I am working on a project in which i am getting data from an arduino over serial communication. So i open a ser = serial.Serial('/dev/ttyACM1', 9600)
and everything is working fine. The thing is that i wrote this code to check when the data i get is 0 but i can't get it work.
while True:
try :
a = ser.readline()
# i do that because the input stream is smthg like b' 16.894548\r\n'
data = a.decode('utf-8')
print(a is str(str(0).encode('utf-8').decode('utf-8', "strict")))
I have tried many things, like getting the sizeof, encode and decode, making everything a str
after decoding. But still no luck.
Any ideas?