If you’ve ever wished you could program your Arduino without lugging a USB cable around, wanted to put an Arduino project somewhere out-of-reach but still be able to easily upload changes to it, thought about building a project that interfaces with an Android phone, or contemplated a way to get remote sensor data streamed to your computer — this project is for you.
It uses a common, low-cost Bluetooth module mounted onto a prototyping shield for durable and reliable use. Along with the module is a circuit that allows the Arduino IDE to automatically reset the Arduino when uploading a new sketch. This project also uses the latest version of the Arduino IDE which eliminates the need to hack in modified DLL files to get the serial programming to work.
Besides uploading sketches, the shield can be used for serial communication using the standard Arduino Serial library between multiple Arduinos, smartphones, computers, or even a Bluetooth-enabled Raspberry Pi.
You will need a computer with built-in Bluetooth or a USB Bluetooth dongle to use the shield to upload sketches to your Arduino. These instructions are specific to Windows 7, but should be similar for Windows 8. Mac and Linux users can probably figure out how to get this working too. Smartphones need to support Serial Port Profile (SPP) to work (this excludes iPhones but includes many Android phones). This project is moderate to difficult, and requires soldering and previous prototyping experience.
Is it possible to program the Arduino Mega with the same procedure.
Yes
It uses a common, low-cost Bluetooth module mounted onto a prototyping shield for durable and reliable use. Along with the module is a circuit that allows the Arduino IDE to automatically reset the Arduino when uploading a new sketch. This project also uses the latest version of the Arduino IDE which eliminates the need to hack in modified DLL files to get the serial programming to work.
Nicely done! One question – I assume with this set-up every time we try to send data to the Arduino over Bluetooth the board will be reset, correct? In other words, the Bluetooth module can only be used to program the Arduino, but will not be usable to send data from or to the board?
You can use the module to send data to the module – it resets only when it gets connected. You just have to start the serial port at 115200 bps.
Do you need to change module settings to use it as a communications port, rather than as a programming interface?
No.
I loaded (over BT) a sketch that did a serial echo and once it loaded, I loaded the IDE serial monitor and it happily echoed back everything I typed over BT.
One major difference is that you will be using the ‘native’ hardware uart0 for serial, not software serial for BT traffic. So instead of defining the serial port with SoftwareSerial mySerial(rxPin, txPin); and mySerial.begin in void setup, you just need to Serial.Begin in void setup.
Great! Thank you so much for the prompt answer!
Dear Dushyant,
So every time you connect vía BT, it resets. To not have to be permanently connected to not cause a reset during the operation of any shetch and transmit data, coud we include in every sketch a kind of “reset deactivator pin”? I imagine putting an Arduino-pin to High, which is connected to transistors to prevent operation of the reset coming from BT, unless a command sent by BT put this “reset deactivator pin” to Low and allow to program another sketch. This command should be programmed in the sketch. Is it an idea or not?
Thank you!
I thought that would be the case, but it doesn’t.
This helped a lot .However, I didn’t need resistor 3 to get this to work. Actually, if i included R3 the circuit wouldn’t work. I am assuming that R3 will constantly output a HIGH to the arduino reset pin and will never rest.
Also, I didn’t need to solder a jumper wire to the HC-05. I just used the STATE pin on the HC-05, which happens to connect to Pin 32.
Hello, I would like to know if this is safe, can the arduino be damaged (unable to upload new sketches) in case there are interferences while uploading (missing or corrupted data) ? In the Arduino IDE there is option “Check code after upload”, I suppose this might help detect upload errors, but does it work with BT? Thanks ;)
How to configure HC-05 to program Arduino Leonardo via bluetooth ?
Thanks for the Project. I have two questions.
1. Do I need 2 ATMEGA328 chips? one in the BT programming shield & the other one is TARGET chip?
2. Why the KEY pin is shorted & disconnected? What is the need of connecting & disconnecting the KEY pin with 3v3 pin?
Any help shall be appreciated.
1. no
2. shorted=command mode, floating=transparent relay mode
Thanks a bunch for this page I connected the 3.3vpin and key pin together and removed the level shifting resistors and finally got at commands on HC-06!
Hi guys,
I’m not sure if this thread is still active but I’m hoping for some advice. I’ve got a HC-06 arduino shield (chinese made) and set the baud rate to 115200 (for Arduino Leonardo). However, I’m not sure how to create the ‘programming circuit’ since pin 32 does not seem to have any function on the HC-06. I would like to upload sketches to the arduino using the HC-06 module.
Any help is appreciated!
Many thanks
I had to use Baud rate of 57600 to program with Arduino 1.5.7 and Seeeduino.
With the Baud rate 115200 it didn’t work.
Correct – the default for the 328P-based Arduino’s is 57600, I believe.
the bluetooth module is always paired to the computer as a bluetooth device and is not assigned a port. How do i assign it to a port?
Spent 2 evenings trying to replicate – no luck.
Have perfectly operational and setup per instructions HC-05
Get connection (slow blink) when sending sketch to the board
But it is either “programmer not responding”, or “not in synch” errors
At some point was able to upload sketches 2 times in a row (miracle!), but had to unplug the ground resistor (15k) to get board running, as it would remain in reset mode, I believe.
Tried different values of divider bridge, and capacitor, to no avail.
Anybody else have it working reliably?
some time ago I was trying to look for out how to program the arduino wirelessly, I have found this https://play.google.com/store/apps/details?id=com.bluino.bluinohexuploader, maybe this can help.
Yes, it works, as described in the instructions, perfectly.
The trick is to follow the instructions to the letter – don’t try and take any short cuts.
I was getting nowhere until I started talking it over with someone else and he pointed out a few things I was missing… my enthusiasm overriding my ability to read, it seems :)
In essence, there are two distinct phases to making this work: The ‘programming the bluetooth module’ phase – where you wire it up and load the sketch that allows you to configure the BT module in command mode. Then there’s the ‘loading the sketch over bluetooth’ mode, where you rewire your circuit for programming over BT.
In my case, the ‘gotcha’ was not noticing that after the first phase, you had to move the TX and RX from the pins used to setup the bluetooth module to pins 0 & 1 of the hardware UART used to program the sketch wirelessly. You have to wire the BT module to pins 0 and 1 for it to work – the bootloader is expecting to sync using the hardware UART.
I also didn’t have all of the components needed, like the rating of resistors and 100 picofarad capacitor in the diagram, but I substituted 3.3kohm and 5.1kohm resistors and a 220 picofarad electrolytic and it still worked, so the circuit is forgiving.
I have loaded everything from ‘blink’ to the full 30k of Ardupilot over BT reliably.
Thanks for helping people out here!
Thank you! You did all the heavy lifting, I just had to RTFM :)
Same problem. The error mesage is “avrdude: stk500_getsync()….”
Thanks for this info.. I used a HC06 and soldered a wire to the STATE header (which did not have a pin) It doesn’t work on the HC-06 as there is only the STATE which pulses while disconnected in AT mode and then stays on when connected. Tried creating a simple circuit using a low pass filter to smooth the pulses and then a NPN transistor to pull the RST low, this works, but holds it low the whole time connected. Might have to get a HC-05 instead..
An update to say after trying unsuccessfully to flash a HC-06 with HC-05 firmware (which is possible). I bought a HC-05 connected up as per instructions and it works perfectly! THANKS
What did you use to try to reflash the HC-06?
have you seen this? https://github.com/lorf/csr-spi-ftdi
No, I haven’t but thanks – that looks like exactly what I need!
Thanks Joshua!
It does work on the HC06 – don’t use the ‘state’ pin, but follow the instructions and solder to the Pin34 of the HC module.
Tried that, but the pin doesn’t stay low when connected as the module doesn’t accept the POLAR command to invert the pin 34 state. It goes high which is the default.
What exact module do you have?
The ‘Hc-05’ and ‘HC-06’ designations are loosely attributed by every various Chinese assembler with access to a firmware tool. In reality, HC-05 and HC-06 are model numbers of Linvar Ltd. I’ve seen about three or four different firmwares with variations on the AT command set. I have 10 with the most awful limited firmware that I will be re-flashing as soon as I have the correct tool. The command set on that is limited to setting the UART and password.
If it was an actual 05 or 06, it would accept the POLAR command. Maybe it was based on another chip other than the CSR-BC417 chipset?
Hey, I have a problem ’cause AT on Arduino doesn’t working. None confirmations from Ardu.
Not enough information to answer that
I don’t know what is important.
What have you done so far? What kind of Arduino board are you using? What connections have you made? What are you using to connect to the Arduino? Do you get any sort of indication that you are connected correctly?
Simply: If you follow the instructions above to the letter, it works – so work through the instructions one step at a time and make a note of what works – when you reach a step that doesn’t work – come back and tell us what is wrong.
There are two distinct stages of getting this to work. The first step is to set up the Arduino to talk to the BT module so you can program it.
That includes loading a sketch that sets up the serial pins, wiring up those pins to the BT module, powering the pin on the BT module to set it in command mode, connecting your PC to the Arduino to connect to the BT module in command mode.
Once the BT module is programmed correctly, you have to wire it up to act as the programming interface, using serial pins 0 and 1 (1&2, depending on how you number them).
PS – I have a module where the ‘state’ pin is actually tied to PIO2 – pin25. You never know until you find a supplier that gives you a consistent product that you can trust.
FWIW, I just checked my ‘good’ HC
at+version
+VERSION:2.0-20100601
Why Pin34 instead of 32?
You can buy Bluetooth shields, Bluetoothduino, Bluetooth adatper here: http://www.elecfreaks.com/store/products_new.html
I followed every step, but cant upload sketches. It says that COM-port is in use.
Also when I check devices in configurationscreen. It says bluetooth disconnected.
Is it possible to program just the atmel328p chip with this procedure?
Yes if the 328 is loaded with the Arduino bootloader.
Good afternoon.
Can I request for the whole details of this project? The schematics and the sketch if thats ok with you?
Thanks. More power!
I don’t know what’s happened to the rest of the article… all the details should be here. Anyway, here’s the project on my site: http://www.joshuanewell.com/electronics/arduino-programming-via-bluetooth
GOT IT WORKING IN SECOND ATTEMPT!
Baudrate set using AT+UART is a critical piece (Step 4), which if done incorrectly will lead to avrdude: stk500_getsync(). The baudrate somehow depends on the Arduino/Processor.
Arduino Uno: AT+UART=115200,0,0
Pro Mini: AT+UART=57600,0,0
In case you hit, stk500_getsync() while sketch upload via bluetooth, Check out how the Arduino Software loads it using a USB/FTDI. Go to preferences and turn ON verbose mode for compile and upload. This will show you what baudrate is expected for a particular make.
And, after lots of experimenting I found out, the level-shif resistors’, capacitor values are really not rigid. Just ensure that the resistor to ground should be at least 1.5 times of the one to Vcc.
To elaborate a bit on this. If you want to see what baudrate the bootloader is expecting the programs to be loaded at, you can also check the make-file for the bootloader your arduino is running. For the Uno and other boards running the optiboot bootloader, it’s [Arduino install folder]/hardware/arduino/bootloaders/optiboot/Makefile
Look for the line ISPSPEED = -b [BAUD RATE]
Hey Joshua,
Awesome product. If you don’t mind taking a look, our team made an infographic for finding the right bluetooth module for you. Take a look if you’re looking to see the different types out there!
http://blog.upverter.com/post/102541328427/bluetooth-module
hi im trying to get this to work and the hc06 and my arduino works togheter fine as long as i press reset on arduino nano right after i hit opload!!!
but i have triet to to make your auto reset but it dont work i have triet both 34 and 32 but nothing can you tell me how i can find the right one?
you need an hc05 to get autoreset to work
I did update arduino nano booloader for software reset flashing. Now I am able to flash with any serial bridge like hc06 and hc05 (without rest line hack). Currently tested only for nano/atmega328, but should be easy to adopt for other chips.
https://github.com/asalminen/arduinobootloader
I had everything set up correctly and then when uploading the sketch, I got the error
avrdude: ser_setspeed(): tcsetattr() failed
avrdude: ser_open(): can’t set attributes for device “/dev/cu.H-C-2010-06-01-DevB-1”: Invalid argument
ioctl(“TIOCMGET”): Bad file descriptor
avrdude: ser_close(): can’t reset attributes for device: Bad file descriptor
anyone seen this or know how to fix it? I’ve been using a 9V battery for power and I’m trying to control a motor using an hbridge.
Is your COM port # higher than 9? I’ve seen reports that this error occurs if your COM port is set too high:
http://blog.gmane.org/gmane.comp.hardware.avr.avrdude.devel/month=20080201
It happens with COM port 1 and 2.
From the research I’ve done, it looks to be a baudrate issue. Are you on a Mac, PC, or Linux? What is your baudrate set at currently?
Mac, and the problem arises in two different arduinos at their baudrates. When using the uno, I have the baud rate set to 115300, and on the nano it is set to 57600.
I believe the Uno uses 115200, not 115300. Perhaps try switching it down to that?
This forum used a Windows emulator to solve the error:
http://www.eventorbot.com/forum/viewtopic.php?f=12&t=585
This forum talks about changing the avrdude file to allow for non-standard baudrates to solve the error:
https://groups.google.com/forum/#!topic/asrob-uc3m-impresoras-3d/bc53ni1SruA
I have facing the same problem as above , I am using Linux Machine could you help please
I am having trouble with the serial command step. When I open the serial monitor, it sends the “AT” command, but I do not receive an “OK” response. Instead I receive “ÿÿ” at varying intervals. I am able to enter the rest of the commands, but all receive the same response.
I tried moving forward, but when I got to the last step, I was unable to send a sketch over BT. I have a feeling that the serial commands aren’t working, but I’m not clear what the issue or solution is.
Hardware:
HC-05 module
Uno board
TX is run to Pin 8 (reading 5V signal)
RX is run to Pin 9 (reading 5V signal)
5V is run to 5V (reading 5V signal)
GND is run to GND
EN is jumpered to STATE (reading 3.5V signal)
Addendum: Do you have to type the OK commands, or are those supposed to be responses from the Arduino?
Those are responses. This might help
http://www.martyncurrey.com/arduino-with-hc-05-bluetooth-module-at-mode/
And that explains it. My EN pin is not a Key pin. Holding the button while powering the HC-05 worked like a charm, thanks!
Got the HC-05 programmed! Also stumbled upon the full AT command list here, which shows the command AT+PSWD to change the passcode for your connection:
http://www.techbitar.com/uploads/2/0/3/1/20316977/hc-05_at_commands.pdf
I am successfully uploading a program to my Uno now; however, my Arduino software occasionally gives me an error such as:
avrdude: stk500_recv(): programmer is not responding
Even when it gives me that error, the program uploads successfully on my Uno. I’m running Arduino 1.6.5. Not sure if this is a bug in the software, or if something weird is happening with my Bluetooth connection.
Try changing your baudrate. It will work.
Hi, tried the steps of this interessting post. Until the soldering it all worked fine. But after the soldering I tried to upload the Blinking scatch for a test. I used the newest Arduino IDE (1.6.4?) and the Uno R3, I selected the lower of the serial ports of the HC-05.
The test resulted in the red LED on the HC-05 blinked all the time and the code was not able to be uploaded (nothing happed and the uploading procedure could not stop).
Afterwards I doublechecked the soldering but could not find the Issue. Could you help me out what the most probable mistakes are?
Thank you for this guide. For my HC-05 module (CZ-HC-05 gomcu) I had to use 4.7uF cap. I also did not use additional resistors, I just left with pull up resistors already present on Arduino Nano.
Thank you. Upload works smoothly every time using Arduino 1.6.4 on OSX Yosemite. But on Windows 7 machine its really hard to get it to work, sometime it works after I restart Arduino, delete bluetooth device and pair again, but most of the time I get either “Access is denied” or Element not found. What I really want is to upload wirelessly using Visual Studio with Visual Micro Arduino plug-in but no luck yet, tried with virtual Windows 7 using Parallels and Win 7 using bootcamp, could also be Win 7 bluetooth communication issue, I’ll try XP/Win8, any helpful information?