Introduction: Wireless Programming of Arduino
I have been building robots for a few years now and one of the things that I have found most frustrating is during testing and debugging. There always seems to be a need for a USB cable which can get in the way and limit the distance that your robot or other project can go or you will have to chase it down just to change one little line of code. I have been using cheap HC-06 bluetooth modules for control and debug but I have not been able to use them to actually program an Arduino. I have heard of using Xbee modules for wireless programming and have found a couple good tutorials for it on SparkFun and Adafruit, but both of these seem a little dated so I am going to attempt to make things a little simpler and more up to date.
Step 1: Materials Needed
Step 2: Setting Up the Receiving Xbee
After the device has successfully installed, open the X-CTU software.
- Choose the COM port from the list that corresponds to your Xbee Explorer Regulated.
- If this is a new Xbee, select the baud rate option for 9600, otherwise choose the appropriate.
- All other parameters should be the same as default.
- Click the 'Test / Query' button to check that you have a good communication with the device.
- If you get an error message, check your COM port and make sure that your Xbee module is plugged in properly.
- Click on the 'Modem Configuration' tab in the X-CTU software.
- Click the 'Read' button to load in all of the current parameters for your Xbee module.
- Before changing anything, we need to find out what the upload speed is for our specific board. You can find that information here on my Blog Spot. Once you have this information, we can reconfigure our Xbee module.
- In the X-CTU software, we will want to create a personalized PAN ID. This is any 4 digit HEX number that will be used to link your two Xbees. Remember the number that you use here as you will need it again for the transmitter.
- Set the 'Interface Data Rate' to the baud rate that we determined in step 8.
- Set the 'Packetization Timeout' parameter to 10.
- Turn DIO3 into an input by setting 'DIO3 Configuration' to 5 - DO HIGH.
- Change 'I/O Output Enable to 0 - DISABLED.
- Set 'I/O Input Address' to FFFF.
- Click the 'Write' button and the new settings will be loaded onto your Xbee Module. To check that the settings were loaded you can go back and change the baud rate on the main screen of the X-CTU software then do another read for your module.
Note: Each Xbee can be either a transmitter or a receiver, there are NOT different modules for each.
Step 3: Setting Up the Transmitting Xbee
- The 'PAN ID', 'Interface Data Rate', and 'Packetization Timeout' settings are all going to be the exact same as we did for the receiver.
- Set 'DIO3 Configuration' to 3 - DI.
- Set 'DIO Change Detect' to 8.
- Once this is done we can go ahead and click 'Write' to update the module.
- We will need a jumper between pin D3 and RTS. What I have done instead of soldering a jumper is I have put right angle headers on my Dongle and just used a pin head jumper but any method of connecting the two pins will work.
- Once your module is plugged back into your computer, we will need to change some settings in the Device Manager so go ahead and open your computers Device Manager. This step is only for Windows users.
- Find your device under the Ports (COM & LPT) section, right-click and select properties.
- Go to the Port Settings tab and click the 'Advanced...' button.
- In here all that you need to do is make sure that the check box for 'Set RTS On Close' is checked.
- Save the changes and you're done.
Step 4: Programming Your Wireless Arduino
Programming on the Pro series of Arduino is very simple. If you are using the Sparkfun Xbee Explorer Regulated then you will not need to do anything to this module except to put some headers on the programming end of the board. Pin D3 is already tied to DTR so we don't need any jumpers here. Just plug in your Xbee Explorer Regulated with the receiver Xbee into your Arduino Pro. I use cheap Arduino knock offs from eBay so I have to plug mine is upside down, just check the silkscreen to make sure that you are plugging it in correctly. All you should need to do now is plug in power to your Arduino and check that the Xbee module is getting power.
In the Arduino IDE everything is the same as programming normally, just make sure that the COM port that you are using is the one that corresponds to the Xbee Explorer Dongle.
Enjoy your new wireless programmer!!
Step 5: Using Non-pro Series Arduino
If you are not using an Arduino Pro or Pro Mini then you will need a little bit of extra hardware. An NPN transistor, a 10k resistor and a 0.1uF capacitor. Connect this in the way shown on the Adafruit website. Check the picture for a simple schematic.
We have a be nice policy.
Please be positive and constructive.