i'm reading value through python serial port of sensor of arduino.
my code(python):
arduino = serial.serial(2, 9600, timeout=1) print("message arduino: ") while true: msg = arduino.readline() print(msg) i don't know why output result b'[sensor-value]\r\n'. so, b'758\r\n' b'534\r\n' b'845\r\n' etc (regarding sensor change value).
how convert this?
you need decode it.
print(msg.decode('utf-8')) please check lexical analysis on python 3 documentation see string prefixes means
Comments
Post a Comment