I have hooked up a raspberry pi and arduino nano via usb cable and have been trying to get them to communicate, but I am having problems reading the number that the arduino sends to the pi.
The print function on the python will say '31', but when I try to check if it equals that number is says False.
Python code:
import serial
ser = serial.Serial('/dev/ttyUSB0')
while True:
serial_input = ser.readline()
print(serial_input)
if(serial_input == '31'):
print('number received')
break;
Arduino code:
void setup() {
Serial.begin(9600);
}
void loop() {
char data[50];
sprintf(data, "%02X", '1');
Serial.println(data);
delay(1000);
}