Northland:
Riiiiiiiiiight.
You mean example 2. With FOURTY SEVEN lines of code. Just to send a number from one arduino to another?
You can’t count
The actual recvWithEndMarker() is only TWENTY-TWO lines 
Northland:
And yet, on https://www.arduino.cc/en/Serial/Print it states
“Floats are similarly printed as ASCII digits, defaulting to two decimal places” which certainly does not imply 47 lines of code are required.
How do you get to the conclusion that that does not require 47 lines?
Northland:
Mega:
Serial2.print(Amps);
Serial2.print(’\n’);
As I said, add a newline (I used “\n” but that’s basically the same).
Northland:
Nano:
if(Serial.available() > 0) {
str = Serial.readStringUntil(’\n’);
Amps = str.toFloat();
lcd.print(Amps);
}
There. 6 lines of code.
Great. Just for your information, readStringUntil is actually 11 lines of code and calls timedRead which is another 10 lines of code. So Robin’s code did not do to badly 
Although this might work for the current setup, be aware that this will not always work.
The pitfalls:
1)
What happens if you don’t receive the ‘\n’ in time? Not likely with your current sending code but something to be aware of. Therefor it might actually be better to use the example with startmarker and endmarker. That way you can guarantee that you received a full message; yes, that will be more lines of code.
2)
The use of String (capital S) which can result in difficult to trace undefined behaviour due to memory issues. It’s not said that that will be the case in this scenario, but don’t come crying that it crashes after 2 hours or 2 days or …
You might be better of using readBytesUntil() and atof().
And a last thing: you pissed away 1.5 kByte of code memory. Not an issue now probably but for other projects it might be.
Based on your code, the following sketch.
void setup() {
Serial.begin(9600);
}
void loop() {
String str;
float Amps;
if (Serial.available() > 0) {
str = Serial.readStringUntil('\n');
Amps = str.toFloat();
//lcd.print(Amps);
Serial.println(Amps);
}
}
Compile information
Sketch uses 6,588 bytes (20%) of program storage space. Maximum is 32,256 bytes.
Global variables use 213 bytes (10%) of dynamic memory, leaving 1,835 bytes for local variables. Maximum is 2,048 bytes.
A sketch loosely based on example 2 of the Serial Input Basics thread.
void setup() {
Serial.begin(9600);
}
void loop()
{
char *str;
float Amps;
unsigned long startTime = 0;
// start time for timeout
startTime = millis();
while (millis() - startTime < 1000)
{
// read a string (lower case s) character by character
str = readSerial();
// if complete
if (str != NULL)
break;
}
// if complete
if (str != NULL)
{
Amps = atof(str);
//lcd.print(Amps);
Serial.println(Amps);
}
}
char *readSerial()
{
static char buffer[10];
static char index = 0;
if (index == 0)
{
// 'empty' buffer
buffer[0] = '\0';
}
// if data available and buffer not full
if (Serial.available() > 0 && index < sizeof(buffer))
{
// read a character
buffer[index] = Serial.read();
// if endmarker
if (buffer[index] == '\n')
{
// terminate with nul character
buffer[index] = '\0';
// for the next time, we start at zero again
index = 0;
// return buffer
return buffer;
}
// indecrement index so it points to next free position
index++;
}
// not complete yet
return NULL;
}
Compile information
Sketch uses 4,904 bytes (15%) of program storage space. Maximum is 32,256 bytes.
Global variables use 214 bytes (10%) of dynamic memory, leaving 1,834 bytes for local variables. Maximum is 2,048 bytes.
And a sketch based on readBytesUntil (not tested)
void setup() {
Serial.begin(9600);
}
void loop() {
char buffer[10];
float Amps;
if (Serial.available() > 0) {
Serial.readBytesUntil('\n', buffer, 10);
bool fIsValid = false;
// make sure that we have a nul character
for (int cnt = 0; cnt < sizeof(buffer); cnt++)
{
if (buffer[cnt] == '\n')
buffer[cnt] = '\0';
if (buffer[cnt] == '\0')
fIsValid = true;
}
// only if we have a nul character
if (fIsValid == true)
{
Amps = atof(buffer);
//lcd.print(Amps);
Serial.println(Amps);
}
}
}
Compile information
Sketch uses 5,050 bytes (15%) of program storage space. Maximum is 32,256 bytes.
Global variables use 209 bytes (10%) of dynamic memory, leaving 1,839 bytes for local variables. Maximum is 2,048 bytes.
It’s your call; if you don’t want to do all the typing, the last option is probably the optimum between amount of typing and code size (if you don’t care about blocking).