From 71a3a48af783aaa402d20bdb3c2c4aa1e601ccd0 Mon Sep 17 00:00:00 2001 From: marcel Date: Wed, 13 Mar 2024 11:37:44 +0100 Subject: [PATCH] Si7021 wrap around bug now has a partial workaround --- CHANGELOG.md | 2 +- firmware/weather_station.ino | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ceb581b..0960f38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,7 +78,7 @@ All notable changes to this project will be documented in this file. - Humidity threshold heater is now a define instead of hard coded numbers in the source. -## [0.2.5] - 2024-03-13 +## [0.2.6] - 2024-03-13 ### Fixed diff --git a/firmware/weather_station.ino b/firmware/weather_station.ino index 0a65e16..1f2d033 100644 --- a/firmware/weather_station.ino +++ b/firmware/weather_station.ino @@ -243,7 +243,13 @@ void ReadSi7021 (void) si7021.triggerMeasurement(); si7021.getHumidity(humidity); - if (humidity>100 || humidity<0) + // There is a bug in the Si7021 chip: when the sensor is exposed to extreme environmental conditions for a longer period (very high or very low humidity), + // the humidity register will wrap around and give wrong values. (https://community.silabs.com/s/question/0D51M00007xeOo9SAE/si7021-relative-humidity-reading-underflowing-?language=en_US). + // Workaround: let's assume the humidity will never go below 15%. In the Netherlands a humidity of below 20% is rare, but can occur and the minimum value ever measured + // in De Bilt was 6% (on 1 april 1965). At several other sites in the Netherlands the humidity went as low as 10%. But as this was a one time event and the + // measurements are doubtful, this event was nor registered in the original database. (https://nl.wikipedia.org/wiki/Relatieve_luchtvochtigheid) + // In rare cases, the humidity value could creep up above 15% (when the actual humidity is 100%) and still give wrong values. + if (humidity>100 || humidity<15) humidity = 100; //If humidity is larger than HUMIDITY_THRESHOLD switch on heater to get more acurate measurement and prevent memory offset @@ -259,7 +265,8 @@ void ReadSi7021 (void) //Serial.print(F("Valid temp")); si7021.getHumidity(MeasuredData.Humidity); - if (MeasuredData.Humidity>100 || MeasuredData.Humidity<0) + // See humidity bug workaround above. + if (MeasuredData.Humidity>100 || MeasuredData.Humidity<15) MeasuredData.Humidity = 100; // Scale for more decimal positions when converted to integer value for ModBus MeasuredData.Humidity *= 100; @@ -460,7 +467,7 @@ void setup() { mb.Ireg (SensorRainSinceMidnightIreg, 0); mb.Ireg (SensorSnowFallIreg, 0); - Serial.println(F("Weather station v0.2.5")); + Serial.println(F("Weather station v0.2.6")); Serial.println(F("(C)2024 M.T. Konstapel")); Serial.println(F("This project is free and open source")); Serial.println(F("More details: https://meezenest.nl/mees/"));