Reading sensor data sent by bluetooth into browser

830 Views Asked by At

I am working on a React app that will make use of 3 sensor data values in real time.

The data is sent through bluetooth from an nRF52840 chip.

At first I tried the Noble library for bluetooth and it worked right away with minimal code: Noble bluetooth code

The result of running the code above looked like this: Sensor data logging

However when I tried to integrate Noble into my React app I got errors with dependencies when Webpack was making a dll so I did not find a way to integrate it.

I tried the Web Bluetooth API instead using the example here: Web Bluetooth heart rate sensor I tried it out using a Polar H10 I have and that worked well, then I modified it to work with my sensor.

Now I can read sensor values into the browser, but I know they are the wrong values.. they are always around 50-60 ish and do not change as I change the sensor.

I am thinking I need some parsing code, like the heart rate sensor code. However that code is using bit-level & operations, flags and it is assuming little-endian data. I do not know if my data is little endian or not or other bit-level details so I would rather not write parsing code.

I know that Noble for example can read it out of the box so I want something similar, is this possible? Is there some kind of bluetooth standard for reading the data or is this hardware specific? There is no documentation on my hardware so I can't read about it. Here is the code I am currently using, similar to the heart rate sensor code: Bluetooth sensor reading code

1

There are 1 best solutions below

1
On

There are standard Bluetooth services & characteristics, but any hardware may choose (or need) to use custom methods. There is no standard then, not even encoding style such as little/big endian or bytes vs strings.

Options to understand the data are to use tools that can read the data in multiple formats, such as HCI logging, nRF Connect (desktop), or Chrome's chrome://bluetooth-internals.