How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

This forum is for the discussion of other projects on Megasquirt/Microsquirt hardware that don't fit into any of the other forums

Moderators: jsmcortina, muythaibxr

How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby Crazy2287 » Tue Apr 18, 2017 6:44 am

Hello all.
This thread was a huge help when doing this, But i found the information disjointed and confusing sifting through so many posts, I'm hoping i can give everyone a rocksolid "how to" To get this working.
viewtopic.php?f=122&t=43883

Ordering, Configuring and setting up the HC-05 Bluetooth unit for tuning the MS-ECU with Tuner studio.

Image

Edit:
Note: The MS-ECU uses 5v Level TTL, while the HC-05 Uses 3.3V TTL. There have been zero failures as far as i know, and many people run these HC-05 off the MS-ECU's 5v TTL. My 2 devices are communicating with each other flawlessly so far. So i am not really sure how much of an issue this really is.
If anyone experiences any issues with Comms or the HC-05 failing outright, and you think it could be due to the TTL levels, please let us know. At the bottom of this guide is a quick top on a mod for a voltage divider, You can incorporate this into the 5v TTL (only the HC/05's RXD pin needs this mod) if you wish.
The risk is, the MS-ECU could possibly have coms issues triggering from a 3v level if it's looking for 5v. And the 5V from the MS-ECU could damage the input to the HC-05. But the devices have been communicating flawlessly to this point, and no one has reported any failures due to the 5v TTL, so I don't see any reason worth complicating the bluetooth mod. But I leave it up to you. See the bottom of this guide for a voltage divider mod to drop the 5v TTL to around 3.3v
/Edit.


You'll need 3 things to get this to work.
A USB-RS232 TTL converter
A HC-05 bluetooth unit
A terminal application

USB-RS232 TTL converter:
https://www.google.com.au/search?q=usb+ttl+converter&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjmupCD_d_TAhVIEbwKHch_B84Q_AUICigB&biw=1782&bih=990
It's purpose is to emulate a serial com port. When you plug it into the computer and install the drivers it will operate as a RS232 over USB, It's intention is to be "Invisible" In other words the computer treats it as a normal serial port. It should (and i encourage you to check this) ouput TTL voltage level which is 3.3v on its RXD/TXD pins. This is important, The HC-05 will not communicate with a 5v or 12v serial connection.
There are several types available and to my knowledge they should all work as long as they are 3.3v (TTL) and have drivers, Some install automatically, some need the drivers downloaded form a 3rd party. I use a PL2303 (type that in ebay) based unit.

HC-05 Bluetooth module:
(search that on ebay, I recommend the one with the button like i got, circled in the pic above, as this makes programming easier)
These modules are designed to operate as an invisible serial link. Meaning when configured correctly, the computer and the connected device see a RS232 connection.
You put serial in one end, it communicates that over a blutooth connection. i recommend the HC-05 (http://www.ebay.com/sch/i.html?&_from=R40&_trksid=p2386202.m570.l1313.TR11.TRC1.A0.H0.Xhc-05.TRS0&_nkw=hc-05) as it can be configured to operate as a Master (seeks out and establishes bluetooth connections), Or a slave(passively awaits a connection attempt). They can be easily configured to different Baud rates to support MS1, or MS2. I'm assuming MS3 as well but I have not done this. Make sure you get HC-05 (type that in ebay) and I recommend getting the units that have the small tactile momentary switch (circled in the pic above) This switch makes programming the unit easier.
I recommend purchasing 2 of these units, You should be able to do it for under $15. Then you can configure a master and slave device, And establish a secure connection to the megasquirt in tuner studio in around 5 seconds after MS-ECU boot. That is not a joke, it's that fast!

A terminal application:
I use realterm: https://sourceforge.net/projects/realterm/
If you use this app, The first thing you should do is ensure the following is ALWAYS SET. (If you use any other application, you'll need to figure it out yourself)
Display tab - Select half duplex (this shows what you type, otherwise you'll have no idea)
Port tab - Parity = None, Data bits = 8, Stop bits = 1, Hardware flow control = None, Baud = 38400 (this is the baud rate that the HC-05 will operate on when in programming mode), Port = Select the port your USB-RS232-TTL device is installed as. Then ensure you click the "change" button and check the detail on the bottom right match those you've just selected.
Send tab - In the "EOL" section ensure "CR" and "LF" are checked (this lets the HC-05 know when the command is finished, otherwise it will lock up and stop responding)
While in the "Send" tab, you will be typing your commands into the empty boxes on the left, And clicking "Send ASCII"


Setting up and programming the HC-05 via USB-TTL converter

Once you get your USB-TTL converter, Plug it into your PC. Ensure it installed correctly. If it does not, Find and update the drivers. Ensure it is installed and recognized as a COM device.
Once your happy it's installed, You can test you have everything set right. Get a jumper and connect the TTL converter's RXD and TXD pins together, creating a feedback loop. Then open your terminal program and test the connection. Make sure you have it set up as described above, and anything you send, Should be be echoed back. In the series of screens below, The first shows the successful feedback, In green is what i sent on TXD, and in yellow is what the TTL converter received on RXD. Hence, you've made a communication loop.
Image

Now unplug the TTL converter and connect the HC-05 to the header pins on the back:
HC-05 <> USB-TTL
VCC <> 5v
Ground<>Ground
RX <>TX
TX <>RX

Image


Programming the HC-05 to work with MS-ECU:

If you purchased the unit with the small tactile button, this is where you hold the button down. If not, you need to connect 5v to the "Key" header pin. If the breakout board does not have a Key header pine, you may be able to find a pinout for the HC-05 chip and sort it out that way.
While holding down the button, Plug the USB-TTL into the computer. The status led on the HC-05 will start to flash a 2 second on-off cycle/
Let the button go and launch your terminal application. Ensure the settings are correct. If using Realterm, set it up as instructed and get ready to send the following commands.
Note:
When setting the blutooth name, you will not be able to confirm it. If you send the "AT+NAME?" queary to the device, it will not reply with the name. This is a limitation with the HC-05 and is documented in it's manual. To confirm the name you need to unplug the USB-TTL and (Do NOT hold the button on the HC-05) plug it back in. The device should boot and start blinking quickly, showing it is in search mode. Wait a few seconds then search using a blutooth device (such as a mobile phone) to see if the HC-05 appears in the list of available bluetooth devices. The default name is "HC-05"

For MS1 set board speed to 9600, For MS2 set board speed to 115200
Set blutooth name and a password (for example "My fully sick car" and "1234")
Set to Slave

Note: Ensure all commands are entered in CAPITALS
The commands are below, followed by a ">" and the expected reply from the HC-05.
AT > OK
AT+NAME=My Cool Car > OK (note: You cannot query the device name with a HC-05. It will reply with "OK" and you must just trust it has updated. You can only check later by searching for the device via bluetooth)
AT+UART=115200,0,0 > OK (Where "115200" you put the msecu's baud rate. 115200 for MS2 and 9600 for MS1)
AT+UART? > +UART=115200,0,0 > OK (this step confirms the current set baud speed. There will be 2 replys, the first gives the baud speed, the second is the acknowledgement "ok")
AT+ROLE=0 > OK (Setting role to 0=slave and 1=master, You want the MS-ECU's bluetooth to be a slave device)
AT+ROLE? > +ROLE=1 > OK (confirming the setting)
AT+PSWD=1234 > OK (Where "1234" you put the bluetooth password you want to protect the MS-ECU with)
AT+PSWD? > +PSWD=1234 > OK

More details on the HC-05 commands can be found here: http://eskimon.fr/wp-content/uploads/2014/10/commandes_AT_HC05.pdf

Follow the logic of the attached screenshot.
Image

Now remove the HC-05 from the TTL device, Put it aside and mark it so you know it is to the MS-ECU device. We will call it the Slave.


Programming a second device to connect to the Megasquirt:

If you have a second HC-05, connect it to the TTL. We will be using this device as the Master You can skip this step for now, and come back to it after installing the 'Salve' HC-05 onto the MSECU.
Re enter programming mode and follow the logic you learned for the first device:
For MS1 set board speed to 9600 (for the Master, whatever you set the baud speed to, Tuner studio must also be set to, so it is easiest to set it to the same as you MSecu version)
For MS2 set board speed to 115200 (for the Master, whatever you set the baud speed to here, Tuner studio must also be set to, so it is easiest to set it to the same as you MSecu version)
Set to Master (AT+ROLE=1)
Set password, Use same password as before.
Set name (name can be anything, does not need to be same as before)
Your second HC-05 is now a dedicated MS-ECU communicator. Unplug it, and plug it back in (without holding the button) and it will boot into search mode.
Open Tuner studio and point it towards the COM port for the TTL device.


Installing the Slave HC-05 onto the MSECU V3.0 mainboard:

Now you need to get your hands dirty on the MSECU.
Get Your Slave HC-05. You need to solder it onto the board. It needs to go between the processor and the RS232 IC U6. Connect the following to the U6 IC on the MS board:
VCC <>Pin 16
Ground <>Pin 15
TX <> Pin 12
RX <> Pin 11

You should add a toggle switch to the VCC wire. So you can power down the bluetooth. You will need to power the bluetooth down to connect a serial connector to the DB9 on the megasquirt. This is needed to flash firmware, or if there is a problem with bluetooth.
You cannot and should not attempt to communicate with both DB9 and Bluetooth at the same time.

I recommend using the underside of the U6 chip directly, as showen in this pic, i used a 4 pin header connector I robbed off some other electronics, making it eazy for me to remove the HC-05 off the board if needed.
Image
Image

Now, power up the MS ecu.
If everything worked correctly, The master HC-05 (If it is still plugged into your computer and powered up?) will connect to the HC-05 slave in less than 5 seconds, and tuner studio will start communicating with the megasquirt.
If you don't have a second HC-05 setup, you can now search for the MS-ECU with your bluetooth laptop/phone and attempt to connect to it.


I hope this guide was eazy to follow and somewhat fool proof. Feedback is welcome!


EDIT:
ME-ECU 5v TTL Mod - Optional

Since the MS-ECU uses 5v TTL, and the HC-05 uses 3.3v TTL, Some people have expressed concerns that the HC-05 may fail due to the higher voltage on it's RXD pin. While no one could conform if this risk has ever eventuated in a failed unit, below is a simple fix to put your mind at ease if you choose.
This only needs to be carried out on the RXD pin of the HC-05.
You will need a couple of resistors. We will be building a simple voltage divider. The goal is to get around 3.3v at the RDX pin. I used a 1kohm and a 3.9kohm which when checked with an oscilloscope, gave me 3.4v
To setup the circuit we will have 2 resistors. R1 and R2. You can use whatever 1/4w or 1/8w resistors you have kicking.
R1 should be somewhere between 1k and 10k.
R2 should be 3.5-3.9x the value of R1 (This is a figure i made up from testing. and should give you between 3.2-3.4v signal. This might not add up to 5v for those of you plugging this through ohms law, But remember the 5v TTL will be as close to the CPU's VCC as it can be, but it will not actually reach 5v.)

R1 connects on lead to pin 11 and the other to R2, R2's other lead then connects to Proto ground.
At the junction of R1 and R2, you connect RX from the HC-05
Image

This is how i installed it on the board:
Image
Last edited by Crazy2287 on Mon May 15, 2017 1:39 am, edited 4 times in total.
*insert witty comment here*
User avatar
Crazy2287
Helpful MS/Extra'er
 
Posts: 50
Joined: Sun Aug 20, 2006 9:35 pm

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby Crazy2287 » Mon May 08, 2017 6:30 am

Hello all, Bumping this thread now that it's finished. Hope it helps some people get this working =)
*insert witty comment here*
User avatar
Crazy2287
Helpful MS/Extra'er
 
Posts: 50
Joined: Sun Aug 20, 2006 9:35 pm

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby Raymond_B » Mon May 08, 2017 7:52 am

Thank you for such a detailed write up! Much appreciated.
1995 Ford Lightning. Dart based 427 Windsor, Novi 2000, full sequential, E-85, etc. MS3/3X
Friends don't let friends share tunes...
http://www.buildpics.org/
Raymond_B
Master MS/Extra'er
 
Posts: 464
Joined: Thu Mar 06, 2014 2:17 pm

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby Crazy2287 » Mon May 15, 2017 1:44 am

Some people expressed concerns of the 5V level TTL of the CPU talking to the 3.3v TTL of the HC-05
No one could confirm that they had ever had an actual failure of the HC-05 or issues with comms because of this.
Originally I thought the CPU was a 3.3v TTL but it turns out it's not.
I've devised an easy method for stepping the RX into the HC-05 from 5v to 3.3 with a simple voltage divider. It can be found at the bottom of the original post.
It is entirely up to you if you want to use this, In all reported cases, connecting directly to pin 11 has never resulted in a failure of a HC-05 nor has it caused communication issues.
*insert witty comment here*
User avatar
Crazy2287
Helpful MS/Extra'er
 
Posts: 50
Joined: Sun Aug 20, 2006 9:35 pm

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby dontz125 » Mon May 15, 2017 5:55 am

Nice write-up! Two comments, just to stick my oar in. The 4-way connector is available at Mouser, M20-1060400; the 6-way is M20-1060600. The terminals are M20-1160042. These are readily available, and pretty cheap at 10-30 cents each.

The other is addressed more to those who build and sell MS and other units. The HC-05 and friends are NOT approved / certified / whatever by the FCC. For the average person installing an accessory in their own equipment, this is fine, it doesn't matter. As soon as you accept a PENNY to do it for someone else, that transmitter had better have an FCC ID number, or you are looking at HUGE fines and possibly time in jail. This counts in Canada and the EU, as well; most things FCC'd are also licensed for use up here, but the EU has its own mess of regulations. If you're a builder looking to add a feature, there is unfortunately nothing that I've found in the past 1-2 months of looking that is as easy & convenient as the HC series. The RN-42 and SPBT3.0DP2 are good options, but have to be mounted on a carrier board with power supply etc.
dontz125
Super MS/Extra'er
 
Posts: 3538
Joined: Mon May 11, 2009 7:14 pm
Location: Scarborough, ON

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby frechem » Fri Jun 23, 2017 6:16 pm

I got all the way to the last steps of installing the HC-05 to the underside of the U6 chip (without the resistors) but I can't find it on my phone or laptop from there. I could find it on both when connected to the USB-RS232 TTL converter. Is the HC-05 supposed to blink quickly like it did when plugged into the USB-RS232 TTL converter? Mine doesn't. I am getting 4.4v at the VCC and 2.5v at the RXD. I know you said that it should have about 3.3v at the RXD. I did use an on-on toggle (P/N 35-004) if that makes a difference?
frechem
MS/Extra Newbie
 
Posts: 9
Joined: Tue Oct 12, 2010 10:42 am

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby Crazy2287 » Sun Jun 25, 2017 5:40 am

When you provide power to the HC-05 it will boot and search for a connection. Regardless of weather or not RXD/TXD is connected.
Ensure the HC-05 is getting 5v on VCC and 0v/Earth/Ground on the ground pin.
Once power is established the led on the HC-05 unit should blink quickly, until a connection is established, then it will blink slowly.

If this is not happening, remove the HC-05 from the Megasquirt and inspect the board, Make sure you didn't damage anything when soldering. Ensure there are no stray component legs or solder drops shorting anything out. Double check the pins on U6 were the correct ones. Connect it back to the USB-RS232 and ensure the HC-05 is still working.
*insert witty comment here*
User avatar
Crazy2287
Helpful MS/Extra'er
 
Posts: 50
Joined: Sun Aug 20, 2006 9:35 pm

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby frechem » Sun Jun 25, 2017 9:08 am

frechem wrote:I got all the way to the last steps of installing the HC-05 to the underside of the U6 chip (without the resistors) but I can't find it on my phone or laptop from there. I could find it on both when connected to the USB-RS232 TTL converter. Is the HC-05 supposed to blink quickly like it did when plugged into the USB-RS232 TTL converter? Mine doesn't. I am getting 4.4v at the VCC and 2.5v at the RXD. I know you said that it should have about 3.3v at the RXD. I did use an on-on toggle (P/N 35-004) if that makes a difference?


I changed to an on-off-on toggle which didn't help.
frechem
MS/Extra Newbie
 
Posts: 9
Joined: Tue Oct 12, 2010 10:42 am

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby frechem » Sun Jun 25, 2017 9:13 am

Crazy2287 wrote:When you provide power to the HC-05 it will boot and search for a connection. Regardless of weather or not RXD/TXD is connected.
Ensure the HC-05 is getting 5v on VCC and 0v/Earth/Ground on the ground pin.
Once power is established the led on the HC-05 unit should blink quickly, until a connection is established, then it will blink slowly.

If this is not happening, remove the HC-05 from the Megasquirt and inspect the board, Make sure you didn't damage anything when soldering. Ensure there are no stray component legs or solder drops shorting anything out. Double check the pins on U6 were the correct ones. Connect it back to the USB-RS232 and ensure the HC-05 is still working.


Like I said, I am getting 4.4v at VCC when connected to the MS but no blinking. Nothing shorted out on the board or any stray component legs. Double checked the pins and they are the correct ones, I can post a pic if needed. I connected back to the USB-RS232 and the HC-05 is working as it should.
frechem
MS/Extra Newbie
 
Posts: 9
Joined: Tue Oct 12, 2010 10:42 am

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby frechem » Sun Jun 25, 2017 12:44 pm

frechem wrote:Like I said, I am getting 4.4v at VCC when connected to the MS but no blinking. Nothing shorted out on the board or any stray component legs. Double checked the pins and they are the correct ones, I can post a pic if needed. I connected back to the USB-RS232 and the HC-05 is working as it should.


I re-soldered all of the connections and viola it is blinking! I tried to connect to my msdroid and had success so then I tried my laptop with no success. I noticed that my MSDroid was still connected so I closed that and tried my laptop again. I was finally able to connect with my laptop so I thought I would try and see what happens if I tried to connect my MSDroid while my laptop was still connected. No luck, I wasn't able to connect my MSDroid now so it seems like it can only be connected to one device at a time?
frechem
MS/Extra Newbie
 
Posts: 9
Joined: Tue Oct 12, 2010 10:42 am

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby Crazy2287 » Mon Jun 26, 2017 8:45 pm

Correct. You will only be able to connect a single device at a time. Because it is 2 way communication over serial, if you tried to and successfully connected multiple devices you would likely crash the megaquirt.

It's good to hear you have it working! I hope the guide was helpful.
*insert witty comment here*
User avatar
Crazy2287
Helpful MS/Extra'er
 
Posts: 50
Joined: Sun Aug 20, 2006 9:35 pm

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby JoseMiguel » Thu Jun 29, 2017 1:07 pm

Great thread

Just FYI. I have been using this HC-05 modules on MS for about 3-4 years. I feed them with 5v directly from the proto area and NEVER had an issue.

Regards
JoseMiguel
Master MS/Extra'er
 
Posts: 579
Joined: Thu Dec 09, 2010 3:48 pm

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby Crazy2287 » Thu Jun 29, 2017 3:20 pm

Do you mean the 3.3v mod? The mod is for the HC-05's RX header for 3.3v TTL.
As you say, 5v from proto to the H-05's VCC is fine.
Thank you for the contribution!
*insert witty comment here*
User avatar
Crazy2287
Helpful MS/Extra'er
 
Posts: 50
Joined: Sun Aug 20, 2006 9:35 pm

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby MidEng64 » Sat Jul 08, 2017 9:28 pm

I just came across this. Is there a reason the photos from the OP aren't view able any more?
"Were it not for a question, we would still be living in the stone age!"
MidEng64
MS/Extra Newbie
 
Posts: 6
Joined: Tue Jun 27, 2017 11:17 am

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby racingmini_mtl » Sat Jul 08, 2017 10:15 pm

MidEng64 wrote:I just came across this. Is there a reason the photos from the OP aren't view able any more?

Yeah, photobucket is greedy. Google it for more details; it's all over the internet.

Jean
jbperf.com Main site . . . . . . . . . . . . . . . . . . . . . . jbperf.com Forum
Image
racingmini_mtl
Super MS/Extra'er
 
Posts: 7806
Joined: Sun May 02, 2004 6:51 am
Location: Quebec, Canada

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby MidEng64 » Sat Jul 08, 2017 10:42 pm

Yah I have used that module in some other little projects. But the google references in relation to MS mainly point back to this thread.

I'll keep looking.. Thx..
"Were it not for a question, we would still be living in the stone age!"
MidEng64
MS/Extra Newbie
 
Posts: 6
Joined: Tue Jun 27, 2017 11:17 am

Re: How To - MS Onboard Bluetooth Cheap Ebay module (HC-05)

Postby BigBlockMopar » Sun Jul 09, 2017 3:26 am

The missing pics in the above post can be seen by going directly to Crazy's Photobucket folder;
http://s346.photobucket.com/user/crazy2 ... t=3&page=1

---
Photobucket has really screwed the online world with their greed action by leaving millions of images all over the net 'broken'.
I hope some huge class-action suit will follow of this and make them either turn off their hotlinking-block again, or face going through some financially dire times.
---
Daily driver: 1973 Dodge Dart - 318ci engine / MS3x - ignition only for now.
A518 OD transmission / 3.55 rearaxle gears.
More toys on my site: https://www.bigblockmopar.nl/
User avatar
BigBlockMopar
Helpful MS/Extra'er
 
Posts: 133
Joined: Sat Dec 31, 2011 6:10 am
Location: Netherlands


Return to Other Development

Who is online

Users browsing this forum: No registered users and 1 guest