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.

Project Steps

Install the latest, beta version of Arduino.

The current beta version of the Arduino IDE has fixed some of the issues that made Bluetooth programming difficult in the past. The most current version available today is Arduino 1.5.6-r2.

You can download the installer from: http://arduino.cc/en/Main/Software

Breadboard the Bluetooth module setup circuit.

The Bluetooth module used in this project is the HC-05. It is inexpensive and one of the most common modules you’ll see in a lot of other projects. The HC-05 is sold bare or mounted to a breakout board. You want one on a 6-pin breakout board. You can find them for sale on eBay and Amazon.

The datasheet for the module is here.

Using a breadboard, temporarily wire the HC-05 Bluetooth module per the schematic.

With 3.3v on the Key pin, the module will enter 38400 baud command mode and will accept AT commands. The Key pin must be connected to 3.3v when the module is powered on. If it is connected afterwards, the module will enter command mode at the default baud rate (as set by the ‘AT+UART=’ command or 9600 baud from the factory).

Upload the setup sketch

Get the sketch from here and upload it to your Arduino.

Run the setup sketch and enter serial commands.

Open the serial console and make sure the baud rate is set to 9600 and line endings is set to be “Both NL & CR”

Enter the following AT commands into the serial console.


AT+ORGL	 

AT+ROLE=0

AT+POLAR=1,0	

AT+UART=115200,0,0	

AT+INIT	 

In order, these commands tell the module to reset to factory settings, switch to slave role (transparent serial bridge), set pin 32 low on Bluetooth connection, change baud rate to match the Arduino Uno programming rate, and to initialize.

Disconnect 3.3v from the Key pin and cycle the power to the module. It will now be running at 115200 baud and be in pairing mode.

Setup the Bluetooth module in Windows.

From the Control Panel select Add a Device.

Add the Bluetooth module.

Select enter pairing code option.

Setup the Bluetooth module in Windows (cont'd).

Enter “1234” for the pairing code.

At the Add a device success window, click Close.

Device ready to use. The OS will create two serial COM ports associated with the device. Always use the one with the lower number.

Solder a jumper onto the Bluetooth module.

Disassemble the breadboarded circuit. Solder a jumper wire directly to the HC-05’s Pin 32.

Don’t forget to use flux.

You may want to use hot glue or tape to protect the joint.

Build the programmer circuit.

Build the programmer circuit onto the prototyping shield.

Solder on a female header for the Bluetooth module if you want to be able to easily remove it later.

Program the Arduino With Bluetooth!

Power on the Arduino from a battery or AC adapter.

In the Arduino IDE, choose the serial port of the Bluetooth module (the lower valued one of the two) and then upload a sketch like normal.