Skip to content

Instantly share code, notes, and snippets.

@skitoo
Last active February 6, 2019 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skitoo/45252acf3723d7a9e20581167da6d853 to your computer and use it in GitHub Desktop.
Save skitoo/45252acf3723d7a9e20581167da6d853 to your computer and use it in GitHub Desktop.
Arduino Emiter RF433
#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();
}
#!/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