[help needed] HOWTO use Bluetooth module

Hardware inside and outside of the ECU
Post Reply
User avatar
AndreyB
Site Admin
Posts: 11041
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

HOWTO use Bluetooth module

Post by AndreyB »

On eBay we have plenty of TODO, these are all based on HC04 or HC05 chips.

Image

In order to get UART via one of these Bluetooth Module (BM) you should first initialize the BM itself. One day we will implement a feature of initializing BM from stm32 code, but until we have it one would need to initialize BM with a USB TTL device. The BM initialization needs to happen only before first use, once it is done the BM configuration is stored inside the BM and it does NOT need to be configured on each use.

TODO: details details
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

jedediah_frey
contributor
contributor
Posts: 51
Joined: Tue Nov 05, 2013 1:43 pm

Re: HOWTO use Bluetooth module

Post by jedediah_frey »

The one I got on Amazon is based on the HC-06 module.

Here's a breakdown of the different versions:

HC-03/HC-04 is Industrial Standard, HC-05/HC-06 is Commercial Standard.
HC-03/HC-05 could be configured to Master/Slave by user.
HC-04/HC-06 just be Master or Slave when the factory, can't be configured by user.

It's very easy to use. You setup the Tx/Rx pins and power it up. It appears to just be another serial device. Windows 7 automatically found it and drivers. To change the settings it needs AT commands.

You could easily cycle through all of the bauds on powerup. Test for an "OK" command echo. When the echo is received use that to program it to 115200.

Now this is just for the STM32<->Bluetooth baud. The baud between the computer and bluetooth module is set when you connect to it. The only odd thing is that I get 2 serial devices (just like the linked article) but only 1 connects through.

http://www.elecfreaks.com/wiki/index.php?title=Bluetooth_Bee

User avatar
AndreyB
Site Admin
Posts: 11041
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: HOWTO use Bluetooth module

Post by AndreyB »

What about RAYSON BTM238 / BTM-238? Has anyone heard of this module or it's BTM222 predecessor?
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

puff
contributor
contributor
Posts: 2833
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: HOWTO use Bluetooth module

Post by puff »

what's so special about it? it's still the old bluetooth.
technically, with BLE you can be able to build a native app for iOS devices to control rusefi.

User avatar
Dron_Gus
contributor
contributor
Posts: 204
Joined: Wed Nov 13, 2013 1:11 pm
Location: S-Pb
Github Username: dron0gus

Re: HOWTO use Bluetooth module

Post by Dron_Gus »

puff wrote:
Sun Feb 02, 2020 3:34 pm
what's so special about it? it's still the old bluetooth.
technically, with BLE you can be able to build a native app for iOS devices to control rusefi.
I thought iOS has very limited BT support. Even Chinas BT OBDII scanners does not work.
May be take a look at ESP32 modules? BT + WiFi. RusEFI can have its own Web-page :)

puff
contributor
contributor
Posts: 2833
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: HOWTO use Bluetooth module

Post by puff »

It has limited support of old-style BT, but it works perfectly fine with BLE. Anyway, it needs some efforts to develop the software.

User avatar
Dron_Gus
contributor
contributor
Posts: 204
Joined: Wed Nov 13, 2013 1:11 pm
Location: S-Pb
Github Username: dron0gus

Re: HOWTO use Bluetooth module

Post by Dron_Gus »

puff wrote:
Mon Feb 03, 2020 7:24 am
It has limited support of old-style BT, but it works perfectly fine with BLE. Anyway, it needs some efforts to develop the software.
With ESP32 you will need only web-browser... And some code for ESP side.

User avatar
AndreyB
Site Admin
Posts: 11041
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: HOWTO use Bluetooth module

Post by AndreyB »

Not all Bluetooth is the same apparently, there are five different generations apparently.

HC-05 and HC-06 we usually use seems to be older Bluetooth 2.0?

Our needs are relatively slow and Bluetooth 4.0 or 5.0 could be extending the range for us?

Just ordered myself HM-10 which seems to be Bluetooth 4.0? I am hoping that HM-10 modules are direct drop-in for us.

Also just ordered myself something (maybe HM-19 maybe not?) based on CC2640r2f (OMG it has Arm Cortex-M3 inside! if it works we can call rusEFI a multi-core ECU can we?) - I think this cute Ebyte module shows a small IPX/IPEX antenna connector?

