From 3234da3a3164c1340da10b3b15286d116d1a57dc Mon Sep 17 00:00:00 2001 From: ManuelW Date: Mon, 5 Mar 2018 20:45:13 +0100 Subject: [PATCH] Update sensor.ino Add support for humidity correction --- code/espurna/sensor.ino | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/espurna/sensor.ino b/code/espurna/sensor.ino index 9ffa7ceb..fa9e7db8 100644 --- a/code/espurna/sensor.ino +++ b/code/espurna/sensor.ino @@ -35,6 +35,7 @@ unsigned long _sensor_read_interval = 1000 * SENSOR_READ_INTERVAL; unsigned char _sensor_report_every = SENSOR_REPORT_EVERY; unsigned char _sensor_temperature_units = SENSOR_TEMPERATURE_UNITS; double _sensor_temperature_correction = SENSOR_TEMPERATURE_CORRECTION; +double _sensor_humidity_correction = SENSOR_HUMIDITY_CORRECTION; // ----------------------------------------------------------------------------- // Private @@ -50,6 +51,9 @@ double _magnitudeProcess(unsigned char type, double value) { if (_sensor_temperature_units == TMP_FAHRENHEIT) value = value * 1.8 + 32; value = value + _sensor_temperature_correction; } + if (type == MAGNITUDE_HUMIDITY) { + value = value + _sensor_humidity_correction; + } return roundTo(value, _magnitudeDecimals(type)); } @@ -111,6 +115,7 @@ void _sensorWebSocketStart(JsonObject& root) { //root["apiRealTime"] = _sensor_realtime; root["tmpUnits"] = _sensor_temperature_units; root["tmpCorrection"] = _sensor_temperature_correction; + root["humCorrection"] = _sensor_humidity_correction; root["snsRead"] = _sensor_read_interval / 1000; root["snsReport"] = _sensor_report_every; } @@ -481,6 +486,7 @@ void _sensorConfigure() { _sensor_realtime = getSetting("apiRealTime", API_REAL_TIME_VALUES).toInt() == 1; _sensor_temperature_units = getSetting("tmpUnits", SENSOR_TEMPERATURE_UNITS).toInt(); _sensor_temperature_correction = getSetting("tmpCorrection", SENSOR_TEMPERATURE_CORRECTION).toFloat(); + _sensor_humidity_correction = getSetting("humCorrection", SENSOR_HUMIDITY_CORRECTION).toFloat(); // Update filter sizes for (unsigned char i=0; i<_magnitudes.size(); i++) {