3 #include <Adafruit_Sensor.h>
7 #include "salon-config.h"
9 const char* wifi_ssid = WIFI_SSID;
10 const char* wifi_pass = WIFI_PASS;
13 IPAddress influxdb_ip(INFLUXDB_IP);
14 long influxdb_port = INFLUXDB_PORT;
15 unsigned int localPort = 2390;
17 long unsigned poll_int = POLL_INT;
19 String location = LOCATION;
25 DHT_Unified dht(DHTPIN, DHTTYPE);
31 WiFi.begin(WIFI_SSID, WIFI_PASS);
33 while (WiFi.status() != WL_CONNECTED) {
39 dht.temperature().getSensor(&sensor);
40 dht.humidity().getSensor(&sensor);
47 sensors_event_t event;
49 dht.temperature().getEvent(&event);
50 if (isnan(event.temperature)) {
53 sendToInfluxDB("temperature,city="+city+",location="+location, "value", String(event.temperature));
55 dht.humidity().getEvent(&event);
56 if (isnan(event.relative_humidity)) {
59 sendToInfluxDB("humidity,city="+city+",location="+location, "value", String(event.relative_humidity));
64 void sendToInfluxDB(String measure, String key, String value) {
65 String line = measure+" "+key+"="+value;
67 Udp.beginPacket(influxdb_ip, influxdb_port);