Si7021 wrap around bug now has a partial workaround

master
marcel 2 months ago
parent 33a5bbbc24
commit 71a3a48af7
  1. 2
      CHANGELOG.md
  2. 13
      firmware/weather_station.ino

@ -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

@ -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/"));

Loading…
Cancel
Save