Serial communication issue between Arduino Nano every and UNO wifi

Hi,

I need to read a float number from a height sensor using two Arduino boards (Arduino Nano every and Arduino UNO Wifi) simultaneously . One solution is reading the height number using Nano (Sender) and send data via serial communication to UNO (Receiver). I used the code below to send a float number from Nano to UNO using Serial1; however, the digits of the whole float number are printed on serial monitor individually (see UNO Serial monitor output below). I also used the code from this link (examples 2 and 4), Serial Input Basics - updated - #3 by Robin2, but none of them worked for my application. Any idea how to solve this issue?
I appreciate any help in advance.

Thank you,
Abbas

Wiring between Nano and UNO
Nano GND---->UNO GND
Nano Tx---->UNO Rx

Code for Sender

float Measured_Height;
void setup() {
  Serial.begin(9600);               
  Serial1.begin(9600);            
}
void loop() {
    Measured_Height=50.89;
    Serial1.println(String(Measured_Height));
}

Code for Receiver

void setup() {
  Serial.begin(9600);            
  Serial1.begin(9600);            
}
void loop() {

         char receivedData = Serial1.read();
         Serial.println(receivedData);        

}

UNO Serial monitor output


5
0
.
8
9




5
0
.
8
9

Do you know what the ln at the end of Serial.println means? It adds a line break after each print.

try in receiver code:

Serial.print(receivedData);  

Hi b707,

Thank you for your help. I edited my code based on your suggestion. It could fix my previous issue; however I got new issue which question mark character (?) printed in the serial monitor (see the output of the serial monitor below); some times the whole line (first line), some times at the end of the number (50.89?) and sometimes in the middle (50.?89). Any idea to solve this issue?

Thanks,
Abbas

⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.⸮89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89⸮
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
5⸮0.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50⸮.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
⸮
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89⸮
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.8⸮9
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89
50.89⸮

Try sending the height every 100 ms, and not every pass through loop.

On the reading side you should only read if there is a character available to read.

if(Serial1.available())
{
char receivedData = Serial1.read();
Serial.println(receivedData);  
}

Hi cattledog,

Thank you for your help. The code is working now.

Thanks,
Abbas

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.