-
Notifications
You must be signed in to change notification settings - Fork 89
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
Weather wind speed false value #234
Comments
I wrote a new fork to capture polls at 4Hz and generate accurate gust and average wind speed values once per minute on the second core. I think I reused a lot of the maths, but the collection code was all different. I occasionally got truly massive wind speeds, but could not see a reason why. I ended up putting some logic in the processing code where if > (highest ever recorded wind speed + a bit) then drop reading and also log a return value that there was an error so I could look into it more. This fixed the problem in the logged data as you would expect, but weirdly never returned an error. I haven't been back to the code since then, but I suppose my point is, it could be the code or maybe it's hardware a bit like button debouncing. Either way a quick fix is to drop any ridiculous readings to not pollute your data and perhaps return some debug information about what intermediate values were generated to help understand the error. |
Hey Stephen, I've found your gust_wind_multicore_polling branch on your fork. It looks interesting! I'll have to have a closer look another day. I realise I could remove the erroneous readings in post - but I wonder if they're an indication of an underlying issue? I was going to take a deeper look into how this code operates but at first glance it's not how I would have written it. For example, if you had two ticks 1ms apart then nothing for the rest of 1000ms - the average time between ticks would be 1ms and report as a windspeed of 1 tick per ms. But I think a more sensible value would be 2 ticks in 1000ms aka 0.002 ticks per ms. As I thought about that I realised - in this use case it's probably not the root cause because the anemometer has physical intertia and rotation, so I think it's reasonable to assume that the ticks will be more or less evenly spaced over a short sample time. So perhaps it is a hardware issue - I still don't think the way it's done at the moment is how I would do it - but I'd like to test it out a bit to understand what exactly is going on there, as at the moment I don't really understand why they've done it that way. |
I think that this is a timing artifact, I've seen it a number of times, but not yet managed to hunt it down. I think that it happens only on the hour readings though, which leads to my belief that the timing of the ticks is reset on the hour, so in this case 17:00 would be the 0 point for timing. This leads to issues if the wakeup happens slightly earlier than the hour, so you get a reading taken at 16:59:59.0 for example, and you get a ms value of 3599000 as your first tick, your second is then at 1000 (tick is at 17:00:01.0). The calculation then uses a time of -3598000 as the time between the ticks. I did try to add logging to try and catch this edge case and to work out what was going on, but it was always wiped before I got to the device due to the limited storage for logs. I've not got any of my devices up and logging at the moment, and don't have time to play more, which is frustrating. I wish Pimoroni would have done more trouble shooting these, as I love the form factor and the idea behind them, and would have loved to have had a new version based on the Pimoroni Pico Plus 2 W. |
For reference these are the surrounding data points:
and
Hey @MrDrem, I think I understand what you mean. But I see two problems with it being a tick rollover issue
I think the rollover you describe happens if you use standard mathematical operators instead of
How often did you see it happen for you? How often were you recording data? I share in your frustration but I've seen improvements even by updating to v0.2.0 from what was preloaded - so hopefully it will continue to improve. I heard the Pico 2 was pin-compatible? Maybe Pimoroni could upgrade to Pico 2 without much difficulty? |
My setup
I'm running the latest release (v0.2.0) on the weather board.
Recording every 5 minutes and sending every reading to an MQTT broker.
Using the DFRobot's Weather Station Kit with Anemometer/Wind Vane/Rain Bucket from The Pi Hut
The problem
I've had it running for about 2 weeks now and twice I've had readings of 958.8141 m/s
I'm not sure the anemometer would have survived spinning at almost 3 times the speed of sound... so I think maybe that reading was wrong... XD
I had excatly the same number both times (958.8141)
The code
The relevant code is enviro/boards/weather.py lines 110-126
Working this backwards from an output of 958.8141 means there was a
rotation_hz
value of 1000 and anaverage_tick_ms
value of 0.5I don't know what
len(ticks)
would have been but it was at least 2If it was 2 then
time.ticks_diff(ticks[-1], ticks[0])
would have been 0.5, if it was higher than 2 thentime.ticks_diff(ticks[-1], ticks[0])
would be higher tooI'm not sure if
time.ticks_diff(ticks[-1], ticks[0])
should be an integer or not but the first integer value would be 4 with alen(ticks)
value of 3The text was updated successfully, but these errors were encountered: