- XBee wireless kit: http://www.amazon.com/CanaKit-Xbee-Wireless-Kit/dp/B004G1EBOU/ref=sr_1_9?ie=UTF8&qid=1331990327&sr=8-9
- Arduino UNO 3: http://www.sparkfun.com/products/11021
The first step is to put the kit together. Here are some pictures before and after assembly:
Next I started looking around for some tutorials on how to connect and send / receive data. There were several sites that were useful:
- http://www.faludi.com/itp_coursework/meshnetworking/XBee/XBee_program_Arduino_wireless.html
- http://ftp1.digi.com/support/documentation/90000982_A.pdf
- http://bildr.org/2011/04/arduino-xbee-wireless/
The first step was to install the FTDI drivers. I downloaded them from this site http://www.ftdichip.com/Drivers/VCP.htm. I installed them allowing the host computer to talk to the connected explorer USB board. Then I needed a way to configure the XBee for peer-to-peer communication (as I only have two chips right now). I was using screen on the mac to see output from my previous tests. That is a little cumbersome. I decided to try zterm (downloaded from http://www.macupdate.com/app/mac/6888/zterm-x) in the hopes that would be a little better.
First, I plugged the XBee on the USB explorer card into my machine. Then I started up zterm. Then under Settings->Modem Preferences, I selected the usb serial device name. To find this I just selected the one that I did not recognize. I also checked in /dev for the date and time of the device to make sure it coincided with when I plugged it in. Then under settings->connection make sure the data rate is set to 9600. The two dialog boxes are shown below.
The wake up sequence is "+++" with no enter. When I typed that I got back "OK", I then typed "ATID" and received back 3332. All looks good and is what was expected based on arduino-xbee-wireless. Then using the guidelines at XBee_program_Arduino_wireless, I issued this command for the first xbee card:
ATID4321which changes the network id to 4321. You should pick your favorite four digit pin.
ATID4321,DH0,DL1,MY0,BD4,WR,CNwhich increases the baud rate to 19,200 and sets the address to 0. I repeated the process for the second card. This time, the command is:
ATID4321,DH0,DL0,MY1,BD4,WR,CN
which increases the baud rate and assigns the second card the address to 1. I then changed the zterm connection data rate to 19,200 and was able to re-issue the "+++" command and the "ATID" to see the new id. The shield I was using has a toggle on it to switch back and forth between UART and DLINE. This lets the code be downloaded using the USB to Arduino and then the serial line to send back and forth data. I created a very simple sketch:
I uploaded this, unplugged the Arduino, and then fired up zterm. When I type something in zterm it is echoed back with a hello prompt in front. So this allowed wireless data to be exchanged once the sketch was uploaded to the Arduino.
- void setup()
- {
- delay(1000);
- Serial.begin(19200);
- Serial.flush();
- }
- void loop()
- {
- Serial.print("\rHello>");
- while (Serial.available())
- {
- char inByte = Serial.read();
- Serial.println(inByte);
- }
- }
No comments:
Post a Comment