For a project I am working on I wanted to be able to load Arduino sketches using Bluetooth. A number of people have attempted to do this and many have been successful and some have not. Here is how I did it.
My goal was to be able to load sketches from the Arduino IDE using a Bluetooth Mare Silver connected to an Arduino using a standard FTDI cable pin out with reset supported.
Here is the finished product:
Using Google I came up with a good bit of reference material. Below are the links that I found especially useful:
Ersin Ried’s post in the Arduino Forums Road to solve the delay on the Arduino IDE
Roving Networks’ Data Sheet for the RN-42
The Electronics Club’s A transistor inverter (NOT gate) (at the bottom of the page) circuit
Step 1 – Modifications to the Bluetooth Mate Silver
Reading the data sheet for the RN-42 we find that DTR is on pin 33. Pin 33 is located on the side opposite from the onboard antenna. Hold your board so that the onboard antenna on the RN-42 is to the left. In this orientation pin 33 will be on the right side of the RN-42 and four pins up from the bottom. It is the one that the left side of the white wire is connected to in the picture below.
Once we have located the DTR pin the next step is to connect it to the RTS position as defined by the FTDI pin out which will result in it being connected to the green wire. In my case I disconnected the header pin from RTS on the board and then ran a wire across from DTR to that position on the header.
In the upper right corner of the picture below you can see the open hole where the header is normally connected to RTS and the white wire connected to that header position.
Step 2 – Supporting connections using the FTDI pin out
You now have DTR on the bluetooth device connected to the pin to support resetting the Arduino. Unfortunately, with the RN-42 the DTR pin is active high and to reset the Arduino it needs to be active low. However, this can be taken care of with a simple transistor inverter circuit using an NPN transistor and two resistors. I used a NPN2222 transistor, male header pins and a female header socket.
The key to assembling the circuit is to bend pins in position 6 up so that they do not touch when you solder the other 5 pins together. Once this is done
- Solder the emitter on the transistor to ground (pin / position 1 on the connectors).
- Solder the collector through a 1K resistor to VCC (pin / position 3 on the connectors).
- Solder the base through a 10K resistor to where you terminated DTR from the RN-42. If you followed my example above this will be where RTS normally is. This would be pin / position 6 on the connector to the bluetooth board.
- Solder the final connection from the collector before the resistor and connect it to the pin / position 6 on the side going to your Arduino.
Step 3 – Change to the Arduino IDE so it will play well with Bluetooth on Windows
You now have a hardware compatible replacement for the FTDI cable you normally use to download sketches to the Arduino. The final thing that you need to do is to make a change to the Arduino IDE to change the way it scans for COM ports.
Ersin Ried’s has done a great deal of work in figuring out the cause of the problem and how to get around it. His work is documented in the following post iin the Arduino Forums: Road to solve the delay on the Arduino IDE. Basically what needs to be done is you need to replace the existing rxtxSerial.dll module with a modified one. The modified version can be downloaded from his website at: http://servicios.ried.cl/arduino/temp/rxtxSerial-2.2_fixed_2009-03-17.rar.
The copy of rxtxSerial.dll in the archive needs to replace the copy that is located in the directory where the Arduino IDE is installed. I would suggest renaming the copy that is there before you replace it so you can easily go back to it.
If you start the Arduino IDE on Windows with bluetooth it will be very slow to come up and anytime you try and access the tools menu. Once you have the updated copy installed this should go away.
Step 4 – Configuring the Bluetooth Mate Silver so that the your PC can connect to it and download sketches.
There are two things that need to be configured on the Bluetooth Mate Silver. The first thing is to set the speed to 57600 baud and the second is to change the profile so that modem signals are supported. This enables the PC running the IDE to toggle DTR to reset the Arduino so the bootloader will accept the sketch. The speed is set to 57600 as the when the IDE runs avrdude it sets the speed for avrdude at 57600.
To do this you will need to connect to the Bluetooth Mate Silver with a terminal emulator program, enter command mode via the three dollar sign command within 60 seconds of power on, enter two commands to update the configuration parameters and then exit command mode.
- Set the RN-42 to DUN-DCE mode enter: S~,1
- To set speed rate of the RN-42 to 57600 enter: SU,57.6
Below is how this looks using ReadTerm:
On thing to note is that the speed for the Bluetooth Mate Silver is set to 115200 out of the box. So if you have not changed it you will need to have your terminal emulator set to 115200 to enter the configuration commands.
Now you should be ready to download sketches from the Arduino IDE to your Arduino using bluetooth.
If you use the Arduino serial commands you will need to make sure to set the speed when you call Serial.begin to 57600 so that it is set the same as the Bluetooth Mate Silver.
This work was built upon the work of others. I post it here not as an example of original work but as an example for reference. If I didn't appropriately credit you for your work please let me know and I will add you.