mirror of
https://gitlab.com/Luci_/arduino-photometrics.git
synced 2026-04-03 03:25:36 +02:00
23 lines
442 B
Python
Executable file
23 lines
442 B
Python
Executable file
import serial
|
|
import time
|
|
|
|
ARDUINO_PORT = '/dev/ttyACM0'
|
|
BAUD_RATE = 9600
|
|
|
|
try:
|
|
ser = serial.Serial(ARDUINO_PORT, BAUD_RATE)
|
|
time.sleep(2)
|
|
except serial.SerialException as e:
|
|
print(f"Error : fail to open serial port {ARDUINO_PORT}: {e}")
|
|
exit()
|
|
|
|
epoch = int(time.time())
|
|
|
|
commande_rtc = f"T{epoch}\n"
|
|
|
|
ser.write(commande_rtc.encode())
|
|
|
|
ser.close()
|
|
|
|
print(f"Cmd send : {commande_rtc.strip()}")
|
|
print(f"Epoch send: {epoch}") |