Xbee - Pololu 3pi+ Connection API Mode (read() does not work)

Hello,

I hope that this is the right forum to ask for help.

I am working with two XBee Series 3 and one Pololu 3pi+ Robot and trying to build the connection between the robot connected to a XBee and the computer using the XCTU software connected to a XBee.

The write() function does work, I am able to send data from the robot to the XCTU terminal using the API mode. But the other way, XCTU Terminal to Pololu doesn’t work, I am not able read any data.

I am stuck with this problem for some time and tried to google a possible solution, but it was no help.

Connections (Pololu/XBee, RX is 0 and TX is 1 according to the datasheet):
3V3 - VCC
GND - GND
0 - DOUT
1 - DIN

Code which doesn’t work:

#include <SoftwareSerial.h>

SoftwareSerial sserial(0,1);
void setup() {
    sserial.begin(9600);
    delay(1000);
    Serial.println("Setup Complete\n");
}

void loop() {
    if (sserial.available() > 0) {
        Serial.println("Data Available!\n");
        char a = sserial.read();
        Serial.println(a);
    }
    else {
        Serial.println("No Data Available\n");
    }
}

When I am trying to print just Serial.read() it also doesn’t work, as the Pololu isn’t receiving anything. It is stuck after the setup(), because the if (sserial.available() > 0) is never true. Without the if condition it also doesn’t work.

For example:

#include <SoftwareSerial.h>

SoftwareSerial sserial(0,1);
void setup() {
    sserial.begin(9600);
    delay(1000);
    Serial.println("Setup Complete\n");
}

void loop() {
    char a = sserial.read();
    Serial.println(a);
}

This just returns:

⸮
⸮
⸮

And so on. Does anyone have a idea what to do? It is really anoying that the write function works, but the read doesn’t.

Hello.

Not all pins on the ATmega32U4 used on the 3pi+ 32U4 Control Board support change interrupts, so only certain pins can be used for RX with Software Serial (pins 8, 9, 10, 11, 14, 15, 16). You might consider just switching to hardware serial (Serial1), especially since you are already using the hardware serial pins.

By the way, the 3pi+ 32U4 Control Board uses 5V signals, so you should double check that your XBee module is 5V tolerant, otherwise you might consider using some kind of logic level shifter to make sure it does not cause problems.

Brandon