Skip to content

Instantly share code, notes, and snippets.

@robinp7720
Created September 26, 2020 20:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinp7720/5b2a2637c041c4552ed75eba16e390e9 to your computer and use it in GitHub Desktop.
Save robinp7720/5b2a2637c041c4552ed75eba16e390e9 to your computer and use it in GitHub Desktop.
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