See also https://www.semiconductorstore.com/blog/2018/Bluetooth-1-0-vs-2-0-vs-3-0-vs-4-0-vs-5-0-How-They-Differ-Symmetry-Blog/3147/
Attachments
E104-BT01_UserManual_EN_v1.8.pdf
(2.05 MiB) Downloaded 64 times
CC2640R2F.jpg
CC2640R2F.jpg (63.75 KiB) Viewed 4767 times
HC-06.jpg
HC-06.jpg (80.3 KiB) Viewed 4767 times
HC-05.jpg
HC-05.jpg (65.35 KiB) Viewed 4767 times
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

puff
contributor
contributor
Posts: 2833
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: HOWTO use Bluetooth module

Post by puff »

afaik, anything higher than 2.0 would require much more efforts in terms of software on the pc/smartphone side.
I bet, megalogviewer won't work witht BLE.

User avatar
AndreyB
Site Admin
Posts: 11041
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: HOWTO use Bluetooth module

Post by AndreyB »

I only have time to buy (and sell) stuff :( I guess I will ship some to @kb1gtt when I will be shipping his MREadapter48 :)
Attachments
my_bt_collection.jpg
my_bt_collection.jpg (751.24 KiB) Viewed 3283 times
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

puff
contributor
contributor
Posts: 2833
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: HOWTO use Bluetooth module

Post by puff »

It seems , both are of ble type. You plan to use them as a 'plain' serial communications device?

User avatar
AndreyB
Site Admin
Posts: 11041
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: HOWTO use Bluetooth module

Post by AndreyB »

puff wrote:
Mon Jun 01, 2020 9:14 am
It seems , both are of ble type. You plan to use them as a 'plain' serial communications device?
that was the plan. am I missing some complications? can you elaborate?
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

puff
contributor
contributor
Posts: 2833
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: HOWTO use Bluetooth module

Post by puff »

I'd say you've just obtained some pain in the ass. :D
What's the plan?
From my understanding, now you'll have to write some app (either for android/iOS or for Windows / Linux) that would communicate with that BLE module.
If the plan is to use it with rusefi console, you'd have to implement that in the code.
I haven't seen any ready to use BLE-serial library or BLE-serial driver. Some older PCs would require a BLE usb dongle.
Old-style bluetooth was the most convenient bluetooth solution...

User avatar
AndreyB
Site Admin
Posts: 11041
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: HOWTO use Bluetooth module

Post by AndreyB »

Are you familiar with the concept of https://en.wikipedia.org/wiki/BLUF_(communication) ?

For example lot "HM-10 4.0 BLE Bluetooth Uart Transceiver" clearly states Uart Transceiver in description. Can you please explain what's different about HM-10 exactly and what exactly would custom app be doing?
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

puff
contributor
contributor
Posts: 2833
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: HOWTO use Bluetooth module

Post by puff »

BLUF? WTF is that?
HM-10? You mean to say those CC2541 modules? They can transceive UART, but unlike HC05/06 you won't see a 'normal' com port or anything similar in '/dev/ '. You'll have to write your own code with all those peripherals, centrals, GAPs, GATTS, etc.
I don't how else I can explain it to you.

There are several BLE serial terminals for Android, but you probably don't need a terminal, you need your own custom app?

User avatar
AndreyB
Site Admin
Posts: 11041
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: HOWTO use Bluetooth module

Post by AndreyB »

https://en.wikipedia.org/wiki/BLUF_%28communication%29 means a paragraph where the conclusions and recommendations are placed at the beginning of the text, rather than the end, in order to facilitate rapid decision making

BT classic has a number of standard "profiles" including SPP = Serial Port Profile = which we use to get trivial TTL. Newer BT BLE is cool and fancy but it has _no_ standard profiles everything has to be done more manually on both ends, making UART with BLE way less trivial.
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

Joey120373
donator
donator
Posts: 61
Joined: Sun May 17, 2020 8:46 am

Re: HOWTO use Bluetooth module

Post by Joey120373 »

I have worked for a little while with both the HC-05/06 and the newer HM-10 ( though some report as HM-08 when queried ).

Both are relatively easy, if not a bit finicky to set up with a serial terminal and a bog standard usb to uart adapter.

I have noticed that the AT commands don't always report back as the data sheet would claim they are supposed to, however i can get them to work.

HC-05/06 modules seem to play nice with my android devices, the HM-10 seems to play nice with IOS stuff.
I am using both in one instance, talking to an RS422 to UART converter, to monitor a serial signal at 9600 baud though i have run a few tests at 115200, and there doesn't appear to be any issues there.

