Reading BLE data from Nano IoT 33

Hello all!

This is my first post at this Forum, I apologize in advance for any mistakes (including language ones).

My intention is to read data from a load cell and send it via Bluetooth to my mobile or laptop. I proudly succeeded doing a prototype with an Uno R3 / HC-05 module / MIT Inventor developed App. But then I decided do downscale the prototype to a Nano 33 IoT, because of it´s size and integrated BLE, wich would dispense the HC-05 module.

After reading a lot and trying to understand how the BLE works, I was finally able to "see" the Nano board at my mobile using NRFConnect. But the data that I´m sending is a float type and NRFC shows it as some kind of HEX type:

Now, there goes the questions:

  1. It seems to be obvious but I didn´t understand yet how I should use BLECharacteristics, BLEByteCharacteristic, BLECharCharacteristic or BLEFloatCharacteristic. It doesn´t seem to have a relation between the data type at the program and what I see at the mobile as a result after BLE processing. The data appears correctly at the serial monitor.

  2. Some examples that I saw used "(byte) data", but I´m also not sure what is this for...

  3. Is it possible to read and store BLE data with any standard Laptop application (like Excel Data Streamer)? (guess I would need a virtual COM port to do it).

Thanks in advance for any contributions!

I use a Nordic UART connection, (ascii not binary)
see this page for some code examples
Arduino NANO 33 Made Easy
You can skip the pfod stuff and just read/write to the bleSerial.

1 Like

Thanks for the tip! @drmpf

You might have done better to use an ESP32 development module which has integrated bluetooth classic as well as BLE.

Using BLE in UART exchange between two devices is a complex way of doing what happens very simply with SPP and bluetooth classic.

But the data that I´m sending is a float type and NRFC shows it as some kind of HEX type:

I think you are seeing the 4 bytes of a ieee-754 floating point number. I don't know if its big or little ended.

I believe that you are going to have to read the 4 bytes into a byte array buffer and then convert to the float. There are several ways to do this, but I like to use

  float value;
  memcpy(&value, receivedArray,  sizeof(receivedArray));
1 Like

Separate the characteristic type from the internal type. They can be the same, but they do not need to be. Create a type that is easy to convey to others e.g., fixed point, signed or unsigned and then tell people what the resolution is. This has been done by the Bluetooth SIG for temperature, humidity and pressure for instance.

The issue is BLE support in programming environments on Windows. Most of the BLE development focuses on mobile applications. I guess nobody wants to run or cycle around with a Windows PC.

If you must use a PC, the best option is likely a second Arduino working as central and sending the data over virtual COM via USB.

That should not matter. What is more interesting, is what the data represents in the real world. Your BLE service and characteristics should be independent of the implementation. That way you can change your sensor design to something better without changing the BLE interface. The same app should work tomorrow.

1 Like

@cattledog , thanks for the tips!

I´ve never used any ESP32 modules. Actually I just begun working with microcontrollers and chose Arduino. I guess there are some differences in coding between them, right? But I´ve already found out that Bluetooth classic is far more easy to use than BLE!

I visited the link you´ve posted and filled the form with the HEX expression that I showed in my original post. The page returned me an "invalid HEX number" message. I guess even IEEE is not understanding what my BLE is sending to my phone at all... :rofl:

@Klaus_K , thanks again!

Ok, now it makes sense for me that whatever BLExCharacteristics I use, mobile will still show bytes just as it receives it.

The idea was to use a laptop, not a desktop, but anyway BLE support in Windows is surely an issue. Windows identified the IoT board, but BLE application that I´ve tried (Bluetooth LE Lab) didn´t. So it was unable to stablish a communication.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.