Hello everyone,
I am trying to understand how to use correctly the BLE on the NANO 33 BLE board.
I run this code to understand the basics and see my values :
#include <ArduinoBLE.h>
#define BLE_Temperature_Service_UUID "859862e5-7ebf-4992-ae0c-4995d8eb271f"
#define BLE_Float_Val_UUID "39605f73-4d22-4660-bc38-6840efef94d5"
#define BLE_Temperature_UUID "5b3900d8-a713-4eae-b472-0340c4dcdc72"
#define BLE_IntVal_UUID "5b3902d5-a253-4eae-b472-0340c4dcdc72"
BLEService temperatureService( BLE_Temperature_Service_UUID ); // User defined service
BLEFloatCharacteristic temperatureCharacteristic( BLE_Temperature_UUID ,BLERead ); // remote clients will only be able to read this
BLEFloatCharacteristic floatValueCharacteristic( BLE_Float_Val_UUID ,BLERead ); // remote clients will only be able to read this
BLEIntCharacteristic intValueCharacteristic(BLE_IntVal_UUID ,BLERead );
float floatValue = 0.0;
float stored_temp = 32.9874;
int intVAL = 32;
void setup() {
Serial.begin(9600); // initialize serial communication
while (!Serial);
if (!BLE.begin()) { // initialize BLE
Serial.println("starting BLE failed!");
while (1);
}
BLE.setLocalName("Nano33BLE"); // Set name for connection
BLE.setAdvertisedService(temperatureService); // Advertise service
//BLE and characteristics
temperatureService.addCharacteristic(temperatureCharacteristic); // Add characteristic to service
temperatureService.addCharacteristic(floatValueCharacteristic);
temperatureService.addCharacteristic(intValueCharacteristic);
//add Service
BLE.addService(temperatureService);
//set the initial value for charasteristics
temperatureCharacteristic.writeValue( stored_temp);
floatValueCharacteristic.writeValue( floatValue);
intValueCharacteristic.writeValue( intVAL);
BLE.advertise(); // Start advertising
Serial.print("Peripheral device MAC: ");
Serial.println(BLE.address());
Serial.println("Waiting for connections...");
}
void loop() {
BLEDevice central = BLE.central(); // Wait for a BLE central to connect
// if a central is connected to the peripheral:
if (central) {
Serial.print("Connected to central MAC: ");
// print the central's BT address:
Serial.println(central.address());
while (central.connected()){} // keep looping while connected
Serial.print("Disconnected from central MAC: ");
Serial.println(central.address());
}
}
I connect to my phone with the nRF Connect app and this is what I get:
The value (0x)19-F3-03-42 should represent the stored_temp = 32.9874;
According to the documentation I found:
So I thought my stored_temp would be either on IEEE-754 or IEEE-11073 but neither of those returns to me 32.9874.
Am I missing something?