Telemetry: Bluetooth

Now that I know how to communicate with the on board diagnostics through USART, I decided to incorporate Bluetooth. The Bluetooth modules that I decided to go with are the HC-05 modules. I chose these because you can adjust the mode for each individual module to slave or master and they are extremely easy to implement. The master module will connect to the ELM327 scanner and the slave will connect to the Discovery board. You could buy an ELM327 scanner that already has Bluetooth, and then you would only need the slave module, but I already had the wired scanner.

Before connecting these modules to the scanner and stm32, you have to set the modes, one to master, and the other to slave. There is already a great blog that describes these steps, which I used to set my modules.
Getting-Bluetooth-modules-talking-to-each-other, by Zak Kemble

Now that the modules are setup, you should be able to power them on and they should automatically connect to each other (if you followed the steps from the site posted). Now it is time to wire them to the scanner and discovery board.

Master Module:
ELM327        BT
5V       —>    5V
GND    —>   GND
Tx        —>   Rx
Rx        —>   Tx

Slave Module:
BT               Discovery
5V       —>    5V
GND   —>    GND
Tx       —>    Rx (PA3 – Any USARTx Rx Line)
Rx       —>    Tx (PA2 – Any USARTx Tx Line)

For the connections to the Discovery board, you can choose any USART lines. For the code that I wrote I chose to use USART2, PA2 and PA3.

To test out the Bluetooth, I wrote a code in Keil that sends anything received on USART2 (Rx from the BT) to USART1. I then connected the USB to USART module to USART1 and my laptop. Anything that is sent from the ELM scanner will be sent through both BT, then to USART1 which is connected to my laptop, this way I can monitor the activity using the terminal. I also connected the Tx lines from USART1 to USART2 so I could also send commands from the terminal. This is pretty much the same setup I used for development, until I got my LCD screen.

Another cool note. You can connect the slave module to the ELM scanner, and then connect to this scanner from your phone (Only Android, not Iphone). You can download a Bluetooth terminal app and send commands to the OBDII. This is really handy when you want to test the output of a particular command quickly. *NOTE: You cannot connect to the master module from your phone, only other slave modules, this is because a master cannot connect to a master and a slave cannot connect to a slave.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s