Wireless Arduino Programming

Remotely program an Arduino using a XBee wireless connection.

For an upcoming project (some Christmas lights) I need to place an Arduino in an out of the way place (attached to the soffit/fascia of my house) and be able to continue to modify the code running on it from the comfort of my desk. Time for a wireless programming link!

I've tried several approaches to this and found the simplest solution yet. If you have an Arduino Duemilanove (not an UNO!) and a XBee with shield you can use the XBee to reprogram the Arduino with only one small hardware modification.

Required Parts

1 Arduino Duemilanove
1 XBee shield (XBee Shield)
2 XBees (XBee 1mW Chip Antenna - Series 1)
1 USB to XBee serial board (USB XBee Adapter)

Required Software

Arduino IDE
X-CTU (simplest method, Windows only),
OR a terminal client (difficult method, all other platforms)

Please read Limor Fried's XBee Adaptor - Connecting, Configuring & Upgrading if you aren't familiar with using either X-CTU or a terminal client to configure XBee adaptors.

Configure the Receiver

  • Put one of the XBees in the USB to serial board and hook it up a computer.
  • Using X-CTU or a terminal client make the following changes to the XBee's settings:
    X-CTU Description X-CTU Setting Terminal Command
    Reset to defaults - ATRE
    Interface Data Rate 6 - 57600 ATBD 6
    PAN ID 1324 ATID 1234
    16-bit Source Address 0 ATMY 0
    Destination Address Low FFFF ATDL FFFF
    DIO3 Configuration 3 - DI ATD3 3
    DIO Change Detect 8 ATIC 8
    XBee Retries 3 ATRR 3
    Packetization Timeout 10 ATRO 10
    Write Changes - ATWR
    Exit Command Mode - ATCN
  • Now remove the XBee from the USB to serial board and place it on the XBee shield and connect the shield to the Arduino.

Configure the Transmitter

  • Solder a jumper between DIO3 and RTS on the USB to serial board.
  • Connect the other XBee to the USB to serial board and connect it to a computer.
  • Using X-CTU or a terminal client make the following changes to the XBee's settings:
    X-CTU Description X-CTU Setting Terminal Command
    Reset to defaults - ATRE
    Interface Data Rate 6 - 57600 ATBD 6
    PAN ID 1324 ATID 1234
    16-bit Source Address 1 ATMY 1
    Destination Address Low 0 ATDL 0
    DIO3 Configuration 5 - DO HIGH ATD3 5
    I/O Output Enable 0 ATIU 0
    I/O Input Address FFFF ATIA FFFF
    Packetization Timeout 10 ATRO 10
    Write Changes - ATWR
    Exit Command Mode - ATCN

Upload Some Code

  • Connect the USB to serial board to the computer and the Arduino to an external power source.
  • Run the Arduino IDE and open a sketch to upload.
  • Select the correct model of Arduino and serial port from the 'Tools' menu.
  • Click the upload icon to start the transfer.
  • If the first attempt fails, click the upload icon while holding the shift key to start a transfer in debug mode, which sometimes can work when a normal upload doesn't.

What's Happening With DIO3?

In order to reset the Arduino, DIO3 needs to be tied to RST with a capacitor. I found out through trial and error that the Sparkfun XBee shield already has this set up. So if your using the Sparkfun shield no additional wiring is necessary, but with other shields you'll need to add the capacitor.

What About the UNO?

I've tried this approach with the UNO and the Duemilanove and found that only the Duemilanove works. My best guess is that this either has to do with the UNO's higher programming speed 115200 vs 57600 or the UNO's new USB-to-serial chip which might somehow interfere.

I've already tried setting up the XBees with the higher baud rate so I'm thinking that there is something else compounding the problem, like the aforementioned USB-to-serial chip. If you have any insight on how to get this working with the UNO please let me know.

Resources

Project Categories: 
An image of a microprocessor
A image of a file of code written in C
Wireless icon

Comments

Franco Cozzo's picture

I have spent hours trying to get this working on a Seedstudio Stalker and it was only this page that finally worked. I used the AT commands since I run GNU/Linux. One thing though -- I think you have the transmitter and receiver the wrong way around.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.