Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid rain statistics values #202

Open
matthias-bs opened this issue Nov 27, 2024 · 15 comments
Open

Invalid rain statistics values #202

matthias-bs opened this issue Nov 27, 2024 · 15 comments

Comments

@matthias-bs
Copy link
Owner

matthias-bs commented Nov 27, 2024

Still a problem, erased memory with Erase All Flash Before Sketch Upload: Enabled, no more ssi in memory, still false rain info ->

data = {"id":43961,"ch":0,"battery_ok":1,"temp_c":10.8,"humidity":96,"wind_gust":3.7,"wind_avg":3.6,"wind_dir":205.0,"uv":0.0,"light_klx":0.3,"rain":994.6,"rain_h":0.0,"rain_d":22940.6,"rain_w":22940.6,"rain_m":22940.6}

Originally posted by @tonbor in #190 (comment)

@matthias-bs
Copy link
Owner Author

@tonbor I need your debug log file to analyze this.

@tonbor
Copy link

tonbor commented Nov 27, 2024

18:54:39.536 -> [115316][D][RainGauge.cpp:194] prefs_load(): lastUpdate =1732730077
18:54:39.568 -> [115323][D][RainGauge.cpp:195] prefs_load(): startupPrev =0
18:54:39.568 -> [115329][D][RainGauge.cpp:196] prefs_load(): rainPreStartup =995.100037
18:54:39.568 -> [115336][D][RainGauge.cpp:197] prefs_load(): tsDayBegin =3
18:54:39.568 -> [115341][D][RainGauge.cpp:198] prefs_load(): rainDayBegin =994.900024
18:54:39.568 -> [115348][D][RainGauge.cpp:199] prefs_load(): tsWeekBegin =3
18:54:39.568 -> [115354][D][RainGauge.cpp:200] prefs_load(): rainWeekBegin =994.900024
18:54:39.605 -> [115361][D][RainGauge.cpp:201] prefs_load(): wdayPrev =3
18:54:39.605 -> [115367][D][RainGauge.cpp:202] prefs_load(): tsMonthBegin =10
18:54:39.605 -> [115373][D][RainGauge.cpp:203] prefs_load(): rainMonthBegin =994.900024
18:54:39.605 -> [115379][D][RainGauge.cpp:204] prefs_load(): rainPrev =2346427760205696598016.000000
18:54:39.637 -> [115388][D][RainGauge.cpp:205] prefs_load(): rainAcc =2346427760205696598016.000000
18:54:39.637 -> [115397][D][RainGauge.cpp:280] update(): rainDelta: 0.0
18:54:39.637 -> [115402][D][RainGauge.cpp:325] update(): t_delta: 1007513408
18:54:39.637 -> [115408][D][RainGauge.cpp:345] update(): hist[9]=0 (upd)
18:54:39.637 -> [115413][D][RainGauge.cpp:383] update(): hist[]={158, -1, 0, 0, -1, 0, 0, 0, 0, 0, }

@tonbor
Copy link

tonbor commented Nov 27, 2024

19:18:59.586 -> [426578][D][RainGauge.cpp:194] prefs_load(): lastUpdate =1732731517
19:18:59.586 -> [426585][D][RainGauge.cpp:195] prefs_load(): startupPrev =1
19:18:59.586 -> [426591][D][RainGauge.cpp:196] prefs_load(): rainPreStartup =17845015893711164469673984.000000
19:18:59.586 -> [426600][D][RainGauge.cpp:197] prefs_load(): tsDayBegin =3
19:18:59.586 -> [426606][D][RainGauge.cpp:198] prefs_load(): rainDayBegin =994.900024
19:18:59.586 -> [426613][D][RainGauge.cpp:199] prefs_load(): tsWeekBegin =3
19:18:59.620 -> [426619][D][RainGauge.cpp:200] prefs_load(): rainWeekBegin =994.900024
19:18:59.620 -> [426625][D][RainGauge.cpp:201] prefs_load(): wdayPrev =3
19:18:59.620 -> [426631][D][RainGauge.cpp:202] prefs_load(): tsMonthBegin =10
19:18:59.620 -> [426637][D][RainGauge.cpp:203] prefs_load(): rainMonthBegin =994.900024
19:18:59.620 -> [426644][D][RainGauge.cpp:204] prefs_load(): rainPrev =17847362088973039403270144.000000
19:18:59.661 -> [426653][D][RainGauge.cpp:205] prefs_load(): rainAcc =2346427760205696598016.000000
19:18:59.661 -> [426661][D][RainGauge.cpp:280] update(): rainDelta: -17845015893711164469673984.0
19:18:59.661 -> [426669][D][RainGauge.cpp:325] update(): t_delta: 1007513408
19:18:59.661 -> [426675][D][RainGauge.cpp:345] update(): hist[3]=0 (upd)
19:18:59.661 -> [426680][D][RainGauge.cpp:383] update(): hist[]={0, 0, -1, 0, -1, 0, 0, 0, 0, 0, }

@matthias-bs
Copy link
Owner Author

