BLE 33 Peripheral Not Updating - Nano 33 BLE Sense - Arduino Forum
Maybe your like
Hello team - I have a fairly basic BLE 33 Peripheral sketch. It compiles and uploads without issue.
Where it fails (or my logic or ability fails) is in reading correct values from the defined Service Characteristic, or recognising Write updates occurring from any Central app.
The attached shows pre-loading the only Characteristic with 'A' however when reading the characteristic values "1" is returned. What have I done incorrectly?
When testing with the LightBlue app (installed on iPhone) I can clearly see 'A' loaded to the relevant characteristic (UUID commencing with 19B10001) and if I writeValue() to the same characteristic with a central app I can see the characteristic updated, however no change to "1" being returned from the readValue() statement.
Any insight or assistance will be very much appreciated.
#include <ArduinoBLE.h> const char* deviceServiceUuid = "19b10000-e8f2-537e-4f6c-d104768a1214"; const char* deviceServiceCharacteristicUuid = "19b10001-e8f2-537e-4f6c-d104768a1214"; BLEService appService(deviceServiceUuid); BLEByteCharacteristic appCharacteristic(deviceServiceCharacteristicUuid, BLERead | BLEWrite); byte uuval = 0; void setup() { Serial.begin(9600); if (!BLE.begin()) { Serial.println("- Starting BLE module failed!"); while (1); } BLE.setLocalName("Nano 33 BLE"); BLE.setAdvertisedService(appService); appService.addCharacteristic(appCharacteristic); BLE.addService(appService); appCharacteristic.writeValue('A'); // this works, visible in LightBlue BLE.advertise(); Serial.println("Nano 33 BLE (Peripheral Device)"); } void loop() { BLEDevice central = BLE.central(); Serial.println("- Discovering central device..."); delay(500); if (central) { Serial.println("* Connected to central device!"); Serial.print("* Device MAC address: "); Serial.println(central.address()); Serial.println(" "); while (central.connected()) { if (appCharacteristic.valueUpdated()){ // never being triggered because it sees an unchangeing "1" not the value visible via LightBlue appCharacteristic.readValue(uuval); Received(uuval); } Serial.print("characteristic value:"); Serial.println(appCharacteristic.readValue(uuval)); // shows "1" not A. Doesn't show update when sending new data from Central } Serial.println("* Disconnected to central device!"); } } void Received(byte VAL) { Serial.println("- Received New Value"); if(VAL == 0x41) Serial.println("A"); else if(VAL == 0x42) Serial.println("B"); else if(VAL == 0x43) Serial.println("C"); else if(VAL == 0x01) Serial.println("1"); else if(VAL == 0x02) Serial.println("2"); }Tag » Arduino Ble Readvalue
-
ArduinoBLE - adValue() - Arduino Reference
-
Understanding BLE lue() - Arduino Forum
-
ArduinoBLE - Arduino Reference
-
Get Continuously The Value Of A BLE Service, Communication ...
-
BLE Central Print Out Values Of Int Characteristic - Arduino Forum
-
dValue! - MKRWIFI1010 - Arduino Forum
-
ARduinoBLE Write INT? - Programming Questions - Arduino Forum
-
Converting Uint8_t Using Arduino 33 BLE And NRF
-
BLERemoteCharacteristic::readValue() Does Not Return The Correct ...
-
Read From One Characteristic · P5.ble.js - ITP
-
Esp-nimble-cpp: NimBLERemoteDescriptor Class Reference
-
BLE Characteristic ReadValue Cannot Reliably Read Data - ESP32 Forum
-
Unable To WriteValue Or ReadValue On BLE Characteristics #4509
-
Python - Blupy Read Value From Chacteristics As Integer And Not As Ascii