program will let you know if arduino disconnected

This commit is contained in:
Seth Samuel 2024-11-12 01:40:58 +13:00
parent d0196b4a31
commit c42864e46d

View file

@ -87,7 +87,7 @@ while connectedWebSocket == False:
while connectedArduino == False:
try:
toPi=serial.Serial(SERIAL_PORT,115200) #connect to arduino
toPi=serial.Serial(SERIAL_PORT,115200,timeout=2) #connect to arduino
connectedArduino = True
except:
print("please check connection to arduino and verify the correct serial port")
@ -115,6 +115,8 @@ while True:
if csvOut == True:
csvWriteOut(firstRun,carData,csvFile)
firstRun=False
try:
toPi.write(str(kmh).encode()+":".encode())
except:
print("arduino disconnected please check connection\n")