Created
September 26, 2020 20:36
-
-
Save robinp7720/5b2a2637c041c4552ed75eba16e390e9 to your computer and use it in GitHub Desktop.
433Mhz request logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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