-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Lux and UV incorrect for Cotech 36-7959 #2073
Comments
It was added from #1575 with 67ee1d6 and is 16 (or 17?) bit, noted to reach 200.000? https://github.com/merbanan/rtl_433/blob/master/src/devices/cotech_36_7959.c#L42
So top bit of
Can you modify your source code, recompile and test? @andrewpile can you double-check that line? |
Recompiled, will test and report back tomorrow when the sun comes up to see how it behaves. I've tried some test samples, but they don't look promising. While one of my samples does decode over 69627 (77661 to be exact), all my other samples had lower values and all the samples in rtl_433_tests now decode as 131067 instead of 69627, which is suspicious. Additionally, it seems that UV index is scaled by 10 so it might be a good idea to map it as a float, but I'll test this out as well. |
It's been a long time since I looked at this, but the origins of this code were always a little suspicious and undocumented, so I suspect it needs more research. |
As expected, lux values are now capped at 131069, all those below are properly decoded.
The lux value is not a 16-bit integer. We do have a few spare bits of unknown purpose (block J), could they belong here? My knowledge of C and bitwise operation is limited, how would I go about testing this? |
Record some samples and their corresponding reading from the official receiver. Then we can look for what bits belong to what value. |
Even better add |
The console displays higher values as klux, the following samples should be either 164.4 klux or 164.9 klux (although I'm not absolutely certain about the last one).
|
Before I forget, the UV value is indeed scaled by 10, ranges from 0 to 150, so it should be formatted as a float to avoid confusion (to prevent UV 0.9 being interpreted as UV 9). The original display console rounds this value up and only displays 0-15. |
The value of
|
I'll see what I can do, might take a while because they have to be in a precise range. I have a bunch of eligible samples, but not their expected values. |
Here's a few I managed to force with a flashlight, they're the best I can do today.
|
If you need values that properly decode across the entire range, I have plenty of that.
|
Oh, those all have |
If it's overflowing, there's a chance that the light value is broadcast in a different message? |
Am I completely misreading this or is there a different package before the main one which we decode?
*** Saving signal to file g001_433.92M_250k.cu8 (99015 samples, 262144 bytes) |
Yes, in the spectrogram (https://triq.org/pdv/) and looking at the data it very much looks like a proper transmission. And it's already a valid Manchester decode. |
Oh and the original author of the decoder knew that too ;) https://github.com/merbanan/rtl_433/blob/master/src/devices/cotech_36_7959.c#L57-L62 |
Not a problem capturing them, I have them from my tests above (when light_lux goes into overflow). |
Here's that batch, in transmission order, along with the expected values of klux.
EDIT: corrected second value. |
Sorry, false alarm. Those are identical packets, just shifted one bit. I should have checked that first. |
Okay, how about this? On every other (unrepeated) package, I get the 25-28 extra rows:
*** Saving signal to file g013_433.92M_250k.cu8 (66156 samples, 262144 bytes) |
Ignore, it's just a wrong guess by the analyzer. This is getting really weird. The data has to be somewhere in the package because it gets regularly updated every 15 seconds along with all other data. |
klux is derived from the UV value. I played around with it a bit and found that the formula (131000 + (UV * 491) ) / 1000 gets the same klux values as reported (after rounding). The constants could be further tuned or confirmed with values closer to the point of lux overflow. |
It's certainly good to extract what the official receiver sees. This rant is slightly off (illuminance vs irradiance, rather than illuminance vs UV index), but might be useful in understanding that converting UV to lux is an unsound hack, even if equipment manufacturers are willing to do it. |
Interesting! Yeah, it’s likely a hack, but personally knowing nothing about the properties of the sensors I’d want more data before deciding how bad of a hack it is. It would be interesting to see how a camera lens UV filter in front of the sensors affected the readings. |
I'll test this out, I should have an UV filter somewhere.
As far as I can see, there's actually just the UV sensor in the window on the integrated sensor unit and, to be fair, the manufacturer does specify in the manual that the accuracy and resolution for UV index are ±1, while "sunlight" has ±15% accuracy and resolution. Additionally, this would explain why I was unable to establish a fixed conversion factor between w/m2 and lux. Rounding errors. |
In any case, what would be our best course of action in regards to RTL_433? |
Matching the official receiver is fine, unless it does really strange things. |
But do I get it right that when the sensor maxes out it just makes up values together with the UV index ? |
Seems to still be problematic. I have a NicetyMeter 0310 which send LUX and UV but the values read by rtl_433 do not match the values on the display. |
I think we did confirm that the 17th bit is the top most of the flags (b[7]), i.e. we should change to this
And we know that the reading tops out at maybe And maybe we could use anthyz' formula Is that summary correct? |
I myself can't answer because I don't really understand the code. |
Can you run
|
Values reported by rtl_443 or shown on the weather station tablet itself? (on the tablet currently I have 78.0k lux) |
Just any low value to confirm and document the 17th bit. No need for any exact value. |
Here's a small list of readings:
|
Looks like the Light and UV values are flagged as invalid because the UV value is implausible. What about the UV values? Do those map to anything sensible? If those are legit light values below 65535 then the TOPBITS field should show 0 not 8. Something is still wrong. |
@zuckschwerdt: this line is wrong better to replace by:
uv is scale 10 and from 0 to 15 so raw max uv is 150. Therefore, the final value must be also corrected and * 0.1f.
|
With this formula for klux :
I got this, is it correct ?
Notice that the UV and Light values are still high here but aligned but did not help to find the 17th topbit / MSB. But, from this older post here we have the confirmation of the TOPBIT is at b[7] & 0x80, here = 0 for Light = 75 lux & uv = 0 UVI, again aligned. See last 2 lines in bitbench So, I guess we have all information, just confirm the klux values based on the uv formula are more or less accurate, at least be same as on the weather station display. More details about the error codes from this sensor that could be managed by rtl_433. |
Thanks! I somehow missed that info from biuklija. The n/a value in the examples we have seems to be The light and uv fix is now commited. But please confirm the table above is correct. The error codes are very detailed, we should at least copy that to the docs. |
|
I was not near the weather station display to check what readings it's showing there but I'll collect another set of readings these days when I can also see the display, and get back. |
Try to use a fresh version of rtl_433, the latest findings are already included now and values up to 131k should match perfectly. |
Thanks. Do I need to build one myself or can I find it somewhere already built? |
New builds should be available at https://github.com/merbanan/rtl_433/releases/tag/nightly in about 10-20 minutes. |
I've been running the nightly build since this morning. The lux values are spot-on up to 131069lux. Seems that is the max value rtl_433 would report. The UV is a bit off too. Sometimes they match, but most of the time rtl_433 show a value lower by 1 than what the tablet shows.
Let me know if some more data is needed. |
The UV index from rtl_433 should be a float with one decimal digit. Is it maybe a rounding error? |
It's a rounding error indeed. rtl_433 reads the float value, however the MQTT auto-discovery add-on is doing the rounding:
|
Ah, ok. That should be |
Do I open some separate ticket for it? |
I've just put that change in now with #2913 |
Thanks alot! |
We have anthyz' formula |
I'd say it makese sense to have the same data as provided by the tablet too. So I'm for it. |
Reading this, I think where we are (with several fixes landed!) is:
and therefore
|
I am intersted in the progress on this issue. I have one of these devices. I found this issue while searching for why my values for w/m2 from rtl_433, Cotech display, and what the Cotech display posts to wunderground.com are different. I can provide any additional information the team needs to solve this problem. I will read through the whole thread to see if I can proactively respond with the information the team requires to get to a solution. |
UV and light_lux were added for Cotech 36-7959 in commit 7f14007 , but light_lux is not decoded correctly. Maximum decoded light_lux value in decoded samples is always 69627 and I'm getting the same value although the console itself properly displays higher values and the value should go up to 200.000.
The text was updated successfully, but these errors were encountered: