Subscribe to Make Magazine Today!

arduioo-week

bluetoothprogrammingshield_scaled

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.

Joshua Newell

Joshua Newell

Joshua Newell is a software developer by day, and an electronics and embedded systems enthusiast by night.


  • Sidhant

    Is it possible to program the Arduino Mega with the same procedure.

    • Zootalaws

      Yes

  • http://42bots.com Stan

    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?

    • http://dushyant.ahuja.ws Dushyant Ahuja

      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.

      • Michele

        Do you need to change module settings to use it as a communications port, rather than as a programming interface?

        • Zootalaws

          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.

          • Michele

            Great! Thank you so much for the prompt answer!

    • Zootalaws

      I thought that would be the case, but it doesn’t.

  • Joseph

    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.

  • Joseph

    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.

  • gugus

    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 ;)

  • Fernando Mattoso Lemos

    How to configure HC-05 to program Arduino Leonardo via bluetooth ?

  • Biplab Roy

    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.

    • Joshua Newell

      1. no
      2. shorted=command mode, floating=transparent relay mode

  • Brian Impellizzeri

    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!

  • Markus Eglin

    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.

    • Zootalaws

      Correct – the default for the 328P-based Arduino’s is 57600, I believe.

  • Jian Li

    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?

  • Aidas Zarskus

    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?

    • ammy

      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.

    • Zootalaws

      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.

      • Joshua Newell

        Thanks for helping people out here!

        • Zootalaws

          Thank you! You did all the heavy lifting, I just had to RTFM :)

    • Claudio Aguila

      Same problem. The error mesage is “avrdude: stk500_getsync()….”

  • techietav

    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..

    • techietav

      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

      • Zootalaws

        What did you use to try to reflash the HC-06?

    • Zootalaws

      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.

      • techietav

        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.

        • Zootalaws

          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?

        • Zootalaws

          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.

        • Zootalaws

          FWIW, I just checked my ‘good’ HC

          at+version

          +VERSION:2.0-20100601

  • keven

    You can buy Bluetooth shields, Bluetoothduino, Bluetooth adatper here: http://www.elecfreaks.com/store/products_new.html

  • Guest

    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.

  • Marijn

    Is it possible to program just the atmel328p chip with this procedure?

  • jb

    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!

Related Supplies at Maker Shed