-
-
Save skitoo/45252acf3723d7a9e20581167da6d853 to your computer and use it in GitHub Desktop.
Arduino Emiter RF433
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
#include "DHT.h" | |
#include <VirtualWire.h> | |
#define DHTPIN 7 | |
#define DHTTYPE DHT11 | |
DHT dht(DHTPIN, DHTTYPE); | |
void setup() { | |
Serial.begin(9600); | |
dht.begin(); | |
vw_setup(2000); | |
Serial.println("Starting..."); | |
} | |
void loop() { | |
delay(2000); | |
float humidity = dht.readHumidity(); | |
float temperature = dht.readTemperature(); | |
if(isnan(humidity) || isnan(temperature)) { | |
Serial.println("Failed to read from DHT sensor!"); | |
return; | |
} | |
byte data[27]; | |
String value = "001#" + (String)(int)temperature + "#" + (String)(int)humidity + "\0"; | |
strcpy(data,value.c_str()); | |
vw_send(data, 27); | |
vw_wait_tx(); | |
} |
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
#!/usr/bin/env python3 | |
import time | |
from rpi_rf import RFDevice | |
rfdevice = RFDevice(27) | |
rfdevice.enable_rx() | |
timestamp = None | |
print('Starting...') | |
while True: | |
if rfdevice.rx_code_timestamp != timestamp: | |
timestamp = rfdevice.rx_code_timestamp | |
print(str(rfdevice.rx_code) + " [pulselength " + str(rfdevice.rx_pulselength) + ", protocol " + str(rfdevice.rx_proto) + "]") | |
time.sleep(0.01) | |
rfdevice.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment