Open SloMusti opened 6 years ago
The communication with RPi and setting the system time can be achieved with the following simple script:
Install first on stock raspbian lite: sudo apt-get install python-pip sudo pip install pyserial
sudo apt-get install python-pip
sudo pip install pyserial
disable ntp (must implement connectivity check later on) sudo systemctl stop systemd-timesyncd.service
sudo systemctl stop systemd-timesyncd.service
#!/usr/bin/env python import time import serial import subprocess ser = serial.Serial( port=`/dev/ttyAMA0`, baudrate = 115200, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1 ) counter=0 while 1: x=ser.readline() if x.startswith("t:"): time= x[2:-1] print "Time found: " + time args = [`date`, `-s`, time] subprocess.Popen(args) elif x.startswith("p:"): print "Period found: " + x[2:-1] elif x.startswith("b:"): adc = float(x[2:]) print("Battery: %2.2f V" % (adc*0.0164))
expected output:
Mon May 14 18:54:09 UTC 2018 Time found: Mon May 14 18:54:09 2018 Period found: 1752 Battery: 4.02 V
The communication with RPi and setting the system time can be achieved with the following simple script:
Install first on stock raspbian lite:
sudo apt-get install python-pip
sudo pip install pyserial
disable ntp (must implement connectivity check later on)
sudo systemctl stop systemd-timesyncd.service
expected output: