Arduino / XBee

I’ve been interested in wireless control for a while now. When I was first getting into it, it seemed like a difficult feat that not too many people had solved. This was especially apparent when it came to using XBee’s. The XBee modules are great for longer-range communication than something like Bluetooth, and the types of networks that you can set up with them are vastly greater. However, even just getting the things to work was, at first, a giant pain in the ass. This is different now than it was, say, six years ago when XCTU was only available for PC and tutorials on the subject of interfacing them were almost non-existent. With cross-platform versions of XCTU now available, and tutorials on sites like Sparkfun, it’s a lot easier. 

Anyway, I recently designed a board for a wearable controller that I wanted to use with an Arduino Micro. I thought this should be an easy task, as I had built Atmega/XBee boards in the past. Low and behold, I came across issues very similar to the ones I had struggled with when I was new to the XBee. After much hair pulling-out, I realized that my issue was a result of the way that the Arduino Micro handles serial communication. In short, the Micro expects serial communication to happen over the USB port and relegates its serial commands to that purpose. However, with the SoftwareSerial library, you can make much wider use of the serial function and obtain much greater control over how that communication takes place via hardware. The following is a basic walkthrough of that simple setup.

///// The Arduino Code to read from potentiometer, blink LED in response to that pot, then transmit via the XBee

#include <SoftwareSerial.h> // Use the Software Serial library

SoftwareSerial mySerial(1,0);   // RX/TX
void setup() {

mySerial.begin(57600);  // Use the same baud rate that you used for the XBee’s


void loop()
int val = analogRead(A0);  //Read from analog pin 0
digitalWrite(13, HIGH);     //This part of the code just uses the pot value to blink an LED
digitalWrite(13, LOW);

mySerial.println(val);  //Here you want to use “print” instead of “write.” 

// End Code —- It’s that simple.  You can use any of the digital pins you want. You might in fact notice that I have the usual TX/RX pins switched in the case above (This is because I made a wiring mistake when I had the circuit boards printed. Derp).


The XBee setup is also very simple. With XCTU, just leave most of the settings as is, and make sure that both radios are on the same channel and have the same PAN ID. Then give radio 1 DL 1 and MY 2. Give radio 2 DL 2 and MY 1. Lastly, make sure that the baud rate is set to the same setting you have in your Arduino code – 57600 in this case. Radio 1 should look like this:



Here are the board and layout for the Arduino Micro / XBee’s:

Screen Shot 2016-05-01 at 10.58.24 PM