6 #include "garage-config.h"
8 const char* wifi_ssid = WIFI_SSID;
9 const char* wifi_pass = WIFI_PASS;
12 IPAddress influxdb_ip(INFLUXDB_IP);
13 long influxdb_port = INFLUXDB_PORT;
14 unsigned int localPort = 2390;
16 long unsigned poll_int = POLL_INT;
18 String location = LOCATION;
22 SimpleDHT22 dht22(pinDHT22);
24 TeleInfo teleinfo(&Serial);
30 WiFi.begin(WIFI_SSID, WIFI_PASS);
32 while (WiFi.status() != WL_CONNECTED) {
38 float temperature = 0;
40 int err = SimpleDHTErrSuccess;
41 if ((err = dht22.read2(&temperature, &humidity, NULL)) == SimpleDHTErrSuccess) {
42 sendToInfluxDB("temperature,city="+city+",location="+location, "value", String(temperature));
43 sendToInfluxDB("humidity,city="+city+",location="+location, "value", String(humidity));
47 if(teleinfo.available()){
48 long I1 = teleinfo.getLongVal("IINST1");
49 long I2 = teleinfo.getLongVal("IINST2");
50 long I3 = teleinfo.getLongVal("IINST3");
51 long PAPP = teleinfo.getLongVal("PAPP");
52 long BASE = teleinfo.getLongVal("BASE");
53 sendToInfluxDB("teleinfo,city="+city+",phase=1", "IINST", String(I1));
54 sendToInfluxDB("teleinfo,city="+city+",phase=2", "IINST", String(I2));
55 sendToInfluxDB("teleinfo,city="+city+",phase=3", "IINST", String(I3));
56 sendToInfluxDB("teleinfo,city="+city, "PAPP", String(PAPP));
57 sendToInfluxDB("teleinfo,city="+city, "BASE", String(BASE));
58 teleinfo.resetAvailable();
63 void sendToInfluxDB(String measure, String key, String value) {
64 String line = measure+" "+key+"="+value;
66 Udp.beginPacket(influxdb_ip, influxdb_port);