1

I have an Arduino Uno with a Wireless SD Shield and XBee S1 and a PC with another XBee S1 connected to it. What I'm after is for me to be able to send a message from my computer and receive a message back from the Arduino (For now let's just say if the Arduino receives a "1" I want it to send an "A" back) Here is the code I have been practicing with (courtesy of SparkFun)

#include <SoftwareSerial.h>
SoftwareSerial XBee(0, 1); // RX, TX
void setup() {
 XBee.begin(9600);
 Serial.begin(9600);
}
void loop() {
 if (Serial.available()) { 
 XBee.write(Serial.read());
 }
 if (XBee.available()) { 
 Serial.write(XBee.read());
 }
}

(I have changed the pins from 2,3 to 0,1 as the latter is on the Arduino itself) I have set my Xbees up and have been able to get them to talk to each other when both connected to separate PC's, but I am having trouble getting the Arduino to send information to the other XBee. When I try and send data from the Arduino IDE both RX and TX Led's flash. Could anyone steer me in the right direction?

James Waldby - jwpat7
8,9203 gold badges21 silver badges33 bronze badges
asked Jun 30, 2015 at 15:45
1
  • 1
    I have changed the pins from 2,3 to 0,1 - change it back, no wonder it doesn't work. You can't have HardwareSerial and SoftwareSerial on the same two pins. It doesn't make any kind of sense. Commented Feb 26, 2016 at 6:13

2 Answers 2

2

You don't need to declare an extra (software) serial port because the wireless shield connects the Arduino TX and RX on pins 0 and 1 directly to the TX and RX of the Xbee. So, Serial.available, Serial.read and Serial.write directly addresses the xbee. Just leave out the software serial from your code and it should work.

answered Jun 30, 2015 at 16:03
2

Pin 0 and 1 are the Hardware Serial of Arduino you cannot use it as the software serial and I also used that code once use pin 2 and 3 its issue regarding the configuration of your XBEE? Check your XBEE configuration XCTU

answered Feb 26, 2016 at 5:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.