X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=rpi_promini%2Frpi_promini.ino;h=a2ee8d1139c09abfe4ed49f0cb66c90f1a33d900;hb=HEAD;hp=5fea2276878c12a1212c91e502d631f193041e5e;hpb=bcaae974d3db50fb3b7f9b88d5105abe76ad5992;p=Arduino diff --git a/rpi_promini/rpi_promini.ino b/rpi_promini/rpi_promini.ino index 5fea227..c89b2cf 100644 --- a/rpi_promini/rpi_promini.ino +++ b/rpi_promini/rpi_promini.ino @@ -40,7 +40,7 @@ DallasTemperature sensors(&oneWire); int int_0 = 300; // ms int int_1 = 900; // ms int wait = 2000; // ms -int repeat = 20; // times (5 times seem a little low for sensors which are more than 10m away) +int repeat = 5; // times (5 times seem a little low for sensors which are more than 10m away) void send_315(char *code) { Serial.print("send 315Mhz "); @@ -88,7 +88,7 @@ void help() { } void setup() { - Serial.begin(9600); + Serial.begin(115200); mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2 mySwitch.enableTransmit(10); // with sender wired in receiving doesn't work, pin #10 mySwitch.setRepeatTransmit(repeat); // or change to be different for 433 and 315 MHz @@ -107,18 +107,20 @@ void setup() { int serial_pos = 0; char serial_data[2]; // socket (0-9), state (0-1) char binary_data[32]; -int dht22_errors = 0; +unsigned int dht22_errors = 0; unsigned long time = millis(); void loop() { if ( millis() - time > 2000 ) { float t = dht.getTemperature(); - if ( dht.getStatus() == 0 ) + float delta_t = abs(t - temp_avg.getAverage()); + if ( dht.getStatus() == 0 && delta_t < 5 ) temp_avg.addValue( t ); else dht22_errors++; float h = dht.getHumidity(); - if ( dht.getStatus() == 0 ) + float delta_h = abs(h - hum_avg.getAverage()); + if ( dht.getStatus() == 0 && delta_h < 10 ) hum_avg.addValue( h ); else dht22_errors++; time = millis();