Open Jsakkos opened 2 years ago
Hey there @sjtrny, mind taking a look at this issue as it has been labeled with an integration (scd4x
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
Any chance you can test with an ESP32 instead?
@sjtrny I unfortunately don't have any ESP32 devices. One thing I will add is that I have 4 of these setup, and only one has this issue. I've tried swapping out the SCD41 itself, reflashing the device OTA, and swapping out the ESP8266 itself. The strange thing is that after a reflash, it will work properly for ~ 30 mins before displaying this message.
Can confirm on an ESP32
On an esp8266 nodemcu, having the same issue. The sensor initializes and displays its serial number. The response is "data not ready yet" each time it is polled.
I don't believe the board is defective as it has did output data one time for me. Sensor is an SCD41 from Adafruit.
This looks very similar to what I'm seeing, I've just asked about it in the Adafruit forums. Mine isn't using ESPHome though, it's connected to an ESP32-S2 running CircuitPython.
When I detect that it's been too long without data (> 5 min), I stop the periodic measurements, re-initialize the sensor, and start measuring again:
if time.monotonic() - last_co2_read_time > 300:
print('Stopping periodic measurements')
scd4x.stop_periodic_measurement()
time.sleep(1)
print('Reinitializing CO2 sensor')
scd4x.reinit()
time.sleep(1)
print('Starting periodic measurements again')
scd4x.start_periodic_measurement()
I don't know enough about ESPHome to tell, but is it possible to program in this kind of workaround with the YAML config? Ideally the best would be to avoid such hacks and have the sensor keep working.
This workaround is usually enough to receive some data again, but it usually doesn't last long and soon enough I'm having the issue once more. In some cases calling reinit
doesn't fix it, so I have some code to detect this and restart the whole board; after a reboot I've always seen it produce data again.
I've tried using the sensor both in its regular periodic measurement mode and its low-power mode, and this has made no difference. In both cases I eventually end up stuck on data_ready == False
forever. It was said above that it can take ~30 minutes for it to get stuck; for me it's completely unpredictable. Sometimes it takes just 5 minutes, other times 12+ hours.
Since I can use CircuitPython to send commands to the sensor, is there anything I could try to help find what's causing this issue?
edit: I've had good success changing from a periodic measurement to the "one-shot" reads documented in section 3.10.1 of the datasheet. I used the existing methods from the client, just with a new constant:
def get_data_oneshot(scd4x):
scd4x._send_command(0x219D, cmd_delay=5)
scd4x._read_data()
It usually gives me a reading, although even this approach fails from time to time. If you're encountering this issue and are able to use single-shot reads, I'd suggest giving it a try.
@Jsakkos I am trying to do the same as you are. I will be using an ESP32-S2 Feather. Would you share your code please. Thanks
Connecting this to a forum post:
General troubleshooting tip, add the following to your configuration:
# Enable logging
logger:
level: VERY_VERBOSE
I should have updated this GitHub issue after I updated my Adafruit forum post. I am no longer encountering this issue, at all.
I had originally connected my SCD-41 in a chain of sensors all connected with STEMMA QT/Qwiic cables with one end being a FeatherS2 Neo and the SCD-41 being the 3rd device in that chain. It went like this:
FeatherS2 Neo → PMSA0003I → MCP9808 → SCD-41 → multiplexer → (2 × SSD1327)
The problem was likely with the amount of power that could be carried by the STEMMA QT port on the Feather to this entire chain. I changed the first link of this chain from a STEMMA QT cable to 4 Dupont cables connected to the board's (5V, GND, SCL, SDA) and going to the PMSA0003I sensor (photo of the device after making this change). I left the rest of the chain as it was, and I never encountered this issue again.
So I would recommend making sure that you are supplying enough power to the SCD-41 sensor. Mine used to get into this "no data" state several times a day, and since making this change it hasn't happened even once.
@nicolasff thanks for the update! I moved the 3v3 to the 5v pin and it started working again. 🙏 thanks so much!
:| oh no it's back!
In general it seems like initialization state machine is missing retry logic. Instead of just saying oops I couldn't read the firmware and then being dead, why doesn't it attempt multiple times to stop measurements and read firmware?
Looks like I need to restart it every once in awhile. Starting to see a lot of other buggy things:
I've tried setting it to lower and lower power modes. Seems to do better that way.
The data sheet seems to indicate it needs 11-13 mA when running with periodic measurements, and 115-137 mA for high performance at 5V.
I found this ESPHome documentation that indicates the default "drive strength" is about 20 mA. https://esphome.io/guides/configuration-types.html#pin-schema
https://sensirion.com/media/documents/C4B87CE6/627C2DCD/CD_DS_SCD40_SCD41_Datasheet_D1.pdf
I'm fairly new to this so I can't quite understand if my board is capable of supplying the sort of power the SCD41 needs:
Managed to fix this with the factory_reset Action.
Edit: not a long-term fix.
I can't find my scd41. could you please post your yaml?
i use: https://shop.m5stack.com/products/co2l-unit-with-temperature-and-humidity-sensor-scd41
Communication failed! Is the sensor connected?
[17:23:32][I][i2c.arduino:069]: Results from i2c bus scan: [17:23:32][I][i2c.arduino:071]: Found no i2c devices!
[17:23:32][C][scd4x:095]: Address: 0x62 [17:23:32][W][scd4x:099]: Communication failed! Is the sensor connected? [17:23:32][C][scd4x:112]: Automatic self calibration: ON [17:23:32][C][scd4x:121]: Ambient pressure compensation disabled [17:23:32][C][scd4x:122]: Altitude compensation: 0m [17:23:32][C][scd4x:127]: Measurement mode: periodic (5s) [17:23:32][C][scd4x:139]: Temperature offset: 4.00 °C [17:23:32][C][scd4x:140]: Update Interval: 30.0s
[17:23:32][C][scd4x:141]: Device Class: 'carbon_dioxide' [17:23:32][C][scd4x:141]: State Class: 'measurement' [17:23:32][C][scd4x:141]: Unit of Measurement: 'ppm' [17:23:32][C][scd4x:141]: Accuracy Decimals: 0
[17:23:32][C][scd4x:142]: Device Class: 'temperature' [17:23:32][C][scd4x:142]: State Class: 'measurement' [17:23:32][C][scd4x:142]: Unit of Measurement: '°C' [17:23:32][C][scd4x:142]: Accuracy Decimals: 2
[17:23:32][C][scd4x:143]: Device Class: 'humidity' [17:23:32][C][scd4x:143]: State Class: 'measurement' [17:23:32][C][scd4x:143]: Unit of Measurement: '%' [17:23:32][C][captive_portal:088]: Captive Portal:
thanxs to all! ;-)
Every disturbance in power delivery results in the sensor not working, until I restart the ESP. After restart it can work for more than a day without any issues.
I've just set up everything on a breadboard, the module is just hanging. And every time I move it - it's not reporting after. Maybe an auto re-init should be implemented?
The problem
The sensor will occasionally become unresponsive and send the message "Data not ready yet". Power cycling the device has no effect.
Which version of ESPHome has the issue?
2021.12.1
What type of installation are you using?
Home Assistant Add-on
Which version of Home Assistant has the issue?
2021.11.5
What platform are you using?
ESP8266
Board
Wemos D1 mini 4mb
Component causing the issue
i2c
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
Seems similar to this issue with the SCD30: https://github.com/esphome/issues/issues/987