I have two Arduinos hooked up to XBee modules. One is sending temperature data from a DS18B20 temperature sensor. The other arduino is collecting that data and displaying it on an LCD. Does anyone know how to get it to work? I got the transmitting Arduino to work and it is sending data properly if I connect the receiving xbee to my computer and looking at the X-CTU Terminal but when I receive the data on the Arduino, it is a bunch of random numbers… They are both running at 57600 Baud as well as the Arduinos. Please somebody help… I really need to finish this project fast and basically cannot move forward without solving this problem first.
I want it to display whatever number I put in. I tried adding the quotation marks just like you put it but it still gave the same result with all the random characters and symbols...
I put the code that you wanted but it would not accept lcd.write("Serial received: ").... I changed it to lcd.print and it worked. It printed the words "Serial Received" Properly but it did not display the number properly from lcd.write(Serial.read());
I have to ask: Why the new thread for the same question you already asked? It makes it a lot harder to follow and people have to ask the same questions over again. Even worse, now, we are going backwards.
lcd.write is correct.
The numbers you are getting are not random. How many times do you think the numbers 56, 46, 48, 194 would appear in a truly random series. Those are the ASCII codes for 8, ., 0, [ch9516], and considering that it appears that your workspace is 80.8ºF, The question becomes why the other garbage is in your communications.
Is there anything else connected to your serial lines (including the USB)? Any strong sources of RF interference?
Sorry… I just thought because my post was going to the lower end of the stack I needed to repost… Did you see the pictures that I posted? It was giving these random characters… I dont think there are any interferences…
Any time there is a new post it will move back to the top. If it drops off the front page and you still need an answer it is better to “bump” the post. i.e. post a reply in the same thread yourself (perhaps only with “bump” in the text) and it will move to top of the heap. Just don’t abuse it by bumping often and it is better to write something along the lines of “Hey Guys, I tried this and that and this other thing, but I still need help.”
So, are both USB cables unplugged?
Let’s try Hello World from the sending unit. So, change the sending Arduino to use:
Well, clearly the lcd.print picture looks more reasonable. However, there are no spaces between the individual bytes being written, so it’s hard to tell which numbers go together.
There is no text, either.
Make the sender send “ABCDEF : 1234567890” once. Make it send the float val 12.34.
float val = 12.34;
Serial.print(val);
Have the receiver lcd.print the received data. Show the code and the lcd picture.
65 is the ASCII code for 'A'. 66 is B. 70 is F. 32 is space. 58 is the ':'. 54 is the ASCII code for '1'.
The data on your LCD starts on line 1, goes to line 3, then line 2 and, finally line 4.
So, the data IS being sent correctly from the sender to the receiver, via the XBees. The issue is this statement:
lcd.print(Serial.read());
The Serial.read() function's return type is byte. While it is the same size as char, the lcd.print() function handles bytes and chars differently. chars are printed as characters '1', '2', 'A', etc. whereas bytes are written as strings '54', '52', '65', etc.
The key then is to cast the value returned by Serial.read90 a char in the call to lcd.print: