Program an Arduino Wireless Over Bluetooth

69,442

191

23

Introduction: Program an Arduino Wireless Over Bluetooth

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.


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

1 Person Made This Project!

Recommendations

  • Backyard Contest

    Backyard Contest
  • First Time Author Contest

    First Time Author Contest
  • Pets Challenge

    Pets Challenge

23 Comments

0
mkpeker
mkpeker

3 months ago

Good work, thanx for sharing.
But its unnecessary to modify or soldering this module. You may use ordinary STATE pin on module. Just invert STATE out by a transistor and connect out by a 100nf to UNO reset pin. Thats it!

Note: even some modules any circuitry is not necessary (but not all).Only use an 100nF capacitor - pole to STATE, +pole to UNO Reset pin ;)

HC-05-Arduino-RESET-Circuit.png
0
Mufaddal007
Mufaddal007

Tip 10 months ago on Step 7

Great tutorial, BTW I have also used HC-05 but the thing is I got error in 2 of the AT configuration commands, AT+POLAR and AT+INIT, previously I was also unable to set baud rate but initializing hardware serial at 19200 done the job then I was able to view the replies in AT command mode. I would like you to update the AT config code.

0
srhafiq
srhafiq

1 year ago

"why I am getting error message in serial monitor when i'm putting "AT+POLAR=1,0"?

0
diy_bloke
diy_bloke

2 years ago

I am not sure if I understand it correctly, but what I gather from this is that before I upload a code via bluetooth, I first have to upload another program to make it possible?
Doesn't that beat the purpose big way?

0
KkbK1
KkbK1

Reply 2 years ago

In case you want to update the program after it has been put in the device, this is helpful as it can done remotely

0
diy_bloke
diy_bloke

Reply 2 years ago

Thank you

0
JustinM994
JustinM994

Question 2 years ago on Step 7

Hi, I am trying to establish a Bluetooth wireless connection between an Arduino Nano and the HC-05 but without succeeding. Apart from the baud-rate, are there any parameters or circuit changes to be applied?
Thanks

0
Nihal12345
Nihal12345

Question 3 years ago on Step 4

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

0
AllawH
AllawH

Answer 2 years ago

after some googling it turns out error 17 means AT+INIT is already excuted

0
richarddl42
richarddl42

2 years 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?

0
katlanta
katlanta

Reply 2 years ago

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

0
BhupendraBJ
BhupendraBJ

Question 3 years ago on Step 6

Where I can get the other related programs for bluetooth module

0
SteinarK2
SteinarK2

3 years 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
syahmigenius
syahmigenius

3 years 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
needsnumbers
needsnumbers

4 years 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
Anjan Halder
Anjan Halder

4 years ago

is 2.2k and capacitor shorted?

0
petefreid
petefreid

5 years ago

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

0
syaruls
syaruls

5 years ago

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

0
Kira_gelo
Kira_gelo

6 years ago

is this possible for BLE?

0
anorehian
anorehian

6 years ago

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