Fixed bug rain meter and luminosity meter

master
marcel 4 days ago
parent 3d980ab38a
commit dd272cfffc
  1. 16
      CHANGELOG.md
  2. 2
      TODO.md
  3. 11
      firmware/weather_station.ino

@ -110,3 +110,19 @@ Support for si7021 humidity sensor (this sensor was not suited for outdoor measu
- Debug messages can be switched on and off with the _DEBUG_ variable
- SEN0562 luminosity sensor
## [0.3.2] - 2025-01-26
### Fixed
The first hour, the ModBus register SensorRainIreg is instable. This is because in setup(), the variable RainPerHourCounter is set to the current millis() value. The RainPerHourCounter is the index for the array RainPerHour, which can hold 24 values. But the index is set to the millis() value, which can have a value abouve 23. This causes a buffer overflow. After the first hour, the index is reset and from thereon the register SensorRainIreg holds the proper rainfall value. The solution is that the variable HourTimer should be set to the current millis() value in setup().
```
-- ts = millis();
-- RainPerHourCounter = ts;
++ ts = millis();
++ HourTimer = ts;
```
Buffer roll over luminosity sensor. This happened because the raw value was mutiplied by 100. But that was wrong: copied this section of the code from the temperature sensor code, which uses this mutiply by 100 to gain precision.

@ -1,6 +1,6 @@
# Todo list for weather station with ModBus over RS-485
## Bug in rain meter register
## Bug in rain meter register [done - 2024-01-26]
The first hour, the ModBus register SensorRainIreg is instable. This is because in setup(), the variable RainPerHourCounter is set to the current millis() value. The RainPerHourCounter is the index for the array RainPerHour, which can hold 24 values. But the index is set to the millis() value, which can have a value abouve 23. This causes a buffer overflow. After the first hour, the index is reset and from thereon the register SensorRainIreg holds the proper rainfall value. The solution is that the variable HourTimer should be set to the current millis() value in setup().

@ -42,6 +42,9 @@
* the circuitry and is therefore about 1.5 degrees above ambient temperature. The BMP280 does not heat up.
* - Added SEN0562 luminosity sensor
*
* 2025-01-26: - Bug rainmeter fixed
* - Bug luminosity sensor fixed
*
* See CHANGELOG.md
*
**********************************************************************************/
@ -241,11 +244,11 @@ void ReadSEN0562()
ReadSEN0562_register(0x10, buf); //Register address 0x10
data = buf[0] << 8 | buf[1];
MeasuredData.Luminosity = (((float)data )/1.2)*100;
MeasuredData.Luminosity = ((float)data )/1.2;
if (_DEBUG_) {
Serial.print("SEN0562 light intensity: ");
Serial.print(MeasuredData.Luminosity/100);
Serial.print(MeasuredData.Luminosity);
Serial.println(" Lux");
}
}
@ -439,7 +442,7 @@ void setup() {
mb.Ireg (SensorRainSinceMidnightIreg, 0);
mb.Ireg (SensorSnowFallIreg, 0);
Serial.println(F("Weather station v0.3.1"));
Serial.println(F("Weather station v0.3.2"));
Serial.println(F("(C)2024-2025 M.T. Konstapel"));
Serial.println(F("This project is free and open source"));
Serial.println(F("More details: https://meezenest.nl/mees/"));
@ -534,7 +537,7 @@ void setup() {
weatherMeterKit.begin();
ts = millis();
RainPerHourCounter = ts;
HourTimer = ts;
}
void loop() {

Loading…
Cancel
Save