Library for NodeMcu / ESP8266 (and Arduino?) for sending measurements to an Influx database.
## Initialization
#define INFLUXDB_HOST "192.168.0.32"
#define INFLUXDB_PORT "1337"
#define INFLUXDB_DATABASE "test"
Influxdb influx(INFLUXDB_HOST, INFLUXDB_PORT);
influx.setDb(INFLUXDB_DATABASE);
Sending a single measurement
Using an InfluxData object:
measurement.addTag("device", d2);
measurement.addTag("sensor", "dht11");
measurement.addValue("value", 24.0);
influx.write(measurement);
Using raw-data
influx.write("temperature,device=d2,sensor=dht11 value=24.0")
Write multiple data points at once
Batching measurements and send them with a single request will result in a much higher performance.
influx.prepare(measurement1)
influx.prepare(measurement2)
influx.prepare(measurement3)
boolean success = influx.write();
Http client error codes
Internally ESP8266HTTPClient
is used.
#define HTTPC_ERROR_CONNECTION_REFUSED (-1)
#define HTTPC_ERROR_SEND_HEADER_FAILED (-2)
#define HTTPC_ERROR_SEND_PAYLOAD_FAILED (-3)
#define HTTPC_ERROR_NOT_CONNECTED (-4)
#define HTTPC_ERROR_CONNECTION_LOST (-5)
#define HTTPC_ERROR_NO_STREAM (-6)
#define HTTPC_ERROR_NO_HTTP_SERVER (-7)
#define HTTPC_ERROR_TOO_LESS_RAM (-8)
#define HTTPC_ERROR_ENCODING (-9)
#define HTTPC_ERROR_STREAM_WRITE (-10)
#define HTTPC_ERROR_READ_TIMEOUT (-11)
...
See list of error codes and list of http status codes.
Documentation
For the documentation see html/class_influxdb.html (only works locally).