Which SLEEP_INTERVAL did you set?

@tonbor
Copy link

tonbor commented Nov 27, 2024

non, comment out sleep

@matthias-bs
Copy link
Owner Author

What is the interval between messages containing valid rain values then? The short log snippets you provided do not show this.

@tonbor
Copy link

tonbor commented Nov 27, 2024

Will look in my source tomorrow. Did buy Heltec T190 with sx1262, will adjust source and adjust config file for this board. See if get the same outcome for rain and not blocking messages from other source then my weatherstation and Bresser sensors.

@matthias-bs
Copy link
Owner Author

Another - most likely - cause for the wrong rain values could be the reception of another weather sensor's rain value (or some radio signal which is misinterpreted as that).
See #200.

To check this, please have a look at the message decoding in the debug log.

@tonbor
Copy link

tonbor commented Nov 28, 2024

Well I have at the monent two readers running. One compiled half year ago a Heltec V3 sx1262. With yet correct readings.
ESPWeather-3275F8
status = online
abb9
data = {"id":43961,"ch":0,"battery_ok":1,"temp_c":7.7,"humidity":81,"wind_gust":0.0,"wind_avg":0.0,"wind_dir":318.0,"uv":0.6,"light_klx":9.6,"rain":997.2,"rain_h":0.0,"rain_d":1.6,"rain_w":18.1,"rain_m":101.6}
rssi v3 = -97.0
extra = {"wind_dir_txt":"NW","wind_gust_bft":0,"wind_avg_bft":0,"dewpoint_c":4.7,"perceived_temp_c":7.7}
radio = {"rssi":-96.5}
72181262
data = {"id":1914180194,"ch":4,"battery_ok":1,"temp_c":14.9,"humidity":59,"uv":44.4}
rssi v3 = -93.5
18839309
data = {"id":411276041,"ch":2,"battery_ok":1,"temp_c":8.50,"moisture":99}
rssi v3 = -98.0
80339449
data = {"id":2150863945,"ch":3,"battery_ok":1,"temp_c":8.50,"moisture":87}
rssi v3 = -95.0

One yesterday compiled with the latest Bresser update an ESP32 S3 with RW95 (sx1276) with now wrong rain readings and multi readings channels. Before the compiler update it was working fine.
ESPWeather2-33737C
status = online
radio = {"rssi":-91.5}
80339449
data = {"id":2150863945,"ch":3,"battery_ok":1,"temp_c":8.50,"moisture":87}
rssi v3 = -112.5
5a8
data = {"id":1448,"ch":5,"battery_ok":1}
rssi v3 = -0.0
2bee7b91
data = {"id":737049489,"ch":22,"battery_ok":1}
rssi v3 = -894684972974079.9
80280f
data = {"id":8398863,"ch":151,"battery_ok":1}
rssi v3 = 205412521519716761986.2
630dc9b
data = {"id":103865499,"ch":246,"battery_ok":1}
rssi v3 = 221.1
32cee9c2
data = {"id":852421058,"ch":249,"battery_ok":1}
rssi v3 = -0.0
abb9
data = {"id":43961,"ch":0,"battery_ok":1,"temp_c":8.1,"humidity":79,"wind_gust":0.0,"wind_avg":0.0,"wind_dir":288.0,"uv":0.0,"light_klx":7.2,"rain":997.2,"rain_h":0.0,"rain_d":0.0,"rain_w":-2023174684709762694012624706374.4,"rain_m":-2023174684709762694012624706374.4}
rssi v3 = -93.0
extra = {,"dewpoint_c":7.0,"perceived_temp_c":14.9}
72181262
data = {"id":1914180194,"ch":4,"battery_ok":1,"temp_c":14.9,"humidity":59,"uv":44.4}
rssi v3 = -108.5

@tonbor
Copy link

tonbor commented Nov 28, 2024

