ESP8266 + InfluxDB + OLED DIsplay and DHT22

03 Dec 2017 [ Blog  ]

Basicly just put together from Examples.

Sending data tu InfluxDB was little bit tricky using HTTPClient and POST method for InfluxDB.


HTTPClient client;
char server[] = "";

//Create Strings from float temperatures
String s_t1 = String(t1);
String s_t2 = String(t2);
String s_h1 = String(h1);
String s_h2 = String(h2);

// Send data to influxDB directly
// Prepare line for POST method 
// Just Add any tags you like
// This line create measurement AirSensor and send 4 values (t1,t2,h1,h2) with some simple tags
line = String("AirSensor,location=home,room=livingroom t1=" + s_t1 + ",t2=" + s_t2 + ",h1=" + s_h1 + ",h2=" + s_h2);

// Create connection to our server and use influx database called sensors
// Run CREATE DATABASE sensors; on your influxdb server
client.begin(server, 8086, "/write?db=sensors");
// Debug only
// Make a HTTP request:
client.addHeader("Content-Type", "application/x-www-form-urlencoded");
int httpcode = client.POST(line);

So, simple one. I’m putting it here just becouse it was not easy to find good example of posting data directly to influxDB.


Sample Grafana Dashboard