fixes, add raw t+h to json

modbus
Ondřej Hruška 3 years ago
parent 30b322fba5
commit ace9fc33d0
  1. 2
      components/bme680/src/bsec2.c
  2. 4
      main/data_report.h
  3. 20
      main/voc_sensor.c
  4. 14
      main/web/websrv.c

@ -329,6 +329,8 @@ static void bsec2_setBme68xConfigForced(struct bsec2 *self) {
conf.os_hum = self->bmeConf.humidity_oversampling;
conf.os_pres = self->bmeConf.pressure_oversampling;
conf.os_temp = self->bmeConf.temperature_oversampling;
// XXX bsec does not use filter, but it shouldn't hurt the algorithm too much and we get better raw values out of it
conf.filter = BME68X_FILTER_SIZE_3;
self->sensor_status = bme68x_set_conf(&conf, self->sensor);
if (BME68X_OK != self->sensor_status) {

@ -24,9 +24,11 @@ struct data_report {
bool thpg_ready;
uint32_t thpg_timestamp;
float temperature;
float temperature_raw;
float pressure;
float humidity;
float gasr;
float humidity_raw;
float gas_raw;
bool co2_ready;
uint32_t co2_timestamp;

@ -157,7 +157,7 @@ static void new_data_callback(
case BSEC_OUTPUT_IAQ:
ESP_LOGI(TAG, "\tIAQ = %f, accuracy %d", output.signal, (int) output.accuracy);
my_report.iaq = output.signal;
my_report.iaq_ready = (3 == (int) output.accuracy);
my_report.iaq_ready = (3 == (int) output.accuracy); // calibration finished
break;
case BSEC_OUTPUT_STATIC_IAQ:
ESP_LOGI(TAG, "\tSTATIC_IAQ = %f, accuracy %d", output.signal, (int) output.accuracy);
@ -176,9 +176,19 @@ static void new_data_callback(
my_report.pressure = output.signal;
my_report.thpg_ready = true;
break;
case BSEC_OUTPUT_RAW_TEMPERATURE:
ESP_LOGI(TAG, "\tRAW_TEMPERATURE = %f", output.signal);
my_report.temperature_raw = output.signal;
my_report.thpg_ready = true;
break;
case BSEC_OUTPUT_RAW_HUMIDITY:
ESP_LOGI(TAG, "\tRAW_HUMIDITY = %f", output.signal);
my_report.humidity_raw = output.signal;
my_report.thpg_ready = true;
break;
case BSEC_OUTPUT_RAW_GAS:
ESP_LOGI(TAG, "\tRAW_GAS = %f", output.signal);
my_report.gasr = output.signal;
my_report.gas_raw = output.signal;
my_report.thpg_ready = true;
break;
case BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE:
@ -207,9 +217,11 @@ static void new_data_callback(
g_data_report.thpg_ready = true;
g_data_report.thpg_timestamp = xTaskGetTickCount();
g_data_report.humidity = my_report.humidity;
g_data_report.humidity_raw = my_report.humidity_raw;
g_data_report.temperature = my_report.temperature;
g_data_report.temperature_raw = my_report.temperature_raw;
g_data_report.pressure = my_report.pressure;
g_data_report.gasr = my_report.gasr;
g_data_report.gas_raw = my_report.gas_raw;
} else {
g_data_report.thpg_ready = false;
}
@ -249,6 +261,8 @@ void voc_read_task(void *param) {
BSEC_OUTPUT_CO2_EQUIVALENT,
BSEC_OUTPUT_BREATH_VOC_EQUIVALENT,
BSEC_OUTPUT_RAW_TEMPERATURE,
BSEC_OUTPUT_RAW_HUMIDITY,
BSEC_OUTPUT_RAW_PRESSURE,
BSEC_OUTPUT_RAW_GAS,

@ -95,7 +95,10 @@ static esp_err_t handler_sample(httpd_req_t *req) {
if (g_data_report.iaq_ready) {
if (timestamp_age(g_data_report.iaq_timestamp) < DATA_MAX_AGE) {
wp += sprintf(wp, "\"iaq\":%.2f,\"iaq_s\":%.2f,\"iaq_co2\":%.2f,\"iaq_voc\":%.2f",
g_data_report.iaq, g_data_report.iaq_static, g_data_report.iaq_co2_ppm_equiv, g_data_report.iaq_co2_ppm_equiv);
g_data_report.iaq,
g_data_report.iaq_static,
g_data_report.iaq_co2_ppm_equiv,
g_data_report.iaq_voc_ppm_equiv);
need_comma = true;
} else {
g_data_report.iaq_ready = false;
@ -104,9 +107,14 @@ static esp_err_t handler_sample(httpd_req_t *req) {
if (g_data_report.thpg_ready) {
if (timestamp_age(g_data_report.thpg_timestamp) < DATA_MAX_AGE) {
wp += sprintf(wp, "%s\"temp\":%.2f,\"hum\":%.2f,\"pres\":%.1f,\"gasr\":%.1f",
wp += sprintf(wp, "%s\"temp\":%.2f,\"temp_r\":%.2f,\"hum\":%.2f,\"hum_r\":%.2f,\"pres\":%.1f,\"gas_r\":%.1f",
need_comma ? "," : "",
g_data_report.temperature, g_data_report.humidity, g_data_report.pressure, g_data_report.gasr);
g_data_report.temperature,
g_data_report.temperature_raw,
g_data_report.humidity,
g_data_report.humidity_raw,
g_data_report.pressure,
g_data_report.gas_raw);
need_comma = true;
} else {
g_data_report.thpg_ready = false;

Loading…
Cancel
Save