4 #include <Adafruit_Sensor.h>
8 #include "garage-config.h"
10 const char* wifi_ssid = WIFI_SSID;
11 const char* wifi_pass = WIFI_PASS;
14 IPAddress influxdb_ip(INFLUXDB_IP);
15 long influxdb_port = INFLUXDB_PORT;
16 unsigned int localPort = 2390;
18 long unsigned poll_int = POLL_INT;
20 String location = LOCATION;
26 DHT_Unified dht(DHTPIN, DHTTYPE);
28 TeleInfo teleinfo(&Serial);
34 WiFi.begin(WIFI_SSID, WIFI_PASS);
36 while (WiFi.status() != WL_CONNECTED) {
42 dht.temperature().getSensor(&sensor);
43 dht.humidity().getSensor(&sensor);
50 sensors_event_t event;
52 dht.temperature().getEvent(&event);
53 if (isnan(event.temperature)) {
56 sendToInfluxDB("temperature,city="+city+",location="+location, "value", String(event.temperature));
58 dht.humidity().getEvent(&event);
59 if (isnan(event.relative_humidity)) {
62 sendToInfluxDB("humidity,city="+city+",location="+location, "value", String(event.relative_humidity));
66 if(teleinfo.available()){
67 long I1 = teleinfo.getLongVal("IINST1");
68 long I2 = teleinfo.getLongVal("IINST2");
69 long I3 = teleinfo.getLongVal("IINST3");
70 long PAPP = teleinfo.getLongVal("PAPP");
71 long BASE = teleinfo.getLongVal("BASE");
72 sendToInfluxDB("teleinfo,city="+city+",phase=1", "IINST", String(I1));
73 sendToInfluxDB("teleinfo,city="+city+",phase=2", "IINST", String(I2));
74 sendToInfluxDB("teleinfo,city="+city+",phase=3", "IINST", String(I3));
75 sendToInfluxDB("teleinfo,city="+city, "PAPP", String(PAPP));
76 sendToInfluxDB("teleinfo,city="+city, "BASE", String(BASE));
77 teleinfo.resetAvailable();
81 void sendToInfluxDB(String measure, String key, String value) {
82 String line = measure+" "+key+"="+value;
84 Udp.beginPacket(influxdb_ip, influxdb_port);