xgzp68xx component is missing oversampling support #3286
-
Component namexgzp68xx Link to component documentation on our websitehttps://esphome.io/components/sensor/xgzp68xx.html Describe the enhancementhttps://cfsensor.com/wp-content/uploads/2022/11/XGZP6897D-Pressure-Sensor-V3.1.pdf shows that the sensor can perform oversampling for both pressure and temperature. The current driver code at https://github.com/esphome/esphome/blob/dev/esphome/components/xgzp68xx/xgzp68xx.cpp does not utilise this support however. Use casesWithout oversampling, the sensor experiences very considerable noise. Readings jump around about about +/- 10 Pa. This would be similar to the Bosch series of barometric sensors - you really do need oversampling turned on to get usable stability in readings. Anything else?In my opinion, there is too much arithmetic division by non-constants in the current driver source code. Division is very slow on CPUs like the ESP32. There is also use of The documentation says that the default K value of 4096 is suitable for +/- 500 Pa sensors. I have exactly one of those sensors, and I had to use a K value of 16384 to get the correct pressure range. I verified that the sensor model is definitely a +/- 500 Pa sensor using a separate pressure sensor. I think the driver implementation code at https://github.com/fanfanlatulipe26/XGZP6897D/blob/main/src/XGZP6897D.cpp is much better written, better matches the datasheet, and the current driver code ought to be replaced with that. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 14 replies
-
🏷️ I've automatically added the |
Beta Was this translation helpful? Give feedback.
-
I went ahead and implemented a solution to this: |
Beta Was this translation helpful? Give feedback.
-
The K value comes from the datasheet. What is your sensor part number? |
Beta Was this translation helpful? Give feedback.
-
Main PR esphome/esphome#10306 has been updated to undo the v2 renaming. |
Beta Was this translation helpful? Give feedback.
I went ahead and implemented a solution to this: