Protocol for sending analog time-series data over Bluetooth

Hi!

I am tinkering on a project where I would like to send analog signal data to a nearby device via Bluetooth.

The basics are already working, so, I am able to send data from my phone to the device and vice versa.

My question here is regarding how I should send this data to another device. I know I can just send the data as is, but I was wondering whether there is already a particular protocol for something like that and whether or not I'd need some sort of compression. I'm not sure what we can achieve with 8MHz.

Let's assume I have various sensor which I want to record at various speeds e.g. at 100Hz and another at 500Hz and so on. Are there libraries that can help me here or would I have to write this myself?

Bluetooth is the protocol. Perhaps you mean "data format"?

From memory I think NASA (the space people) published a bunch of binary data interchange formats that pre-date the emergence of self describing format such as XML and JSON.

If you are recording something like sound or vibration then of course there is the format used by WAV files.

Is every sample different from the last?
If you have a run of identical values then the simplest compression scheme is to only send a sample when there has been a significant change in the value. The definition of 'significant' is up to you.

At such rate you are hitting BLE maximum practical throughput, so you want to squeeze your data as much as possible. There is no space for headers that would describe what data are sent. Compression is quite tricky here (very small packet and you don't want to rely on the previous packet in order to keep it robust), depending on data nature it may be not worth applying (if most of the time values are constant but you are most interested in cases when they are changing fast, then difference-based compression would give you nice performance when you are not much interested in data, and poor performance where it matters most)

Well, no I really meant a protocol on top of Bluetooth but I guess it makes sense what the_3d6 is saying. It's probably best to send the raw data. Perhaps just something like [timestamp, label, value] and that's it.

The word 'protocol' is usually used in the context of bidirectional communication with flow control, ACKs, timeouts and retries and so on.
You are describing a data format that lives outside the context of communication.

Some do, some don't. For example using a heart-rate sensor would require me to send a lot more data as compared to a simple temperature sensor. What you're saying makes sense so it's probably best to limit the frequency of each sample as well as using delta-sampling.

1 Like

Makes sense. Thanks for the explanation :slight_smile:

And perhaps not even that. The label is surely redundant - or should be. The timestamp should be able to be applied at the receiving end.

I have a DSD TECH HM-19 Bluetooth 5.0 BLE Module which I would like to get some information from in command-mode.

The following code is supposed to set the module in command mode and read out its responses:

#include <SoftwareSerial.h>

#define MD_PIN 9   // Pin for setting bluetooth module mode
#define RX_PIN 10  // Pin for receiving data from BT module
#define TX_PIN 11  // Pin for sending data to BT module

SoftwareSerial BTSerial(RX_PIN, TX_PIN);  // RX, TX

void setup() {
  Serial.begin(9600);

  pinMode(MD_PIN, OUTPUT);
  digitalWrite(MD_PIN, HIGH);  // Activate AT-mode

  Serial.println("Enter AT commands:");
  BTSerial.begin(9600);
}

void loop() {

  if (Serial.available()) {
    BTSerial.write(Serial.read());
  }

  if (BTSerial.available()) {
    Serial.write(BTSerial.read());
  }
}

However, the response, provide e.g. the command AT, is a non-ascii character. Same for things like AT+NAME? etc.

This kinda lookd like as if the baud rate was wrong bot according to the datasheet, the detault is 9600.

Not sure what I'm doing wrrong here..

I've also tried to remove VCC and re-power it making sure MD_PIN is indeed set to HIGH on power up but that didn't help either.

Also note: I have a HC-05 Bluetooth Module as well which works essentially the same way except its default baud rate is 38400 in command mode. If I switch those module, the HC-05 works without issues.

image

Yes, the Serial Monitor appends "Both NL & CR".

According to the data sheet, you don't want the NL/CR.

8 AT Commands
Factory default setting:
Baud: 9600, N, 8, 1; Peripheral Role; transmit mode.
AT Command format:
Uppercase AT command format. string format, without any other
symbol. (e.g. \r or \n).

Unfortunately, it responds the same way even without \r\n.

Changing it to "No Line Ending" gives the same result.

So I've wasted a lot of time learning that there's a huge number of BT modules out there. I think I was a bit naive in believing that there's some kind of standard out there..

I'm looking at three different modules and every single one has a different issue. The first is outdated (my fault) as it's not supporting BLE, the other one is a clone (also my fault) which I simply cannot get to work and the third is from DSD TECH which, for whatever reason, won't send me meaningful responses in command mode.

The only module that didn't make me go crazy is the HM-05 module I have but this one, of course, won't connect with my JavaScript client because, of course, it has no BLE and, of course, BT Classic is not supported. Of course.

So, I can't be the only one with this issue: Is there a BT module which is "the way to go" somebody can recommend?

At this point I would like to highlight that all this wasn't necessary if I was able to figure out what's wrong with the DSD TECH module.

That's a lot of words, without telling us what it is you want to do.

Hi

.....In case you are looking for a decent BLE module for your cards , go with original HM-10 from Jinan Huamo Technology

actual firmware is 7.0.7
AT commands manual downloadable : clic on "BLE4.0 modules "

read Martin Currey's page

Hi!
I use Nano 33IOT and nano 33BLE for my projects as they have included BLE communication through Nina module.

With the arduino BLE library, you must be able to link with your javascript or other.

I have given up working with HC-05, HC-06, etc and similar modules
the ESP32 is low cost (approximatly £7 in UK), has a powerful processor, plentry of flash and SRAM (for a microcontroller), onboard WiFi, Bluetooth Classic 2.0 and BLE
can be programmed using the Arduino IDE

1 Like

At this point I can basically throw away almost everything I got, and on top of that, it's just a matter of time until I scrap the Arduino IDE for something more sophisticated (it's just not really something for larger projects).

But thank you for the advice because I'm not trying to re-invent the wheel here, I just want my project to progress and not care about Bluetooth..

I'm currently looking for a board, I can't find one with a Type-C (except one where a users says they got delivered without Type-C).

Can you recommend something?

got the impression from post 1 you were looking for BLE

never seen a microcontroller development board with a type-C connector