Repozitář pro studenty 3.ročníku zaměření IVE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

18 lines
467 B

import serial #pip intall pyserial
import time
from datetime import datetime
ser = serial.Serial("COM3",9600)
while True:
line = ser.readline().decode("utf-8").strip()
sensor_name, sensor_value = line.split(":")
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print(f"Čas: {current_time}")
print(f"Název senzoru: {sensor_name}")
print(f"Hodnota senzoru: {sensor_value}")
print("------------------")
time.sleep(1)