Program an Arduino Wireless Over Bluetooth

43,740

175

15

An Arduino Uno is a really cool piece of hardware to get started with electronics, but one downside to the Arduino is it needs to be plugged into computer using a serial to USB cable each time you want to upload the code. In some projects it would be really handy to program the Arduino wireless, so in this instructable I'm going to show you how to program an Arudino wireless over Bluetooth, so you don't have to carry an extra USB cable again or unplug the Arduino from the project just to upload the new code.

You can also view the video below on how to build this project.


Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Tools and Components

Here is a list of the components and tools required, the list is simple and all you need is -

  • Arudino Uno
  • HC05 Blueooth Module
  • PCB
  • Breadboard
  • 2.2K Resistor
  • 1K Resistor
  • 0.1uF Capacitor (code 104)
  • Header Pins
  • Wires
  • Soldering Iron
  • Soldering wire

Step 2: HC05

This project uses the HC05 Bluetooth module for communication, this is cheap and easy to find on eBay. Make sure you have the HC05 module and not the HC06, they look the same, but the difference is that the HC05 works as both a master and client but the HC06 works only as a client. This project may not work with the HC06.

If you bought a module with the breakout board make sure it has a key terminal, if it has a Wakeup terminal you will have to solder a wire to the pin 34 which will act as a KEY pin. Then solder the pin 32 of the HC05 we will use this to reset the board each time we upload the code.

Step 3: AT Commands

Before establishing connection between the Bluetooth module and the PC, we need to upload the code, to the Arduino that puts the HC05 in at command mode. The code can be found bellow

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX

void setup()
{
pinMode(9, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
digitalWrite(9, HIGH);
Serial.begin(9600); Serial.println("Enter AT commands:"); BTSerial.begin(38400); // HC-05 default speed in AT command more }

void loop() {

// Keep reading from HC-05 and send to Arduino Serial Monitor if (BTSerial.available()) Serial.write(BTSerial.read());

// Keep reading from Arduino Serial Monitor and send to HC-05 if (Serial.available()) BTSerial.write(Serial.read()); }

Step 4: Circuit

Next we need to connect the arduino at the HC05 to put it into AT Command mode this can be done by setting up the connection as follows

HC05 GND to Arduino GND Pin

HC05 5V to Arduino 5V

HC05 TX to Arduino Digital Pin 10 (soft RX)

HC05 RX to Arduino Digital Pin11 (soft TX)

HC05 Key (PIN 34) to Arduino Digital Pin 9

After setting up the following connection on the breadboard, before connecting the Arduino to the computer, remove the power to HC05 by disconnecting the VCC pin. After you connect the Arduino to a computer you can go ahead and plug the VCC pin back. This would have put your HC05 in AT command mode.

Now open up a serial terminal and enter the following commands, the board will respond with an "OK" each time a command runs successfully

AT+ORGL
AT+ROLE=0
AT+POLAR=1,0 AT+UART=115200,0,0 AT+INIT

.

Step 5: Measuring

Now lets start with building the programming shield, you could add header pins to all the terminals of the Arduino and make a shield for your project but I choose to add header pins required for this project. Plot the pins onto the PCB and solder them.

Next we need to cut out the excess PCB, I used a rotary tool to do this, you could also use a PCB cutter. After cutting the board place the PCB on the Arduino and make sure that everything fits right.

Step 6: Circuit

You can refer to the picture for the circuit, the circuit is quite simple. Now we use the pins 32, VCC, GND, TX, RX of the HC05, we no longer require the KEY pin. The pin 32 of the HC05 is used as a reset pin for the Arduino, because the board resets automatically each time the code is uploaded to the board. There is also a voltage divider part of the circuit as the pin 32 of the HC05 supports 3.3V logic so you should maintain a voltage level of 3.3V.

Step 7: Testing

After soldering the components make sure you soldered all the terminals right using a multi-meter. After all the connections are done, you can now plug the programming shield on the Arduino, and connect the Bluetooth module to your computer, the default password is "1234".

Now open up the Arduino IDE and select the blink program (we will use this as the test sketch), select the right com port. You can find the serial port of your module in the device manager if you are using windows. Next hit upload and you should see the HC05 connect to the computer and upload the code to the Arduino.

If everything went well you should have the Arduino on board LED, blink at an interval of 1 sec.

Makerspace Contest

Participated in the
Makerspace Contest

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    15 Discussions

    0
    None
    richarddl42

    5 weeks ago

    When the program is running in the Arduino, does Serial.println work via bluetooth to the serial monitor in the IDE on the PC? And serial input?

    1 reply
    0
    None
    katlantaricharddl42

    Reply 20 days ago

    yes,. when using this method, you can do instead usb device, but the data transfer more slowly.

    0
    None
    Nihal12345

    Question 4 months ago on Step 4

    I AM GETTING ERROR 17 IN SERIAL MONITOR WHILE GIVING AT+INIT.CAN YOU HELP

    0
    None
    BhupendraBJ

    Question 9 months ago on Step 6

    Where I can get the other related programs for bluetooth module

    0
    None
    SteinarK2

    10 months ago

    Hi, I got a pair of 3D shutterglasses that can be controlled by bluetooth.
    I downloaded a document for the bluetooth standard, but is there any way I can use the HC-05 or HC-06 to controll the shutter function on these glasses. Any idea?

    0
    None
    syahmigenius

    10 months ago

    im doing this wireless upload program.. its success but i need to press reset button after click upload in arduino ide and then it will upload... How can i able to upload without pressing the reset button?

    0
    None
    needsnumbers

    1 year ago

    Something isn't right about your Reset line with the capacitor and voltage divider. When the pin 32 goes high or low, the cap will decouple into AC leaving a straight voltage divider after like a fraction of a us. You have 2.5v going to the Reset line of the "Arduino" board according to the circuit. I'm surprised it works but then again I haven't looked at the board reset circuitry. Maybe there is a one-shot? I doubt it. Either way, good job using low cost parts.

    0
    None
    Anjan Halder

    2 years ago

    is 2.2k and capacitor shorted?

    0
    None
    petefreid

    2 years ago

    What is the function of pin 32? The datasheet lists it as an I/O pin

    0
    None
    syaruls

    3 years ago

    when this BT disconnects with the smartphone, can the smartphone ring an alarm??

    0
    None
    Kira_gelo

    3 years ago

    is this possible for BLE?

    0
    None
    anorehian

    3 years ago

    So what are the differences between the 05 and the 06?

    0
    None
    tomatoskins

    3 years ago

    I never knew that this was possible! Great project! Thanks for sharing!

    1 reply
    0
    None
    pseaton

    3 years ago

    Two terrific Arduino projects in two days! Really appreciate the great read, and clear instructions. Thanks for sharing!