debug:10:30:28.152 -> [181904][D][WeatherSensor.cpp:351] getMessage(): [SX1276] R [D4] RSSI: -91.5
10:30:28.152 -> [181911][D][WeatherSensor.h:598] log_message(): Byte #: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
10:30:28.152 -> [181924][D][WeatherSensor.h:608] log_message(): De-whitened Data: 99 08 AB B9 23 90 B2 00 00 00 00 99 72 04 08 10 80 00 84 04 00 70 00 00 00 AA
10:30:28.152 -> [181937][D][WeatherSensorDecoders.cpp:105] findSlot(): sensor[0]: v=0 id=0x0000ABB9 t=1 c=0
10:30:28.305 -> decode_ok for get weather Data
10:30:28.305 -> start publishWeatherdata
10:30:28.305 -> [181951][D][RainGauge.cpp:194] prefs_load(): lastUpdate =1732786212
10:30:28.305 -> [181958][D][RainGauge.cpp:195] prefs_load(): startupPrev =1
10:30:28.305 -> [181964][D][RainGauge.cpp:196] prefs_load(): rainPreStartup =-18338.847656
10:30:28.305 -> [181971][D][RainGauge.cpp:197] prefs_load(): tsDayBegin =4
10:30:28.305 -> [181977][D][RainGauge.cpp:198] prefs_load(): rainDayBegin =-2023174684709762525546554589184.000000
10:30:28.305 -> [181986][D][RainGauge.cpp:199] prefs_load(): tsWeekBegin =3
10:30:28.305 -> [181992][D][RainGauge.cpp:200] prefs_load(): rainWeekBegin =994.900024
10:30:28.305 -> [181999][D][RainGauge.cpp:201] prefs_load(): wdayPrev =4
10:30:28.305 -> [182004][D][RainGauge.cpp:202] prefs_load(): tsMonthBegin =10
10:30:28.306 -> [182010][D][RainGauge.cpp:203] prefs_load(): rainMonthBegin =994.900024
10:30:28.306 -> [182017][D][RainGauge.cpp:204] prefs_load(): rainPrev =-2023174684709762525546554589184.000000
10:30:28.306 -> [182027][D][RainGauge.cpp:205] prefs_load(): rainAcc =-2023174684709762525546554589184.000000
10:30:28.306 -> [182036][D][RainGauge.cpp:280] update(): rainDelta: 0.0
10:30:28.306 -> [182041][D][RainGauge.cpp:325] update(): t_delta: 1007513392
10:30:28.306 -> [182047][D][RainGauge.cpp:345] update(): hist[5]=0 (upd)
10:30:28.306 -> [182052][D][RainGauge.cpp:383] update(): hist[]={-1, -1, -1, -1, -1, 0, -1, -1, -1, -1, }
10:30:28.334 -> start publishWeatherdata 2
10:30:30.631 -> Channel: 0
10:30:30.631 -> domoticz/in: {"idx":10502,"nvalue":0,"svalue":"8.1;80;0"}
10:30:30.631 -> domoticz/in: {"idx":10499,"nvalue":0,"svalue":"239.0;WSW;0.0;0.0;8.1;8.1"}
10:30:30.631 -> domoticz/in: {"idx":10501,"nvalue":0,"svalue":"0.0;997.2"}

@matthias-bs
Copy link
Owner Author

matthias-bs commented Nov 30, 2024

We'd need more debug output like

data = {"id":43961,"ch":0,"battery_ok":1,"temp_c":7.7,"humidity":81,"wind_gust":0.0,"wind_avg":0.0,"wind_dir":318.0,"uv":0.6,"light_klx":9.6,"rain":997.2,"rain_h":0.0,"rain_d":1.6,"rain_w":18.1,"rain_m":101.6}

and the parameters passed to rainGauge.update() to see what is going on.
Another thing to be checked is if the real time clock is running correctly.

@tonbor
Copy link

tonbor commented Nov 30, 2024

A brand new Heltec T190 and this is the rain start
abb9
data = {"id":43961,"ch":0,"battery_ok":1,"temp_c":6.1,"humidity":80,"wind_gust":0.0,"wind_avg":0.0,"wind_dir":168.0,"uv":0.0,"light_klx":3.9,"rain":997.2,"rain_h":0.0,"rain_d":0.0,"rain_w":987.3,"rain_m":987.3}
rssi = -104.5
debug see #203

@matthias-bs
Copy link
Owner Author

@tonbor I noticed from a GitHub mail that you reported that the issue was caused by an unstable power supply, but I cannot find your comment in any of the issues you created. Can this issue be closed then?

@tonbor
Copy link

tonbor commented Dec 3, 2024

Well the problem is starting the first time reading the sensor when the sensor has a value from the past and the module has none. Then hour, day week and month gets the wrong values.

@matthias-bs
Copy link
Owner Author

matthias-bs commented Dec 4, 2024

The software should handle this correctly:

  • At a fresh start (reset command received or Flash erased), all entries are as in valid and the current rain gauge value and the timestamps are stored. From this point on, the values are calculated.

  • If there are values from a previous run stored in the flash, the algorithm will assume that it should proceed from there, i.e. use the stored timestamps and rain gauge values as if recorded previously (from the same sensor!). This includes some tricks to handle potential resets (battery change) and counter overflow of the rain gauge.

See https://github.com/matthias-bs/BresserWeatherSensorReceiver/wiki/04.-Implementing-Rain-Gauge-Statistics

Since I'm implemented some unit tests for this part of the software (which are run as GitHub actions CI), nobody else reported any problems and I use the library in my own projects, I assume that it works correctly.

The only thing which is not quite correct is the handling of pasthour() in the example code:

float pastHour(bool *valid = nullptr, int *quality = nullptr);

You should pass a pointer to a bool valid; variable to it and use the function's return value only if valid is true.

Besides, I am quite confused by the mix of information you provided - three issues, different boards, library versions, IDE versions, example codes snippets (MQTT vs. Domoticz), power supply issues, ...

I you still think there is a SW issue (I don't say this is impossible...), please provide a complete log file spanning over a few transmission cycles, with accurate information (as requested in the issue templates) and point me in the right direction... Otherwise I'm not inclined to spend my spare time on analyzing small bits of the big picture...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants