I am connecting an Arduino Nano 33 BLE to an Android smartphone to send the detection of a fall. I would like to set an alarm in the app and show the background of a label in red, for instance. My problem seems to be with the data type I am sending. I've tried different options: short floats, unsigned integers and bytes. This is the code I use in the Arduino to send an integer, for instance:
When the fall condition is activated, I see the number 1 with green background in the app but I fail to see a red background with the text FALL DETECTED. This seems to be due to a failure in the if block when I compare the received value to 1 but I cannot understand why. How can I do that comparison so I can detect the number 1 effectively?
Thank you for your help. Shame on me, I should’ve read more carefully the BLE reference guide where it is clearly stated that the received data type is a list. Moreover, many examples I have seen use lists, but I thought that the idea was to populate a list with the incoming data in floats, integers or whatever which is precisely what is done automatically.
Please, let me ask you another question to make sure that I’ve been doing things correctly:
If I want to receive notifications of the magnitude of the acceleration and the magnitude of the angular speed, do I need to pack them in a string in the peripheral before sending the data and then parse that string to get the magnitudes in the central device? or can you register to receive data from more than one characteristic? I’ve tried the latter but I failed and I want to discard it if it is not possible.
Applications such as nRF Connect can receive notified data from several characteristics.
It should be possible to register for multiple UUIDs with a single BLE component. You would only need multiple BLE components if connecting to more than one device.
I finally managed to receive two float data registering their UUID in a single BLE as you pointed out. The problem I had had before was with the selection of the UUID to process the data when a float was received. I usually declare my UUID in caps but appinventor strings for UUID are in small caps so the condition to know what float I was receiving never matched!
I also include the piece of debugging code that helped me to find the mismatch between the characteristic UUID (in small caps) and my string (in caps).