Core Electronics Forum

Rasp pi and arduino xbee communication

Hi, I would like help to get my raspberry zero to transmit a signal (character) to my arduino in order to trigger a servo motor. I am using XBee series 1, API mode for all XBee units. I have tested the wireless communciation via Xbees between two arduino units and they work fine, with the activation of the servo motor. The problem arise when I try to use Xbee communication with a raspberry zero (with a xbee USB explorer) together with an arduino. I appreciate if I can get advice on how I can overcome the lack of XBee transmission from my rapsberry zero to my arduino. Thanks!

The code of my sending unit (raspberry zero) is:

import serial
ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=.5)
for x in range(0,10):
      ser.write('A\r\n')

The code for my receiving unit (arduino) is:

#include <Servo.h> 
#include "SoftwareSerial.h"
Servo myservo;

int pos = 0;
SoftwareSerial XBee(2, 3);

void setup()
{
 Serial.begin(9600);
   XBee.begin(9600); 
   myservo.attach(12);
}
 
void loop()
{
  if (XBee.available())  
 {
        char c = XBee.read();
        if (c == 'A')
 {
          //delay(7000);
          myservo.write(180);
          delay(3000);
        }
    }
     else 
     {
       delay(10);
   }
    
 }

To rule out an Xbee problem, I also did another test setup and used another arduino as the sending unit.
This worked and the code for this arduino unit is:

#include "SoftwareSerial.h"

SoftwareSerial XBee(2, 3);

void setup()
{
  Serial.begin(9600); //Start serial port for debugging
  XBee.begin(9600); 
  delay(2000);
}

void loop()
{
          XBee.write('A');
          delay(4000);
          Serial.println("A Sent");
}