Some ESP experiments; Raspi: Only write into the average table if avg values not zero
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
#include "aREST.h"
|
||||
#include <climits>
|
||||
|
||||
//If the debug macro is enabled, there's a freeMemory routine
|
||||
//Check if this resolves the crashes...
|
||||
#define DEBUG_MODE 1
|
||||
|
||||
|
||||
//DHT settings:
|
||||
#define DHTPIN 14 // what digital pin we're connected to
|
||||
|
||||
@@ -13,12 +18,6 @@
|
||||
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
|
||||
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
|
||||
|
||||
// Connect pin 1 (on the left) of the sensor to +5V
|
||||
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
|
||||
// to 3.3V instead of 5V!
|
||||
// Connect pin 2 of the sensor to whatever your DHTPIN is
|
||||
// Connect pin 4 (on the right) of the sensor to GROUND
|
||||
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
|
||||
|
||||
// Initialize DHT sensor.
|
||||
// Note that older versions of this library took an optional third parameter to
|
||||
@@ -43,9 +42,12 @@ float temperature;
|
||||
float humidity;
|
||||
|
||||
|
||||
|
||||
//milli counter
|
||||
unsigned long millitotal = 0;
|
||||
float millicounter = 0;
|
||||
|
||||
//Temp variables
|
||||
float h, t;
|
||||
|
||||
//First measurement
|
||||
bool firstmeasurement = true;
|
||||
@@ -86,14 +88,14 @@ void setup() {
|
||||
|
||||
void loop() {
|
||||
// Wait a few seconds between measurements.
|
||||
float millicounter = millis();
|
||||
millicounter = millis();
|
||||
|
||||
if (millicounter >= millitotal) {
|
||||
// Reading temperature or humidity takes about 250 milliseconds!
|
||||
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
|
||||
float h = dht.readHumidity();
|
||||
h = dht.readHumidity();
|
||||
// Read temperature as Celsius (the default)
|
||||
float t = dht.readTemperature();
|
||||
t = dht.readTemperature();
|
||||
|
||||
// Check if any reads failed and exit early (to try again).
|
||||
if (isnan(h) || isnan(t)) {
|
||||
|
Reference in New Issue
Block a user