|
|
@ -84,14 +84,14 @@ struct __attribute__((packed)) sensor_readings_t { |
|
|
|
uint32_t voc = 0; // Ohm
|
|
|
|
float pm10 = NAN; // µg/m³
|
|
|
|
float pm25 = NAN; // µg/m³
|
|
|
|
float lux = NAN; |
|
|
|
float lux = NAN; // lx
|
|
|
|
float uvi = NAN; |
|
|
|
float uva = NAN; |
|
|
|
float uvb = NAN; |
|
|
|
float temperature_max = NAN; // °C
|
|
|
|
float temperature_min = NAN; // °C
|
|
|
|
int battery = 0; |
|
|
|
int8_t rssi = 0; |
|
|
|
float voltage = NAN; // V
|
|
|
|
int8_t rssi = 0; // dBm
|
|
|
|
time_t lastUpdate = 0; |
|
|
|
} sensor_readings; |
|
|
|
|
|
|
@ -371,11 +371,12 @@ void getSensorMeasurements() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
sensor_readings.battery = analogRead(_VBAT); |
|
|
|
int battery = analogRead(_VBAT); |
|
|
|
sensor_readings.voltage = (battery/4096.0)*2*3.42; |
|
|
|
sensor_readings.rssi = WiFi.RSSI(); |
|
|
|
|
|
|
|
ESP_LOGI(TAG, "RSSI : %5d dBm", sensor_readings.rssi); |
|
|
|
ESP_LOGI(TAG, "Battery : %5d ", sensor_readings.battery); |
|
|
|
ESP_LOGI(TAG, "Battery : %5d ", battery); |
|
|
|
ESP_LOGI(TAG, "Heap : %5lu", ESP.getFreeHeap()); |
|
|
|
|
|
|
|
sensor_readings.lastUpdate = getTimestamp(); |
|
|
@ -417,7 +418,7 @@ void receiveMqtt(const char* topic, const char* data, int data_len) { |
|
|
|
if (jsonDoc.containsKey("uvb")) sensor->uvb = jsonDoc["uvb"].as<float>(); |
|
|
|
if (jsonDoc.containsKey("pm10")) sensor->pm10 = jsonDoc["pm10"].as<float>(); |
|
|
|
if (jsonDoc.containsKey("pm2.5")) sensor->pm25 = jsonDoc["pm2.5"].as<float>(); |
|
|
|
if (jsonDoc.containsKey("voltage")) sensor->battery = jsonDoc["voltage"].as<int>(); |
|
|
|
if (jsonDoc.containsKey("voltage")) sensor->voltage = jsonDoc["voltage"].as<float>(); |
|
|
|
if (jsonDoc.containsKey("rssi")) sensor->rssi = jsonDoc["rssi"].as<int8_t>(); |
|
|
|
if (jsonDoc.containsKey("timestamp")) sensor->lastUpdate = jsonDoc["timestamp"].as<time_t>(); |
|
|
|
ESP_LOGI(TAG, "got new values from %s, timestamp: %lu", topic, sensor->lastUpdate); |
|
|
@ -670,7 +671,7 @@ void sendValues() { |
|
|
|
jsonDoc["pm10"] = sensor_readings.pm10; |
|
|
|
jsonDoc["pm2.5"] = sensor_readings.pm25; |
|
|
|
} |
|
|
|
jsonDoc["voltage"] = sensor_readings.battery; |
|
|
|
jsonDoc["voltage"] = sensor_readings.voltage; |
|
|
|
jsonDoc["rssi"] = sensor_readings.rssi; |
|
|
|
jsonDoc["timestamp"] = sensor_readings.lastUpdate; |
|
|
|
serializeJson(jsonDoc, buf, JSON_BUF_LEN); |
|
|
|