(Aug-30-2020, 02:43 PM)deanhystad Wrote: Serial.readline waits for a newline character ('\n'). Since you did not specify a timeout value for serial.open, and your program does not wait forever, it must be receiving a newline and that is why there is a newline at the end of you string/bytes/whatever. I am not sure why you are also getting the carriage return ('\r'). It must be part of the message that was sent or an artifact of how the message was sent.
Use strip() to remove trailing blank space characters like carriage return and new line.
arduino_data = arduino.readline().strip()
Dear deanhystad Thanks for the repy
It is very clear me what you have point out
This is the arduino code
int x = 10; int temp = 10; int hum = 12; void setup() { Serial.begin(9600); } void loop() { temp++; hum++; delay(10); Serial.print(temp); Serial.print("x"); Serial.println(hum); delay(2000); }in above code Serial.println(hum);code ( Line number 14 )have println ln is carriage return but the first code Serial.print(temp);( Line number 12 )do not have carriage return but it is showing in the output
Please advice
About timeout I will check and update here
yes your point out is very accurate and technical
I change the code as follows
arduino = serial.Serial('COM15',9600 , timeout = 1)Arduino code also change by removing carriage return
void loop() { temp++; hum++; delay(10); Serial.print(temp); Serial.print("x"); Serial.print(hum); delay(2000); }Now it is working
Grate thanks