Hello ,
I have a script that read data from serial sensor
the data is sent in BR 9600
i'm waiting 500ms from each reading - so I'm getting 2 reading at one time
how can I avoid this ?
I have a script that read data from serial sensor
the data is sent in BR 9600
i'm waiting 500ms from each reading - so I'm getting 2 reading at one time
how can I avoid this ?
Time: 17:11:59 23.89!95.1223.88!99.60 23.89 no Time: 17:12:01 23.88!102.2023.88!100.20 23.88 no Time: 17:12:03 23.89!93.9223.88!98.52 23.89 no Time: 17:12:05 23.88!104.5223.89!91.72 23.88 nothis is the code :
import serial
import time
import I2C_LCD_driver
ser = serial.Serial(
port='/dev/serial0',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
def ReadFromSerial():
x=ser.readline()
print (x)
split = x.split("!")
print (split[0])
if (float(split[0]) >100):
problem = "yes"
else:
problem = "no"
return problem
while True:
print ("Time: %s" %time.strftime("%H:%M:%S"))
answer = ReadFromSerial()
print(answer)
time.sleep(0.5)
