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
ms5611 fix #969
ms5611 fix #969
Conversation
I scanned over the available generic arduino "ms5611" libraries in PIO, and I noticed all of them use delay(3) or at most delay(4) in that spot. The esphome library is obviously based on Jarzebski's arduino ms5611 library, which is the only one I've seen with that eternal delay(100). |
It was a struggle, but I managed to get firmware compiled with the changes included. Testing as of now... will report back as soon as I see any issues (hopefully none). |
Unfortunately, the 10ms fix alone did not help. I'm not sure what else it could be; maybe it is something else in the library, or something in the way esphome handles the library? IDK, but a fix is over my head at this point. |
I turned my attention to the calculation section and found many differences in math, but I believe most of it is equivalent (bitshifts vs pow(2,x), etc). However I'm not familiar with the methods used in esphome. So I don't know for sure if it has issues with handling overflows, etc. The ms5xxx maths are known to work well. So I tried implementing them as 'literally' as possible, without success (values were silly higher than they should be). Here are the "good maths" copied directly from ms5xxx.cpp (read_adc() returns an unsigned int, and C[] is an array of unsigned int's... also note C[0] isn't used so indexes are shifted up 1):
...and my failed attempt at implementing the same math functions in esphome (values are way too high to be right):
I thought maybe there was a typo in the esphome library on those prom read indexes, so I tried shifting them up 1 to look like ms5xxx. That failed with even worse values, but worth noting it was |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description:
ESPhome ms5611 library results in errors in pressure readings (jump up/down by 30hpa randomly). This is likely due to a problem with reading the prom calibration values. I have used another library successfully on other projects for several years straight. This ms5xxx library is found here:
https://github.com/Schm1tz1/arduino-ms5xxx
The only related difference between the libraries that I found so far is a different delay bewteen the reset command and prom read command. ESPhome uses 100ms, ms5xxx uses 3ms. This very well could be the cause of the problem!
ms5xxx also variable delays between readings and conversions that depend on resolution. Esphome uses 10ms for these delays, which is the same as the ms5xxx delay for 4k resolution. Since I'm not sure which res esphome uses, I left those at 10ms for now.
A link to the original discussion with some troubleshooting, and the issue report:
https://community.home-assistant.io/t/esphome-ms5611-issue/164240/2
esphome/issues#1004
[update: The erroneous measurements still occer with this change.]
Related issue (if applicable): fixes
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#
Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: