weatherstation/firmware/influxdb.ino

26 lines
1.2 KiB
C++
Executable file

void pushToInfluxDB(String device, float sensorValues[]) {
/*influxdb.write("weather,device=" + device + " temperature=" + String(sensorValues[SENSOR_TEMPERATURE]));
influxdb.write("weather,device=" + device + " humidity=" + String(sensorValues[SENSOR_HUMIDITY]));
influxdb.write("weather,device=" + device + " light=" + String(sensorValues[SENSOR_LIGHT]));
influxdb.write("weather,device=" + device + " windspeed=" + String(sensorValues[SENSOR_WINDSPEED]));
influxdb.write("weather,device=" + device + " pressure=" + String(sensorValues[SENSOR_PRESSURE]));
influxdb.write("weather,device=" + device + " batvoltage=" + String(sensorValues[SENSOR_BAT_VOLTAGE]));*/
String msg = "weather,device=" + device + " temperature=" + String(sensorValues[SENSOR_TEMPERATURE])
+ ",humidity=" + String(sensorValues[SENSOR_HUMIDITY])
+ ",light=" + String(sensorValues[SENSOR_LIGHT])
+ ",windspeed=" + String(sensorValues[SENSOR_WINDSPEED])
+ ",pressure=" + String(sensorValues[SENSOR_PRESSURE])
+ ",batvoltage=" + String(sensorValues[SENSOR_BAT_VOLTAGE]);
uint8_t tries = 0;
do {
tries++;
influxdb.write(msg);
} while (influxdb.response() != DB_SUCCESS and tries < 5);
}