Re: XBee Arduino Communication

How Do I Transfer Data from one XBee Arduino to another XBee Arduino?

Series 1 or 2 xbee's? Already configured with X-CTU? Receiving random numbers -> baud-rates correct? If you receive random numbers, how do you know they are send properly?

IF the xbee's are properly configured what about just ignoring that they are xbee's and pretend it is a serial cable. Than it is a matter of Serial.available, Serial.read and Serial.print.

I recommend to focus on one single problem first before doing the complete project.

Jeroen

They are Series 1 XBee's... They are configured in X-CTU.... And Yes they are both running at 57600...

If I connect the receiving XBee to my computer and look at the X-CTU Terminal, I can see that the right values are being transmitted. However, when I plug it into the receiving Arduino and use Serial.Read and Serial.Available, It gives my some weird numbers..

We need to see the code on the sending Arduino and the code on the receiving Arduino. You are probably making some assumptions about the data, on the receiver, that are not valid.

Sending Arduino:

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup()
{
Serial.begin(57600);
sensors.begin();
}

void loop()
{
sensors.requestTemperatures();
Serial.println(sensors.getTempFByIndex(0));
}

Receiving Arduino:

#include <LiquidCrystal.h>

LiquidCrystal lcd(2,3,4,5,6,7);

void setup ()
{
Serial.begin(57600);
lcd.begin(20,4);
}

void loop()
{
lcd.print(Serial.read());
}

On the receiver, you are calling Serial.read() without checking that there is anything to read. When there is no serial data to read, the Serial.read() function returns a -1.

What does lcd.print(-1) do?

if (Serial.available() > 0) lcd.print(Serial.read());

I am still getting random numbers tho...

With the sender connected to the PC, and the Serial Monitor open, do the values shown look reasonable?

What kind of random numbers? Always numbers or are there letters and other symbols mixed in?

When it is connected to the computer, the temperature values are perfect! Like it is around 70 to 80 degrees. And if I hold the sensor, the value goes up so it is responding properly.

There are no letters or numbers but they are like for example 568340483 all at once. It gives numbers in the billionths at one time.

Try changing the sender to do this:

Serial.print("Sensor temperature: ");
Serial.print(sensors.getTempFByIndex(0));
Serial.println(" <==");

See if the characters come across correctly.

Without knowing what the return type is for sensors.getTempFByIndex(), it’s hard to say what is being sent. I would hazard a guess though that the temperature is being converted to a string.

That shouldn’t really matter, though, since the string is what is being received and printed on the receiver.

I think that should be:

  if (Serial.available()) {
    lcd.write(Serial.read());

lcd.print expects data as ASCII characters while lcd.write expects data as a byte value.

I tried the code that you told me to use and now it is giving completely random characters…

Have any idea why?

I would double check your LCD wiring and setup.

What happens when you run:

lcd.print("hello, world!");

Are the numbers (or characters) truly random? i.e. do they repeat or have similarities? Truly random is nearly impossible to achieve.

Why not post some of these random numbers, as they may hold clues.

Just give me a sec.... I will post a picture of my setup and output...

Oh and I tried typing hello world and it worked perfectly by the way...

Well I do not know how to post a picture lol... Anyway... I used lcd.write and it displayed some of the numbers and at one time it displayed 80.87 but then it showed some different lines and other weird symbols...

Well I do not know how to post a picture

You need to upload your pictures to a file sharing site, like flickr. Then, using the InsertImage or InsertHyperlink buttons, create a link to the web-based photo.