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