How to use XBEE module on Relay Shield for Arduino V2.1?

I’m looking to use the XBee module on the DFRobot’s Relay Shield for Arduino V2.1. However i am unable to make it work.

If anyone could point me to a tutorial/or code for basic serial in out to another xbee from the shield, I will greatly appreciate it.

Did you try the link to the Sample code on the link you provided?

The DFRobot Relay Shield for Arduino is used differently than most shields. To get power to it you need to:

  1. Unplug your USB cable used to upload your program and provide an external power source. I used 7.4v LiPo or 11.1v LiPo plogged into the power jack.
  2. To communicate with your XBEE or bluetooth module the shield uses the serial port so don’t use pins for TX and RX, simply use and Serial.print()
  3. After you upload your program, remove the USB cable and the “prog” switch to “Run” mode. Back to “Prog” when uploading a new program…and so-forth.
    Here is a simple LED on off to test it. I used a smartphone bluetooth app to send the data.

#include //Software Serial Port

#define Sketch_Name “BTC_XBEE_Relay_Slave_Led_2017_3_18”
//#define RxD 4
//#define TxD 5

#define PINLED 13

#define LEDON() digitalWrite(PINLED, HIGH)
#define LEDOFF() digitalWrite(PINLED, LOW)


//SoftwareSerial blueToothSerial(RxD, TxD);

void setup()
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
Serial.print("Sketch: ");


void loop()
char recvChar;

while (1)
if (Serial.available())
{ //check if there’s any data sent from the remote bluetooth shield
recvChar =;
Serial.print("Command = ");

  if (recvChar == '1')
    Serial.println("; LED is ON");
  else if (recvChar == '0')
    Serial.println("; LED is OFF");


1 Like