Compare commits

...

2 commits

Author SHA1 Message Date
Kai Lauterbach
1e534bf86a Added missing influxDB v1 implementation 2022-05-16 22:29:28 +02:00
Kai Lauterbach
6109a2901d Fixed windspeed calculation radius value. 2022-05-16 22:28:42 +02:00
2 changed files with 80 additions and 2 deletions

View file

@ -27,7 +27,7 @@
#define WIFI_MINIMUM_SIGNAL_QUALITY 10 // percent
#define RESET_ESP_TIME_INTERVAL_MS 3600000
#define ROTOR_LENGTH_KM 0.000115
#define ROTOR_LENGTH_KM 0.000016 // 1.6cm
#define WIND_SENSOR_MEAS_TIME_S 5.0
#define SEC_TO_HOUR_FACTOR (60.0 * 60.0)
#define COUNT_TO_KMH ((TWO_PI * ROTOR_LENGTH_KM / WIND_SENSOR_MEAS_TIME_S) * SEC_TO_HOUR_FACTOR)

View file

@ -2,7 +2,85 @@
#include "config_user.h"
#if INFLUXDB_VERSION == 2
#if INFLUXDB_VERSION == 1
Influxdb _influxdb(INFLUXDB_HOST, INFLUXDB_PORT);
void influxdb_begin() {
// Init variables to influxdb config - doesn't talk to database
_influxdb.opendb(INFLUXDB_DB, INFLUXDB_USER, INFLUXDB_PASS);
}
void pushToInfluxDB(String device, float sensorValues[]) {
uint8_t tries = 0;
boolean addComma = false;
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;
}
debug(msg);
do {
tries++;
_influxdb.write(msg);
} while (_influxdb.response() != DB_SUCCESS and tries < 5);
}
#elif INFLUXDB_VERSION == 2
// Data point
Point sensor(DEVICE_NAME);