We have been working on the xbee pro xsc for a couple of days,we got it to light the other arduino's led but were having problem display it on the com port,it continuously showed us -49 for any integer data.
Your pinMode(2,HIGH) in your master code should not be HIGH, it should be either OUTPUT or INPUT. Im surprised you didn't get an error message. Also your trying to SEND a CHAR not an INT, so your slave code should not be looking for an INT, it should be:
char data = Serial.read();
And for your master code should be:
Serial.Write('0');
Serial.Write('1');
Serial.Write('2');
Serial.Write('3');
etc
ok, regardless if your using a button or not, if you want to send data from the master to the slave you need to Serial.Write it otherwise the slave will get the wrong data.
also that -49 is just (-'0'), there is no incoming data so data = data-'0'; is going to produce -49 everytime.
Also one other thing, if you want to receive data from the master to the slave and then print that data from the slave, you need to have a ARD mega, because a regular UNO will not be able to do both.
Unless, your master has a LCD display in which case it can do both, but to get the data from a RF or BT module and then display it on a computer monitor, it can't do that.
MEGA:
Serial.begin(9600); //print the incoming data to the screenget the incoming data
Serial1.begin(9600); // get the incoming data
Serial.print(/your data here/); // NOTICE the Serial"1" this puts your data on a different TX/RX to be output to the screen.
yup that is happening,the thing is that its glowing the led whenever defined like at 0 or 1,it does go on and the rest of the times its off,but the problem is with receiving the data,its showing me values that are constant
I'm an idiot for not asking this before, do you know how to use an xbee or is this your first time?
If this is your first time, then please go on youtube and find some tutorials. I have a sample code here that may help you.
Also watch this guy:
The Xbee has it's own way of communicating to the arduino. It will not accept Serial.read or write commands, instead it has its own xbee.read and xbee.write.
HOWEVER...
If you just want to test the code you wrote, use jumper cables to simulate a connection.
int led = 13;
void setup()
{
Serial.begin(9600); // usb connection to PC, view in ARD serial monitor
Serial1.begin(9600); //connect to mega
pinMode(led,OUTPUT);
Serial.println("start on slave");
}
void loop()
{
if (Serial1.available() > 0) {
digitalWrite(led,HIGH);
char data=Serial1.read();
Serial.print(data);
data = ' '; // clears data for new char, (just in case)
}
else {
digitalWrite(led,LOW);
}
}
its actually not the first time,ive configured it,and ive seen that video too but it doesnt help alot as ive a xbee pro xsc,but the connection is established and im using a 3v3 regulator to connect to the arduino for both my xbees,
dout=rx0(data that came ,now stored in the buffer)
din =tx0(data coming in from the arduino to transmit)
and the thing is all the codes that Ive tried till now can only do a specific function like light an led,or like jeremy blum's servo motor,but i still dont know to receive data.
The major problem with this xbee in specific is that it cant go more than 9600 baud rate,plus it works on point to point communication,so i really cant use the api mode.
The major problem with this xbee in specific is that it cant go more than 9600 baud rate,plus it works on point to point communication,so i really cant use the api mode.
yes it can go beyond 9600 if you know how to do it. And I apologize, it can use Serial.read and write.
now from the codes you wrote, what do you want to actually do with it?
Also try that jumper trick I said before, so you can see what the slave ARD is actually getting.
yeah i think thats what im going to do next,its taken too long,the main function for this was long range thats why i bought it,and its taken me so long to get it to work.What xbees did you use?
quick question, did you follow that video from sciguy completely? Because he shows what program to download and how to setup the xbees. Im just curious, thats all.
yup,for this xbee,basically instead of choosing the xbee model like xb 24 or something and then choosing router at or coordinator at,i had to choose xbee xsc 9600 which automatically comes when its read,now comes the fun part,i cant use atdh or atdl for this,so it took me along time figuring this out ,the two commands are ATID(pan address) which i set as default for both,and ATDT which have to be the same so i put it as 0100 using teraterm instead of putty ,and the communication was made after ATWR.
And the thing is that it isnt series 1 or series 2 or pro versions of those 2,there is a totally different model XBee Pro 900 XSC RPSMA - WRL-09087 - SparkFun Electronics