Xbee Reading and not Writing

Hi Everyone,

I’m trying to talk between two XBee’s (Series 1) that are set up point to point according to this example (Examples & Guides | Digi International). One is on the GHI Xbee module and the other an XBee USB explorer. The problem is I’m only able to talk one way between the USB explorer and the XBee module. When I send a byte from the Gadgeteer Xbee this is not seen in the serial console. In debugging this I replaced the Xbee Gadgeteer module with the USB serial module and the byte is read by the serial console, so it’s definitely being passed to the XBee.

I’m using hydra on 4.2. My code is below, I’m really just wanting to make sure that I’ve not done something silly or that there are any problems with this set up before I test it without the module.

Many thanks for any advice.

 void ProgramStarted()
           xBee.Configure(9600, GT.Interfaces.Serial.SerialParity.None, GT.Interfaces.Serial.SerialStopBits.One, 8);
           xBee.SerialLine.DataReceived += new GT.Interfaces.Serial.DataReceivedEventHandler(SerialLine_DataReceived);
           button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);

            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

        void button_ButtonPressed(Button sender, Button.ButtonState state)
            byte[] toWrite = { 0x13 };
            xBee.SerialLine.Write(toWrite); // get reading of compass 3600

        void SerialLine_DataReceived(GT.Interfaces.Serial sender, System.IO.Ports.SerialData data)
            int recievedData = sender.ReadByte();

Sorry I’m not sure how clear this is, but the USB explorer does not see the byte, I’ve been debugging this through a serial monitor.


So what is working exactly ?

USB Explorer -> GHI XBee or GHI XBee -> USB Explorer ?

I’ve had similar problems with my XBees. (Series 1, Pros). There are a few things I had to go through in order to get them to work.

First, I’ve had to check, double-check, and triple check their configuration. Make sure addressing is configured properly. One thing I found that helps is using X-CTU and the ATND command. Get your XBees up and running - in my case, I have one running through a Gadgeteer and one running through a XBee Explorer. On the PC, fire up X-CTU; choose the corresponding COM port for your XBee Explorer and flip over to the terminal window. Fire a “+++”; wait a few seconds for the OK message; then issue ATND. It should come back with the address information on the partner XBee. You’ll see it’s high and low address, signal strength, etc…

I’ve also noticed that my XBees are vulnerable to wireless interference. I’ve had to play with using different channels. I spent a day or so beating my head against the wall trying to get a simple ping-test going only to discover that switching channels resolved the problem. It got so bad that I thought my colleagues cell phone was killing me.

I found that hooking the serial port’s error received event can help alert you to problems.

I also found that having multiple data received event handlers wired up can cause them to step on each other. I had one event handler wired up for accepting/processing “commands,” and another wired up for sending binary data over XModem. I found that I have to be really careful about disconnecting the “command” processing before doing binary processing; and vice-versa. Otherwise, my “command” handler would kill “binary” processing; or vice-versa.

I also wrote my own XBee wrapper based on some of the community code-share - I’m not use XBee API mode. There’s a short, simple XBee wrapper in the community that shows how to receive a stream of data, parse it out, and raise events whenever a full command-string is received. I use similar code/classes on both my Gadgeteer and PC.

I hope this helps. :slight_smile:

Thank you for your reply.

I have managed to get this sorted - but still very useful, I’m actually not sure what I did to make this work but it just started talking both ways so perhaps it was interference.

I had a couple of issues with the Xbee not saving my settings properly and in particular the baud rate would change, not to default, but 5600, which is strange, it has happened 3 times.

I have also more recently had some issues with my battery and voltage regulator which were quite noisy, the result was sporadic chat between Xbee’s, were sometimes they would ignore each other.

I am talking between gadgeteer and an xbee with the cmps10 compass directly connected to the xbee.