Mounting both in a small enclosure seems to work fine and allows the guys at work to use whatever phone they might have to pull up a serial terminal and see the data. Both modules also seem to work fine at 3.3v for the power supply ( most cheap boards are listed at 3.6-5.5v for the power input ).

My biggest complaint would be the quality issues with so many available, and finding the correct data sheet for the module you actually got vs the one that the fleabay seller claimed it was. It can be a bit frustrating.

User avatar
AndreyB
Site Admin
Posts: 11041
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: HOWTO use Bluetooth module

Post by AndreyB »

Well, back to Bluetooth.

We actually have BT initialization code in rusEFI itself

Code: Select all

#if EFI_BLUETOOTH_SETUP
	// Usage:   "bluetooth_hc06 <baud> <name> <pincode>"
	// Example: "bluetooth_hc06 38400 rusefi 1234"
	addConsoleActionSSS("bluetooth_hc05", bluetoothHC05);
	addConsoleActionSSS("bluetooth_hc06", bluetoothHC06);
	addConsoleActionSSS("bluetooth_spp", bluetoothSPP);
	addConsoleAction("bluetooth_cancel", bluetoothCancel);
#endif /* EFI_BLUETOOTH_SETUP */
for end users that mean that if one uses rusEFI console, the following commands are available:

bluetooth_hc05
bluetooth_hc06
bluetooth_spp
bluetooth_cancel


I believe I had those working and that's how I got my HC initialized.

We need to make nicer TS button for same logic https://github.com/rusefi/rusefi/issues/1685
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

tmbryhn
Posts: 57
Joined: Wed Feb 12, 2020 2:40 am
Location: Norway

Re: HOWTO use Bluetooth module

Post by tmbryhn »

I'm currently working on BT implementation for my next rev.:
https://rusefi.com/forum/viewtopic.php?f=2&t=1820&p=38811#p38811

I've had great success with multiple generic HC-05 "fleeBay" modules that has been set up for MS-based ECUs through a simple terminal program using the AT-commands, and been paired directly through TS. I've experienced reasonable reception, even when enclosed in an aluminum case and mounted on the opposite side of the firewall. I however recommend mounting the ECU on the inside for increased coms reliability.

The Proteus STM32F427ZGT6 utilizes "USART3" on the same port pin names as the STM32F407VGT6 used in the MRE v0.5.0:
TX: PB10, pin# 69
RX: PB11, pin# 70.

As far as I understand, all official RusEfi firmware builds are currently released with Bluetooth code included.

Firmware:
- Is the BT code by default for the UART3/USART3 regardless of MCU?
- Does the firmware require additional activation by any means, or is the UART port continuously standing by for incoming messages on the RX pin?
- Will the firmware auto-detect BT module baud rate? Eg. will it be possible to set up the module for 115200 for potential increased data rate?

BT module options:
- Current firmware supports HC-05, HC-06 and SPP-C modules?
- Are there support for other modules, eg. with coax connector for external antenna?

HW-Implementation:
- When making the next PCB rev. with built-in bluetooth footprint, are there any considerations other than routing the TX->RX and RX->TX that should be taken into account?

User avatar
AndreyB
Site Admin
Posts: 11041
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: HOWTO use Bluetooth module

Post by AndreyB »

No. rusEFI uses whatever UART is specified in the specific board file. Different boards are potentially compiled with different pins, that's out of scope of this BT thread. Primary UART channel is hard-coded because that's part of recovery, there is also secondary UART which is somewhat flexible. Some binaries are compiled with USB as primary communication channel and the only UART is flexible. It's a complicated (potentially for no good reason) area.

rusEFI does not auto-detect BT module, rusEFI is mostly not aware of the fact that UART is routed to BT. While we have some BT initialization logic in rusEFI, it's on-demand commands not part default start-up code. This means that any pre-initialized module is supported and there is very little connection between rusEFI and BT in general.
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

tmbryhn
Posts: 57
Joined: Wed Feb 12, 2020 2:40 am
Location: Norway

Re: HOWTO use Bluetooth module

Post by tmbryhn »

I poked around in the board source file; found some UART related in the MRE board_configuration.cpp, but nothing in the Proteus file.

What's the best approach to get an extra UART set up for BT on Proteus if not already ready in current firmware bundle release?

User avatar
AndreyB
Site Admin
Posts: 11041
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: HOWTO use Bluetooth module

Post by AndreyB »

I would assume that Proteus as any other rusEFI board has at least one UART configured. Just hook up pre-configured BT module to that UART and you are good to go!
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

Post Reply