2018-06-23 20:13:33 +02:00
|
|
|
|
2017-11-20 20:15:14 +01:00
|
|
|
void pushToInfluxDB(String device, float sensorValues[]) {
|
2018-06-23 20:13:33 +02:00
|
|
|
|
2019-02-02 13:58:47 +01:00
|
|
|
uint8_t tries = 0;
|
|
|
|
boolean addComma = false;
|
2018-07-12 22:30:30 +02:00
|
|
|
|
2019-02-02 13:58:47 +01:00
|
|
|
String msg = "weather,device=" + device + " ";
|
|
|
|
if (!(isnan(sensorValues[SENSOR_TEMPERATURE])))
|
|
|
|
{
|
|
|
|
msg += "temperature=" + String(sensorValues[SENSOR_TEMPERATURE]);
|
|
|
|
addComma = true;
|
|
|
|
}
|
|
|
|
if (!(isnan(sensorValues[SENSOR_HUMIDITY])))
|
|
|
|
{
|
|
|
|
if (true == addComma)
|
|
|
|
msg += ",";
|
|
|
|
msg += "humidity=" + String(sensorValues[SENSOR_HUMIDITY]);
|
|
|
|
addComma = true;
|
|
|
|
}
|
|
|
|
if (!(isnan(sensorValues[SENSOR_LIGHT])))
|
|
|
|
{
|
|
|
|
if (true == addComma)
|
|
|
|
msg += ",";
|
|
|
|
msg += "light=" + String(sensorValues[SENSOR_LIGHT]);
|
|
|
|
addComma = true;
|
|
|
|
}
|
|
|
|
if (!(isnan(sensorValues[SENSOR_WINDSPEED])))
|
|
|
|
{
|
|
|
|
if (true == addComma)
|
|
|
|
msg += ",";
|
|
|
|
msg += "windspeed=" + String(sensorValues[SENSOR_WINDSPEED]);
|
|
|
|
addComma = true;
|
|
|
|
}
|
|
|
|
if (!(isnan(sensorValues[SENSOR_PRESSURE])))
|
|
|
|
{
|
|
|
|
if (true == addComma)
|
|
|
|
msg += ",";
|
|
|
|
msg += "pressure=" + String(sensorValues[SENSOR_PRESSURE]);
|
|
|
|
addComma = true;
|
|
|
|
}
|
|
|
|
if (!(isnan(sensorValues[SENSOR_BAT_VOLTAGE])))
|
|
|
|
{
|
|
|
|
if (true == addComma)
|
|
|
|
msg += ",";
|
|
|
|
msg += "batvoltage=" + String(sensorValues[SENSOR_BAT_VOLTAGE]);
|
|
|
|
addComma = true;
|
|
|
|
}
|
|
|
|
if (!(isnan(sensorValues[SENSOR_ESAVEMODE])))
|
|
|
|
{
|
|
|
|
if (true == addComma)
|
|
|
|
msg += ",";
|
|
|
|
msg += "esavemode=" + String(sensorValues[SENSOR_ESAVEMODE]);
|
|
|
|
addComma = true;
|
|
|
|
}
|
|
|
|
if (!(isnan(sensorValues[SENSOR_BATCHARGESTATE])))
|
|
|
|
{
|
|
|
|
if (true == addComma)
|
|
|
|
msg += ",";
|
|
|
|
msg += "batchargestate=" + String(sensorValues[SENSOR_BATCHARGESTATE]);
|
|
|
|
addComma = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2019-01-27 16:29:58 +01:00
|
|
|
Serial.println(msg);
|
2019-02-02 13:58:47 +01:00
|
|
|
#endif
|
2019-01-27 16:29:58 +01:00
|
|
|
|
2018-07-12 22:30:30 +02:00
|
|
|
do {
|
2019-02-02 14:59:00 +01:00
|
|
|
tries++;
|
2019-02-02 13:58:47 +01:00
|
|
|
influxdb.write(msg);
|
2018-07-12 22:30:30 +02:00
|
|
|
} while (influxdb.response() != DB_SUCCESS and tries < 5);
|
2019-02-02 14:59:00 +01:00
|
|
|
}
|