Skip to content

Instantly share code, notes, and snippets.

@robinp7720

robinp7720/logger.py

Created Sep 26, 2020
Embed
What would you like to do?
433Mhz request logger
from datetime import datetime
from datetime import timedelta
from time import sleep
import RPi.GPIO as GPIO
RECEIVE_PIN = 23
RECIEVED = []
GPIO.setmode(GPIO.BCM)
GPIO.setup(RECEIVE_PIN, GPIO.IN)
lastTime = datetime.now()
last = 0
while True:
current = GPIO.input(RECEIVE_PIN)
currentTime = datetime.now()
if(current == last):
if (currentTime - lastTime > timedelta(seconds=10)):
break
continue
delta = (currentTime - lastTime).microseconds
RECIEVED.append((delta, current))
lastTime = currentTime
last = current
print("DONE")
print("WRITING TO FILE")
file = open("output", "a")
for i in RECIEVED:
file.write(str(i[0]) + '\n')
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.