What bluetooth device to choose?

Hi!

For a project, I need to send some data (both binary and strings) between and Android device and a Arduino. The obvious choice was to use bluetooth with UART.

I happened to have a HM-10 clone laying around, so I burned the real HM-10 firmware and got everything working. Problem is, using some Play Store app for testing, there seams to be a quite big delay from when I sent the data from Android to when I receive it on the Arduino.

Also, the HM-10 only supports data packages less than 20 bytes, and I might need up to ~50 bytes per package.

BLE 4.0+ also seams a bit tricky to operate compared to older versions where you just connect and start sending data via a Bluetooth socket (on Android).

Does anyone have any experience sending more than 20 bytes of data over bluetooth and what module did you use for this?

I'm currently thinking of HC-06 or something in that area.

Thanks in advanced!

I use HC-06 which supplies a constant stream of data, was used to download files averaging 250k, and I have never seen any delays. I have used HC-05 in an identical manner.

HM-10 only supports data packages less than 20 bytes, and I might need up to ~50 bytes per package.

I have no idea what this is about, but I understand the HM-10 is a drop-in replacement for the HC-05. In the light of that, I suspect what you say is either untrue, or not a problem.

BLE 4.0+ also seams a bit tricky to operate compared to older versions where you just connect and start sending data

This might have been true once. I rather suspect this was because the BLE game was hijacked by incompetant nerds who kept shifting the goalposts, but BLE is now mainstream and, since you have one, I rather doubt that you need to get an HC-0x.

I have never seen any delays

The delays I was seeing turned out to be because I used "Serial1.readString()". When swiching to a loop that read a byte/char at the time the delay was removed.

I suspect what you say is either untrue, or not a problem.

Here is the work mode information from the PDF:

Mode 0:
Before establishing a connection, you can use the AT command
configuration module through UART.
After established a connection, you can send data to remote side from
each other.

Mode 1:
Before establishing a connection, you can use the AT command
configuration module through UART.
After established a connection, you can send data to remote side. Remote
side can do fellows:
Send AT command configuration module.
Collect PIO04 to the PIO11 pins input state of HM-10.
Collect PIO03 pins input state of HM-11.
Remote control PIO2, PIO3 pins output state of HM-10.
Remote control PIO2 pin output state of HM-11.
Send data to module UART port (not include any AT command and per package must less than 20 bytes).

Mode 2:
Before establishing a connection, you can use the AT command
configuration module through UART.
After established a connection, you can send data to remote side. Remote
side can do fellows:
Send AT command configuration module.
Remote control PIO2 to PIO11 pins output state of HM-10.
Remote control PIO2, PIO3 pins output state of HM-11.
Send data to module UART port (not include any AT command and per package must less than 20 bytes).

I did solve this by just splitting it up and sending it in 20b packages and sending it with a totalt-lenght byte first so that the Arduino could just assemble it again.

This might have been true once. I rather suspect this was because the BLE game was hijacked by incompetant nerds who kept shifting the goalposts, but BLE is now mainstream and, since you have one, I rather doubt that you need to get an HC-0x.

Well, it's been a few years since I even look at any bluetooth communication on Android, so the API has changed I guess. Looking at it now, It's not as complicated as I thought.

he delays I was seeing turned out to be because I used "Serial1.readString()". When swiching to a loop that read a byte/char at the time the delay was removed.

I haven't heard of "Serial1.readString()". getting rid of it was probably a good move.

Before establishing a connection, you can use the AT command

Is noteworthy. It implies you don't need to, and you may never need to. And splitting it up into 20b packages was probably unnecessary.

so the API has changed I guess. Looking at it now

I don't think it was the API, I think we got rid of the nerds. And indeed one of the great things about bluetooth is that it is easier than you thought.

You should be able to treat bluetooth just like you treat the serial monitor.

Nick_Pyner:
I haven't heard of "Serial1.readString()". getting rid of it was probably a good move.

I'm using the Arduino Micro Pro with the Atmel ATmega32U4, that has Serial for usb-serial and Serial1 for the RX/TX. The readString() has a timeout unless I send a new-line char, which I don't

Nick_Pyner:
Is noteworthy. It implies you don't need to, and you may never need to. And splitting it up into 20b packages was probably unnecessary.

While testing with apps like BLE Scanner, I was only able to receive 20 byte. In retrospect that might also have been the app limiting it to sending only the first 20 bytes of the string without any AT-commands.

By changing the code a bit (removing the readString() for example) and reading each byte into a buffer, I'm now able to receive 128 bytes without issue (with my own app). Tried 256, but where was more than 500ms delay between sending the data and the data being printed out to the usb serial (both Serial and Serial1 running at a baud rate of 115'200). That was a bit to much for this project. Anyhow, 128 bytes will be enough for now.

Nick_Pyner:
I don't think it was the API, I think we got rid of the nerds. And indeed one of the great things about bluetooth is that it is easier than you thought.

You should be able to treat bluetooth just like you treat the serial monitor.

Perhaps, I can't say for sure, but I recall BLE on Android being a bit more complex to utilize a few years ago than I felt today, code wise. It might be due to changes in the API or due to me growing as an Android developer.

FYI, this project will remote control a custom made media player on an Android device. The app will display music videos or (when playing mp3's) music visualizations in fullscreen. The remote will be use to change tracks and what not. So I'll need to send the track name (artist and title) to the Arduino to be displayed on an OLED display so you know what song you're selecting.

This will be used in a modded show-car with large sound system, the Android device (tablet) will be connected to a LCD display in the back via HDMI. Having the ability to change song on the display will look bad on the big screen as Android will just mirror the image of the tablets display to the external one. :slight_smile:

OK, I think this is beyond me. I just send data and receive commands to dump files

sending only the first 20 bytes of the string without any AT-commands.

And I have no idea why you would need to send AT commands. They are for Bluetooth, not Arduino, and I can only repeat the last line of my previous.

Thanks for the comment on the Micro Pro.

Nick_Pyner:
I have no idea why you would need to send AT commands. They are for Bluetooth, not Arduino, and I can only repeat the last line of my previous.

I don't need to send AT commands, and I'm not. With the app I tested with first, I was only able to send 20 byte of string-data even if I just typed in "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" (30 chars). :stuck_out_tongue:

Anyhow, the issue has now been resolved so :slight_smile: