letscontrolit / ESPEasy

Easy MultiSensor device based on ESP8266/ESP32
http://www.espeasy.com
Other
3.24k stars 2.2k forks source link

[BUG] Plugin 135 - SCD4x freeze after some times #5023

Closed iz8mbw closed 4 months ago

iz8mbw commented 4 months ago

Hello. using a SCD41 sensor on an ESP32 board, yes I use latest firmware of 1st April 2024.

What happens is after some times (some hours) the sensor freeze and from the web interface I see "0" as value and no more MQTT messages are published. See here the values on Home Assistant: image

To recover it I need to restart ESP32 board or do a Power-Off / Power-On. On the logs I don't see nothing when the sensor freeze (no EVENT are generated).

Polling interval set to 60 seconds, "i2c scan" still detect the sensor.

image

image

I2C Scan result: image

From the log, as you can see, no messages/events from SCD41 sensor (don't confuse the events you see that are referred to another sensor, the SGP41): image

tonhuisman commented 4 months ago

Is this a LittleFS build (IDF 5.x) or SPIFFS (IDF 4.4)? Does this also occur with older builds?

iz8mbw commented 4 months ago

Hi Ton, it's a LittleFS build. Same issue with older build but I connected the sensor since some weeks so cannot told to you if a build of 2 months ago (for example) was working.

TD-er commented 4 months ago

How is the sensor connected? Length of the cables, for example. What I2C clock frequency?

iz8mbw commented 4 months ago

20 cm, i2c slow as per screenshot

TD-er commented 4 months ago

Have you also tried with the other I2C device disconnected? Just to make sure it is only an issue with the SCD4x sensor and not related to something else.

iz8mbw commented 4 months ago

No. I'll do more test if needed but cannot understand why no EVENTS are in the log when it is frozen.

TD-er commented 4 months ago

I have not yet any clue what is happening here. One of the options is that the sensor gets locked up. Or maybe the plugin is getting out of sync with the sensor.

iz8mbw commented 4 months ago

Just an update, I changed the power supply of the sensor from 3V3 to 5V and now it's still working since 28 hours.

iz8mbw commented 4 months ago

Screenshot_2024-04-03-21-14-11-32_c3a231c25ed346e59462e84656a70e50

tonhuisman commented 4 months ago

Just an update, I changed the power supply of the sensor from 3V3 to 5V and now it's still working since 28 hours.

That sounds more like a wiring mistake or a faulty voltage regulator on your board (assuming there is one installed) or a broken sensor, as the SCD41 tech specs say the max VDD should be no higher than 3.6V...

iz8mbw commented 4 months ago

According to Sensirion Data Sheet the maximum VDD is 5.5V Screenshot_2024-04-03-22-34-38-20_f541918c7893c52dbd1ee5d319333948

tonhuisman commented 4 months ago

Hah! Official Sensirion pdf says different: 🤔 ❓ image

TD-er commented 4 months ago

Is the digital level of the data signals related to this voltage? If so, then other I2C devices may also be exposed to higher voltages

iz8mbw commented 4 months ago

https://sensirion.com/products/catalog/SCD41/

tonhuisman commented 4 months ago

Ah, too many Sensirion pdfs in the same folder 😊

iz8mbw commented 4 months ago

Hah! Official Sensirion pdf says different: 🤔 ❓ image

Sensor in scope is SCD41, not SGP41

tonhuisman commented 4 months ago

Yes, mixup, sorry.

Still, smells like a broken sensor, as it should still work OK from 2.4V, so it's strange it won't cooperate at 3.3V Maybe adding a 10uF capacitor near the sensor might stabilize it better?

Edit: The max. VDD ripple of 30mV seems to indicate it might be a tad sensitive to instable power.

TD-er commented 4 months ago

image Hmm the peak current is lower on 5V, so this might still be power supply (or wiring) related. And as you can see, the input high level is related to Vdd. So I guess it is perhaps better to look into the power supply to the sensor as running at 5V may not be very stable regarding I2C communications and it can be dangerous to other I2C devices on the same bus which might not be 5V-tolerant.

Keep in mind that using cheap breadboard wiring will cause a significant voltage drop when running "high" currents, even as low as 200 mA.

So you might want to add some 10 uF and 100 nF capacitor close to the Vdd/GND of the sensor and look into the connection of both GND and Vdd of the sensor.

iz8mbw commented 4 months ago

Guys, for now going to close this issue. Thanks for suggestions.

Ciao!