Introduction: Upgrade Your $3 Bluetooth Module to Have HID Firmware
Ever wanted to get your Arduino project to act like a Bluetooth keyboard/mouse or gamepad? If yes, then this is the tutorial for you!
In this Instructable I'm going to show you how to flash your cheap Bluetooth module to make it a whole lot more useful!
Evan Kale already has an awesome ible on this topic, which you can checkout here. Evan's method involves using a Parallel port to do the flashing of the chip. Parallel ports are not a common thing found in computers these days so I thought I would share the process I used to achieve the same thing as Evan's instructable using a cheap USB device so it should work on nearly any computer.
Lets get to it!
Step 1: Check Out the Video
I have made a video where I run through all the steps of the process, so check it out!
I'll cover the same information in this instructable.
Step 2: So, What Are We Doing?
The HC-05 and HC-06 are really common Bluetooth modules used in Arduino projects, they are very easy to connect to and are only about $3 each.
They are pretty basic modules though and don't support too many features. They do however use the exact same chip as modules that are more feature rich, so it is possible to re-flash them with the firmware of these modules to get the same features. One such module is the RN-42
The feature we are most interested in is that the module can work as a HID device. With a Bluetooth HID module you can connect to your arduino projects to your Cell phone or computer and get it to behave like a Mouse/Keyboard or game pad device.
It's worth pointing out that the RN42, while it is a bit more expensive than the HC-05, (about $15 more), there is significantly less effort involved in using one directly! So if you are interested in using a Bluetooth HID module in your project, definitely consider that as a good option! Just personally I really like the thought of upgrading something to do things it wasn't really intended to do!
Step 3: What Do We Need?
We will need the following things to flash the firmware:
- Bluetooth module (either HC-05 or HC-06 will work)
- FTDI Breakout Board (FT232RL) - Make sure to get the one with the pins on the side as shown in the image!
- Male header pins
- Mini USB cable for the FTDI board (you might have one of these already, PS3 controllers used to use them)
- Wires, 4 x 220 Ohm resistors and a breadboard
You pick up all of the above at here:
- HC-05 Bluetooth Module* - $3
- FTDI Board* - $2
- Male Header Pins* - $0.50
- Mini USB cable* - $2
- Basic electronics starter kit* (contains the wires, resistors and the breadboard) - $2.55
*= Affiliate Links
Step 4: Prep for the Circuit
Before we build our circuit for flashing we need to do a bit of prep
First we need to solder the male header pins to the FTDI board as shown in the first picture
Next we need a way of connecting to the pins on the Bluetooth module that are highlighted in the second picture.
Evan has this cool trick using a clothes peg that he describes here in his instructable, but I couldn't get the wires to stay in place, so I ended up just soldering 4 different colour wires to the pins highlighted.
Step 5: Building the Circuit
We now need to build the circuit for flashing the Bluetooth module, its pretty straight forward thankfully
Wire it as shown in the image, but here are some additional comments that are important
- Make sure that the FTDI Logic Level jumper is set to 3.3V as the HC-05 is a 3.3V device (highlighted by green in the picture)
- Despite being a 3.3V device, you want to connect VCC of the module to the 5V pin of the FTDI board, the FTDI board's 3.3V pin can't supply enough current to power the module, and the module has a regulator on the VCC pin.
- You can use any resistors even close to the 220 Ohm value, I used 180 Ohm when I was doing it and it worked perfectly
Step 6: Software Download and Installation
Next we want to download and install the different bit of software we need for the flashing process.
So first we want to download the following:
- Blue Suite Software - This requires you to register, it says you need a business email address, but a Gmail one worked fine for me. After you register they will email you your password. When you login, revisit this link again to be brought to the downloads page
- FTDI Module Drivers - These are the custom drivers that allow us to use the FTDI module to flash the Bluetooth Module. Go to the releases link up the top and download the latest zip file. The readme on this GitHub project is full of good information so if you run into any issues it's worth checking it out
- Zadig Driver Installer - This is for installing a generic driver for you FTDI module that the custom drivers need.
- Blue Suite
- Install the Blue Suite software first (take note of where you choose to install it if you change it from the default). Its a straight forward installer.
- FTDI module Drivers
- Extract the zip file that was downloaded
- Click into the newly extracted folder
- Then click into the lib-win32 folder
- Right click on the usbspi.dll file and copy it.
- Navigate to where you installed the Blue Suite software (for me it was C:\Program files(x86)\ CSR\BlueSuite 2.6.2)
- In this folder there is a file called usbspi.dll, rename it to something else (I called it usbspiBACKUP.dll)
- Right click in the folder and paste the file you copied earlier, you should now have both the new usbspi.dll file where the old one was
- Plug your FTDI board into your computer (Note: I had issues flashing when using a USB hub, so try plugging it in directly to the computer if you can)
- Launch Zadig
- Select the FTDI module from the drop down (should be called FT232R USB UART)
- If you don't see it, go to Options and then List all devices
- Select the libusbK driver and click Install Driver
That't it for installation, now the fun beings!
Step 7: Backing Up the Firmware on the HC-05
The first thing we want to do is backup the firmware that is currently on the HC-05 module in case you ever want to return it to its original state, and also we need to backup the modules current settings.
Dumping the firmware
- Go to your start menu open CSR Bluesuite 2.6.2 -> Blueflash
- Select your FTDI board from the drop down (if it's not automatically selected), its the one labeled "FT232R ..."
- You should now see a status of "Processor Running", if you don't see the message double check your wiring and also check for shorts between cables
- Click the Stop Processor button
- This will enable some other buttons, then click the Dump button
- Choose a location and a name for this backup.
- This will take about 2 minutes to backup
- When it's finished, click the Start Processor button and close BlueFlash
Backing up the settings
- Go to the start menu again and open CSR Bluesuite 2.6.2 -> PSTool
- Select SPI BCCMD and then select your FTDI board in the Port drop down.
- Click File -> Dump
- Choose a location and a name for the setting file, I recommend keeping it together with firmware flash.
- This will take about 1 minute to backup
You should now be left with 3 files, as shown in the last picture. (dump.xdv, dump.xpv and dump.psr)
Step 8: Create a Settings Merge File
When we flash new firmware on these chips, their settings will be overwritten too, but there is some settings we want to keep. So to do this we create a settings file with just the settings we want to keep and merge it onto the modules current settings.
- Create a new text file beside the 3 files created in the previous step, call it update.psr
- Open this new file and also open your settings backup from the previous step (the file ending in .psr)
- Copy the following values from your settings backup to the new file
Step 9: Getting a Backup of the RN42 Firmware
We now need to get a backup of the RN42 firmware.
Checkout Evan's ible again to get the wiring of the RN42 and repeat the process as in the previous step.
You could also check the comment section of Evans ible as there are some very helpful people there that can help with this step!
Step 10: Flash the Firmware Onto the HC-05
So now we want to take the RN-42 firmware we got in the previous step and flash it onto the HC-05.
NOTE: Make sure you have backed up the settings as pre the previous step before doing this, as there is no getting them back after we flash the firmware!
Flashing the firmware
- Open up Blueflash again.
- Click the Stop Processor button.
- Click the Choose File button and select the RN42.xpv you got in the previous step
- Click the Download Button
- When finished, click the Start Processor button and close BlueFlash
Merging the settings
As mentioned in one of the previous steps, the firmware contains all the settings of the chip that it came from, so all the settings of our HC-05 have now been replaced, but we want to keep the ones we saved in the update.psr file
- Open PSTool
- Go to File -> Merge ...
- Select the update.psr file from the earlier step.
- Now if you select Bluetooth Address in the list and click Entry->Read Entry, you should see that it is now the same as the one in your update.psr
Congratulations, you should now have an upgraded HC-05!
Step 11: What Now?
Let's run a quick test that it's behaving as expected! I would leave the SPI pins on til you have tested it at least once!
I'm testing it with an ESP8266 arduino board as it's 3.3V chip so no need for a level shifting (remember that HC-05 is a 3.3V module) but also because it's capable of running software serial at 115200, which is now the default baud rate of the modified HC-05.
- Wire up the module to the ESP8266 as shown in the above picture.
- Download the sample sketch from my Github page
- Upload the sketch to your ESP8266
The sketch is just a simple pass-through from the hardware serial to a configured software serial.
Setting up the module
- Open up the serial monitor in the Arduino IDE
- Select the No Line Ending in the drop down
- Make sure the baud rate is set to 115200
- Type $$$ in and click Send, CMD should be returned.
- You now need to change the line ending back to Newline
- Now type in SF,1 and click Send - This will reset the module to factory settings.
- Now type S~,6 and click Send - This changes the module to HID mode.
- Change the module name if you want to: SN,name_here
- We now want to configure our module to be a mouse and keyboard combo: SH,0230
- And then finally to restart the module with our new settings we type: R,1
Pair with your phone
- Open the Bluetooth settings on your phone and search for new devices
- Your new name for your device should appear, connect to it. (note that it should also have a keyboard symbol as its being reconised as a keyboard device)
Test it out!
- Go back to your serial monitor
- Select No Line Ending
- On your phone, open an app that you can type into
- Now you can type into the serial monitor and when you press Send. What you typed should be input on the phone as a keyboard input.
This is just a simple project to show it working, I have some future projects planned where this will be more useful!, stay tuned!
I just want to say a huge thanks to Evan again for the original instructions, Evan has some really awesome projects so you should definitely check him out!
I hope you enjoyed this project and as always, if you have any questions please let me know and I'll do my best to help!
We have a be nice policy.
Please be positive and constructive.
Whoops, I meant the Dump option is NOT available.
Help, I'm stuck at step 7. Blueflash connects successfully to HC-05, but when I hit stop Processor it gets stuck saying "Downloading Flash Stub" forever. The Dump option is available either :(