A few days later when I attempted to test it again, I ran into problems. The motor was not responding. I discovered that the arduino board's TX and RX LEDs were not flashing when I sent commands, and determined that the issue was with the communication.
After testing the XBee modules using a simple sketch, I'm unsure what the problem is (though I'm confident it's still with the communication) and would appreciate some help.
Now for some details:
Components used:
I purchased both XBee PRO S2B modules from adafruit sometime last year. I don't see them on adafruit's website anymore, but I think they're similar to these. I also purchased these adapter kits.
Here's a picture of my modules and adapters: I usually connect the coordinator XBee to my laptop using a USB to FTDI adapter. Since the adapter is essentially a small breakout with some female-female jumper wires, I'll post pictures in case that is the issue. You can also see in the picture below how I have it connected to the adapter. To see if the problem was with my FTDI adapter, I also repeated the testing by accessing the coordinator through my Arduino Uno as described in this video. No difference was observed with the exception of being able to see RX/TX LEDs flash (or not) on the Arduino.
To test the XBees on another board, I also used an Arduino Micro (not to connect the coordinator to the laptop, but to run the sketch).
Test Sketch
I adapted some code found on an Adafruit XBee guide.
Code: Select all
#include <SoftwareSerial.h>
// XBee's TX is connected to pin 2 (Micro's RX)
// XBee's RX is connected to pin 3 (Micro's TX)
SoftwareSerial XBee(2, 3); // RX, TX
void setup()
{
Serial.begin(9600); // Com with serial monitor
delay(2000); // Wait for port to open
Serial.println("Goodnight moon!");
// Both XBees configured for 9600 baud
XBee.begin(9600); // Com through XBee using RX/TX pins
XBee.println("Hello, world?");
}
void loop()
{
if (XBee.available())
{
Serial.println((char)XBee.read()); // send xbee data to serial montor
}
if (Serial.available())
{
XBee.println((char)Serial.read()); // send serial monitor data to XBee
}
}
For a serial monitor, I have been using visual studio 2013. To send/receive data through the XBee attached to my laptop, I've been using XCTU.
Before recommending that I check/change settings in XCTU, please keep in mind that the modules were working previously and that none of the settings have been changed. My suspicion is that too much current got away from the motor and fried something either on an adapter or on one of the modules. Right now I'm hoping you can help me find out what exactly needs replacing.
Testing Setup
Using the Arduino Mico I connected:
- Laptop USB to Arduino Micro USB
5V and GND on Micro to adapter 5V and GND
D2 on Micro to TX on XBee
D3 on Micro to RX on XBee
Testing and Results
I attempted to send characters from the XCTU console to the serial monitor and vice versa. I did this test multiple times, switching XBee modules and switching adapters. Changing adapters didn't seem to make a difference. I'll put below what I did followed by what I observed.
Computer/XCTU connected to the coordinator
- Typing characters into the XCTU console log
- The red LEDs on both of the XBee adapter kits light up for about 4 seconds, but the coordinator lags behind the router by about 1 second.
No RX/TX LEDs flash on the Micro
No message appears in the serial monitor
When connecting the coordinator to the computer through the Arduino Uno, the RX LED on the Uno does flash
- Typing characters into the serial monitor (and pressing send of course)
- The RX LED on the Micro flashes
The red LEDs on both of the XBee adapter kits light up for about 4 seconds (synchronized this time)
The character appears in the console log
When connecting the coordinator to the computer through the Arduino Uno, the TX LED on the Uno does flash
- Typing characters into the XCTU console log
- The red LEDs on both of the XBee adapter kits light up for about 4 seconds (synchronized)
No RX/TX LEDs flash on the Micro
No message appears in the serial monitor
When connecting the router to the computer through the Arduino Uno, the RX LED on the Uno does flash
- Typing characters into the serial monitor (and pressing send of course)
- The RX LED on the Micro flashes
The red LEDs on both of the XBee adapter kits light up for about 4 seconds (again the coordinator lags behind the router by about 1 second)
The character appears in the console log
When connecting the router to the computer through the Arduino Uno, the TX LED on the Uno does flash
The delay in the coordinator's LED makes me think that there's an issue with the coordinator module (not the adapter since switching adapter's didn't make a difference). However, I'm not sure how this accounts for the communication being "one-way." I call it one way because the console can receive data from the monitor, but the monitor cannot receive data from the console. In my mind, switching the router and the coordinator would reverse that, but I could be wrong.
Or maybe nothing is broken but I misspelled something in my code? I have no idea at this point. It's been taking a long time to fix something that was almost literally working fine yesterday. Any help would be appreciated. Thanks!