Help in reading values from a Nano BLE 33 sense to Nano 33 IoT

Hello, I am trying to transfer data from a BLE 33 Sense (BLE peripheral, let's call it TX board) to a BLE 33 IoT (Central, let's call it RX board).
Particularly I am using a simple variable for float (axis X of 33 Sense gyroscope), on ArduinoBLE.h library type is BLEFloatCharacteristics

I am quite sure that:

  • TX and RX are connected;
  • TX is sending data
  • RX identifies the specific charateristic
    but I cannot print received value on Serial, since I have or NULL or 0 value printed, or conversion issues and errors.

Below there is the CENTRAL (RX) part of code not working and I can't resolve.

// retrieve the GYRO characteristic
if(DEBUG){Serial.println("DEBUG retrieve the GYRO characteristic");}
BLECharacteristic gyro_ch_x = peripheral.characteristic("ce7b9417-7860-42d0-87b5-9e35ec8dd241");

if (!gyro_ch_x)
{
if(DEBUG){Serial.println("DEBUG gyro_ch_x ESISTE");}
Serial.println("Peripheral does not have gyro_ch_x characteristic!");
peripheral.disconnect();
return;
// COMMENT: this message has never been printed out, so I am quite sure gyro_ch_x is detected!
}

// while the peripheral is connection
Serial.println(gyro_ch_x.read());
//Serial.println("GyroX=" + gyro_ch_x.value());

At the end I have null value; I tried also to cast gyro_ch_x in a float variable, but it seems it always a BYTE variable with 0 value.

I'm not an experienced programmer, anyway I didn't find in any forum or documentation full example of such code apart from simple int or boolean variable.
I need a float value.

May anyone help me?
Thanks in advance!

GB

http://forum.arduino.cc/index.php?topic=396450.0

Thanks Nick for your help.
Anyway, it seems to be not enough for me and my problem...
Any other help?

For anyone interested
At the end of several exercises, I found that, in ArduinoBLE.h library, function:
BLECharacteristic.readValue(value);
does work with a long variable - it works! I transferred long values from one TX to RX!
does NOT work with a float variable, I have error in Compile phase: "no matching function for call to 'readValue(float&)'
unfortunately this is not specified on library documentation

so I will find a way to transform float into long
bye

GB

Your issue may have something to do with unsigned data type versus signed.

Anyway, there is a data type conversion routine used in BLE Thermometers, which works. IEEE 11073 float. You could try that.

I had created an example using this conversion format here (this library had come from Adafruit):

https://create.arduino.cc/projecthub/gerrikoiot/ble-infrared-thermometer-using-feather-m0-bluefruit-le-board-7e386c

More on the conversion technique here:

Hope that helps you.