#include <WiFi.h>
#include <WiFiUdp.h>
#include <LibTeleinfo2Std.h>
-#include <Adafruit_Sensor.h>
-#include <DHT.h>
-#include <DHT_U.h>
+#include <OneWire.h>
+#include <DallasTemperature.h>
#include <HardwareSerial.h>
#include "garage-config.h"
WiFiUDP Udp;
// Temp
-#define DHTPIN 19
-#define DHTTYPE DHT22
-DHT_Unified dht(DHTPIN, DHTTYPE);
+// GPIO where the DS18B20 is connected to
+const int oneWireBus = 19;
+// Setup a oneWire instance to communicate with any OneWire devices
+OneWire oneWire(oneWireBus);
+// Pass our oneWire reference to Dallas Temperature sensor
+DallasTemperature sensors(&oneWire);
// Uptime timer
boolean tick1sec=0;// one for interrupt, don't mess with
delay(500);
}
- dht.begin();
- sensor_t sensor;
- dht.temperature().getSensor(&sensor);
- dht.humidity().getSensor(&sensor);
+ sensors.begin();
tinfo.init(TINFO_MODE_STD);
tinfo.attachDataStd(DataCallback);
if ( WiFi.status() == WL_CONNECTED ) {
Serial.println("DEBUG wifi connected, start temp measure");
- sensors_event_t event;
+
+ sensors.requestTemperatures();
+ float tempC = sensors.getTempCByIndex(0);
- dht.temperature().getEvent(&event);
- if (isnan(event.temperature)) {
+ if(tempC == DEVICE_DISCONNECTED_C)
// Error
} else {
- sendToInfluxDB("temperature,city="+city+",location="+location, "value", String(event.temperature));
- }
- dht.humidity().getEvent(&event);
- if (isnan(event.relative_humidity)) {
- // Error
- } else {
- sendToInfluxDB("humidity,city="+city+",location="+location, "value", String(event.relative_humidity));
+ sendToInfluxDB("temperature,city="+city+",location=serre_semis", "value", String(tempC));
}
+
sendToInfluxDB("teleinfo,city="+city+",location="+location, "SINSTS", tinfo_SINSTS);
sendToInfluxDB("teleinfo,city="+city+",location="+location, "SINSTS1", tinfo_SINSTS1);
sendToInfluxDB("teleinfo,city="+city+",location="+location, "SINSTS2", tinfo_SINSTS2);