Wayne's Tinkering: Inexpensively Program Your Arduino Via Bluetooth
Wayne's Tinkering: Inexpensively Program Your Arduino Via Bluetooth
Wayne's Tinkering
Page
Inexpensively Program Your Arduino via
Bluetooth
Updated 11-26-2017
I like working with Arduino boards as a quick way to prototype the odd gadget, or
the occasional gizmo, but having to program them via USB cables can be a pain. So,
I decided to investigate ways to do this wirelessly. There are off the shelf solutions
to this problem, such as the official Arduino BT (Bluetooth) board (now, apparently,
discontinued), or the wonderful Bluefruit EZ-Link module from Adafruit, but I wanted
to see what was possible using one of the really cheap (~$4) Bluetooth modules you
can get on eBay. One such device is often labeled the HC-05 module, of which
(caution) there are many variations, but more on that in a moment. I wound up
purchasing a pair of modules that look like this:
1 of 8 10/13/2019, 2:52 AM
Inexpensively Program Your Arduino via Bluetooth - Wayne's Tinkeri... https://sites.google.com/site/wayneholder/inexpensively-program-your...
Each HC-05 "module" is actually built from a component Bluetooth board that's been
mounted onto another PCB on which is added a 3.3 volt regulator, an LED, a
pushbutton and several other passive components. The module came with no
documentation, but I was able to reverse engineer the following, approximate
schematic:
Unfortunately, there are a great variety of modules on the market that all look
roughly similar to the modules I purchased. There seem to be two main variants.
One is based on an HC-05 Bluetooth module. This version supports an extended set
of AT commands that allow it to reprogrammed to act as ether a Bluetooth Master, or
Slave, as well as configure other features, such as the default baud rate. The other
variant is based on an HC-06 module. This kind can only act as a Bluetooth Slave
and requires a different method to configure it with AT commands. I tried a few of
the HC-06 variants, but found them frustrating to use, so I don't recommend using
them, especially as they're usually not any cheaper. However, it can be tricky to
identify what you're buying, as HC-06 modules are sometimes identified as HC-05
modules. So, here are a few things to look for when trying to purchases the HC-05
variant:
1. Look for the push button switch used to engage programing mode.
2. Look for a 6 pin header soldered on. The HC-06 variants often only solder on
a 4 pin header.
3. See if the listing indicates it uses an HC-05 (not completely reliable, but helps
identify with other factors considered.)
2 of 8 10/13/2019, 2:52 AM
Inexpensively Program Your Arduino via Bluetooth - Wayne's Tinkeri... https://sites.google.com/site/wayneholder/inexpensively-program-your...
4. Notice the pin patterns used to solder the castellations on the Bluetooth
module to the carrier PCB (indicated with blue arrows in the above photo) as
these vary and the pattern of unsoldered castellations vs soldered ones gives a
strong clue, as the HC-06 variant uses different pins. However, as many of the
modules sold seem to be covered with shrink wrap tubing, this can be difficult
to determine in an on-line listing.
5. Make sure the carrier PCB contains some circuitry. At a minimum, look for the
3.3 volt regulator, the LED and related circuitry. Some modules listed as using
an HC-05 seem to have the Bluetooth module soldered onto a carrier PCB
without these needed parts.
Also, be careful that you don't inadvertently purchase a blank carrier PCB, as some
vendors sell these and a quick look at the photo may show something that looks
similar to the back side of the module pictured above, but that does not have a
Bluetooth module soldered onto the other side.
NEW 11-26-2017: See the section at the bottom of this page on how you can also
order an adapter board to implement the programming connections shown above.
Next, I put the module into programming mode by holding down the pushbutton on
the HC-05 module as I powered up the assembly. In response, the LED on the
HC-05 module will begin to blink on and off very slowly. Then, I used the Arduino
IDE's Serial Monitor function to send commands to the module (select the FTDI as if
it were an Arduino board and set Serial Monitor 38400 baud) one at a time and set
to send "Both NL & CR". Here's the sequence I sent (blue) and the response I
received back (green):
3 of 8 10/13/2019, 2:52 AM
Inexpensively Program Your Arduino via Bluetooth - Wayne's Tinkeri... https://sites.google.com/site/wayneholder/inexpensively-program-your...
AT+UART=57600,0,0
OK
Note: you can verify the baud rate change by typing the following command and
check for the indicated response:
AT+UART
+UART:57600,0,0
OK
This reprograms the power on baud rate (does not change baud rate in programming
mode) to the rate typically used by the Arduino boot loader (note: this varies from
one Arduino to another, so verify the rate your Arduino uses first!) However, here's
a quick guide to help you match the needed baud rate to the particular Arduino
board you're using (Updated 11-29-2017):
I also decided to reprogram the pairing password from the default value of 1234 to
0000, which is the default used by Bluetooth on OS X. You can do this using this
command:
AT+PSWD=0000
OK
And, if you have multiple HC-05 modules and want to tell them apart, you can use
this command to rename the module. I chose to name my pair of modules HC-05A
and HC-05B, like this:
4 of 8 10/13/2019, 2:52 AM
Inexpensively Program Your Arduino via Bluetooth - Wayne's Tinkeri... https://sites.google.com/site/wayneholder/inexpensively-program-your...
AT+NAME=HC-05A
OK
Once the commands are complete, power cycle the HC-05 and you should find that
the changes you've made have persisted and that the module will now run at this
new baud rate and using the new password code and name (if set.)
The HC-05 module exports a signal called STATE that goes HIGH whenever the serial
link becomes active, but we need a low-going signal to trip the Arduino's RESET line.
This can be accomplished by means of a simple, transistor-based inverter circuit.
The design I came up with to do this also adds an RC differentiator circuit to the
input of the transistor, so the transistor's collector should be connected directly to
the Arduino's RESET pin.
5 of 8 10/13/2019, 2:52 AM
Inexpensively Program Your Arduino via Bluetooth - Wayne's Tinkeri... https://sites.google.com/site/wayneholder/inexpensively-program-your...
Note: none of the components in this circuit are especially critical. You can probably
use just about any NPN transistor you might have handy and you can vary the value
of the resistor, or capacitor by a fairly wide range and still have a suit that works. In
essence, the circuit works like a differentiator and converts the rising edge of the
STATE pulse into a LOW-going pulse that lasts for a duration set by the RC network
formed by the resistor and capacitor.
Finally, to put all this to practical use and connect the HC-05 module with this new
RESET circuit to the Arduino, simply connect everything together, like this:
The exact locations of the pins on the Arduino will vary depending on the type of
Arduino board used, but the essential connections are shown above. The 2K and 3K
resistors shift the 5 volt logic level of the TX signal from the Arduino down to the 3.3
volt logic level used by the HC-05. The circuit also includes a buffer between the
HC-05's Tx pin and the Arduino's Rx pin. This is needed when the Arduino you're
using has an on-board USB to Serial convertor. In this case, the Rx and Tx on the
Arduino's processor chip are connected to the USB Serial Adapter chip through 1K
resistors. Adding the buffer boosts the weak, 3.3 volt Tx signal from the HC-05
making it strong enough to over power the signal coming from the USB Serial
Adapter. You can use nearly any type of CMOS-based buffer for this. Good candidates
are the 74HC4050, or CD4050B. Or, for a compact solution, the SN74LVC1G17DBVR.
You'll then need to perform a pairing operation between the HC-05 and your
computer before you can select and use the bluetooth serial port in the Arduino IDE.
Once paired, you should be able to select the HC-05 from the Arduino IDE's "Port"
menu. Once selected, you should be able to click "Upload" to compile and upload
6 of 8 10/13/2019, 2:52 AM
Inexpensively Program Your Arduino via Bluetooth - Wayne's Tinkeri... https://sites.google.com/site/wayneholder/inexpensively-program-your...
new code as long as the HC-05 and it's connected Arduino remain powered up. One
caution, however. I recommend that you unpair the HC-05 when you're done using
it, as leaving the HC-05 paired with a computer when the HC-05 if powered off will
generally cause all programs thats can for USB serial ports, to start up very slowly,
as they have to time out while looking or paired ports that are not currently
available.
If you're familiar with working with surface mount parts, the PCB is easy to assemble and requires
on a pair of 6 pin, right angle headers to complete. Here's a photo of the assembled PCB
connected to a 5 Volt Arduino Pro Mini:
7 of 8 10/13/2019, 2:52 AM
Inexpensively Program Your Arduino via Bluetooth - Wayne's Tinkeri... https://sites.google.com/site/wayneholder/inexpensively-program-your...
you're using, as some of them the pins in one order and other have them in the reverse order.
The following show this using a Sparkfun Pro MIni as compared to a Chinese-mased clone Pro
Mini I purchased on eBay. I'm actually not sure which pin order is correct as, if you search for
"Arduino Pro Mini pinout" you'll see many different versions shown. I've labelled the pins on
the adapter board to make it easier to connect the correct pins. Just be aware that you may need
to flip the adapter board over to properly connect with some versions of the Pro Mini.
If you'd like to build this HC-05 adapter for the Pro Mini, the PCB can be ordered from OSH Park by
clicking here. A set of 3 PCBs will cost you $1.80. The other parts can be ordered from Mouser, or
Digi-Key, but be sure to get the SOT-23-5 version of the SN74LVC1G14DBVR Schmitt inverter.
The two resistors are 0603 (Imperial) / 1608 (Metric) surface mount resistors. I recommend using
thick film, 1% resistors, as they're cheap and available from many different manufactures and don't
stress about exact values. Anything close to 2K and 3K will work fine. And, of course, please read
the above text to understand how to purchase a compatible HC-05 module and program it to the
proper baud rate.
Sign in | Recent Site Activity | Report Abuse | Print Page | Powered By Google Sites
8 of 8 10/13/2019, 2:52 AM