The operation add item to list cannot accept the argumants

hey all,

every time I hit the 'start' button Im getting this massage:
image

basicly my app is reciving sensor reading (value only) via ble and suppose among other stuff to save the highest value on each loop.
dose any one know what Im missing?
and dose the canvas blocks are right?


The problem is that global CTAR_DATA is not a list, most probably global CTAR_DATA is set to 0 and that's why you get this error like in the example below. Try to use Do it to debug your blocks

this is how I defined global CTAR_DATA:
image
is there another way to define a new list variable?

Maybe you initialize global variable to create an empty list but at some point set it to 0. I can not see all your blocks, I'm only guessing. Use Do it and post a screenshot of get global CTAR_DATA

Yes, as @dora_paz says.

You initialise your variables as lists, but then you set them to strings (why?), so your variables become strings and are no longer (empty) lists, therefore you cannot add items to them (as a list).

This is what I got.

DTD.aia (206.9 KB)

I uploaded the app mybe it will be easier to find whats wrong

Not really, because your app connects to a bluetooth device of some kind and fetches data.

Show an example of the data your receive that is captured in global Sensor_Value.

Here are the contradictory ways you treat global SENSOR_VALUE:


as a list of numbers (that is what this event returns)

blocks (1)
as a single number


again as a single number


the big picture.

You must learn the blocks that deal with lists and the items in them.

so if I want to update the value of the variable every time the app recives new data, so I will have only one numbre at all time. how do I do it?

This app can't be understood unless the data collection technique is clarified.

How many bytes arrive at each bytesReceived event?

  • enough to plot as a graph, or
  • just a few, that need to accumulated for later graphing from a longer list?

Also, please define

  • CTAR
  • JOR
  • Q_JOR

I have connected a force sensor to an arduino nano and sanding the reading from the sensor every 0.5 sec to the app via BLE, so it suppose to be a single integer every 0.5 sec.
the variables are the amount of loops (repetitions) needed to be made on each exercise.

In that case, define a procedure (copied from the guts of your Start button Click event) that accepts a single Sensor_VALUE , and call it from the BLE BytesReceived event as follows:

when BLE.BytesReceived
  for each byte in byteValues
     set global Sensor_VALUE to byte
     call the graphing procedure with Sensor_VALUE
  end for each
end when BL.BytesReceived

I just noticed something from your data log.

Your data stream has numbers with decimal fractions.
How did you expect them to appear as bytes, which are integers?

Post your sketch, so we can see how you format the data stream.
I suspect the app should be receiving strings, not bytes.

1 Like

I just changed it to floats received.
that should be fine no?

How do we know what is being sent without the sketch that sends it?

#include <ArduinoBLE.h>

#define BLE_BUFFER_SIZES 20
#define BLE_DEVICE_NAME "DTD"
#define BLE_LOCAL_NAME "DTD_1"

int red = 11;
int green = 10;
int blue = 9;
float sensor = A0;
float cf = 19.5; // caliberation factor
float pressureReading;

BLEService BLESensors("00001101-0000-1000-8000-00805F9B34FB");
BLECharacteristic pressureBLE("000B", BLERead | BLENotify | BLEBroadcast, BLE_BUFFER_SIZES);

void setup()
{
LedColor (0,255,0);
Serial.begin(9600);
while (!Serial);

// begin initialization
if (!BLE.begin())
{
Serial.println("starting BLE failed!");

while (1);

}

// set the local name peripheral advertises
BLE.setDeviceName(BLE_DEVICE_NAME);
BLE.setLocalName(BLE_LOCAL_NAME);
BLE.setAdvertisedService(BLESensors);
BLESensors.addCharacteristic(pressureBLE);

    BLE.addService(BLESensors);

// start advertising
BLE.advertise();

Serial.println(("Bluetooth device active, waiting for connections..."));
}

void loop()
{

// listen for BLE peripherals to connect:
BLEDevice central = BLE.central();

// if a central is connected to peripheral:
if (central) {
Serial.print("Connected to central: ");
// print the central's MAC address:
Serial.println(central.address());

// while the central is still connected to peripheral:
while (central.connected()) 
{
  for (int i=0;i<10;i++)
      {
        float Reading = analogRead(sensor); 
        pressureReading = pressureReading + Reading;
        delay (50);
      }
      
      pressureReading = pressureReading / 10;
      pressureReading = (pressureReading * 5.0) / 1023.0;
      pressureReading = pressureReading * cf;

      Serial.println(pressureReading);

      pressureReading = 0;

}
// when the central disconnects, print it out:
Serial.print(F("Disconnected from central: "));
Serial.println(central.address());
}
}

void LedColor(int redL, int greenL, int blueL)
{
analogWrite(red, red);
analogWrite(green, green);
analogWrite(blue, blue);
}

This tells me you should be expecting Strings, not Bytes or Floats.