I would like to port that small programm to run on an ESP32.
It is using the accurate time to set an gpio on and of. On the Raspi i get the time from 3 ntp server.
On that ESP32 i would like to use in addition a gps receiver...
Is that possible? Thanks in advance...
Code: Select all
import time
from RPi import GPIO
LED_PIN = 40
SEQUENCE = [
(1000, True),
(2000, False),
(7000, True),
(3000, False),
(5000, True),
(2000, False),
]
PERIOD = sum(t for t, _ in SEQUENCE) / 1000.0 # in seconds
def main():
GPIO.setmode(GPIO.BOARD)
GPIO.setup(LED_PIN , GPIO.OUT)
try:
next_time = time.time()
next_time -= next_time % -PERIOD
while True:
for delay, on in SEQUENCE:
GPIO.output(LED_PIN, on)
next_time += delay / 1000.0
time.sleep(max(0, next_time - time.time()))
finally:
GPIO.cleanup()
if __name__ == '__main__':
main()