paulvha / scd30

arduino esp8266 ESP8266 SCD30 SCD-30 ESP32 UNOR4
Other
41 stars 11 forks source link

using the setAmbientPressure function results in extreme noise in the output #15

Open gazzat5 opened 1 month ago

gazzat5 commented 1 month ago

Hi there,

I have a bme680 pressure sensor which is giving fairly stable pressure readings: image

However when I use the pressure sensor readings to set the ambient pressure for the scd30, the output numbers for Co2 are extremely noisy (and the below is with extensive filtering): image

I am only setting the ambient pressure after every reading from the scd30, and I have tested intervals of 5, 10 and 20 seconds between each reading but the noise remains. This is similar to the way Example 10 is doing it where it sets the pressure every time data is available as long as the pressure sensor is enabled.

When I remove the setAmbientPressure command and just use the setAltitudeCompensation command the readings are much more stable and sane.

I note that I am sending the readings from a float variable with millibar values such as 1004.79 which is getting automatically converted to an integer value as that's what the function is expecting to receive. I don't know if this is having an affect.

I'm testing on a Wemos D1 Mini pro (esp8266), and using the latest version of the SCD30 library, and the latest version of the Adafruit_BME680.h library.

I also note that the scd30 library is running it's internal beginMeasuring command every time the pressure is provided, which runs sendCommand(COMMAND_CONTINOUS_MEASUREMENT, pressureOffset), so I wonder if the sensor is being reset/restarted each time the command is sent which might explain the noisy readings...?

Can share code if needed though it is rather long (and ugly)

Thanks in advance

paulvha commented 1 month ago

hi, It has been a long time since I have worked on the SCD30 and I have not tested for this behavior.

Some feedback: you can be right that a reset happens with each update. When de sensor is in continuous mode and a change in altitude is done, the complete command needs to be resend. That might mean a complete restart.

What happens if you disregard the first X (say 2) readings AFTER an update of the ambient pressure? will that reduce the noise.

Enable debug and check that the float to uint16 is working as expected.

Instead of taking the result from the BME680, rework example 10 to provide "fake" updates on the ambient pressure. This will rule out that BME680 communication could have an impact.

Do you have the Automatic field calibration enabled? It could have a negative impact.

There was something on GIThub.. but no answer : https://github.com/esphome/issues/issues/4448