I'm running this code on an adafruit esp32s2 reverse tft feather, with the scd4x connected (plus an SEN5x but it will gracefully accept not having one (hopefully). Code needs an adafruit io username + key and wifi, plus the SCD40/SCD41/SCD42.
https://github.com/good-enough-technology/Good-Enough_Air-Quality-Device_CO2-SCD4x_PM-SEN5x_CircuitPython
The symptom is that when I was calling if scd4x_device.data_ready: after sleeping for 30seconds it was false, but very often false, so my code wouldn't read the metrics that iteration. I never get this issue with the sen5x on same bus. When bug detecting I set it to check in a loop, with time.sleep 0.1, and it took between under a second to over 3seconds to become scd4x_device.data_ready == True. That's not expected behaviour according to my experience with other libraries for this sensor (arduino etc). I have the i2c bus initialised manually (instead of board.I2C) so I can set the frequency, to avoid the esp32s2 100kHz timing bug, but no noticable diference.
Using Circuitpython 8.1.0-beta 2 (maybe, but the one with gifio), and now 8.2.0 beta 1.
My understanding from arduino land was data_ready meant new readings available for the read_measurements type function. This library doesn't have such a beastie so the meaning is unclear👹 Is it the same, should I wait until data_ready to read scd4x_device.co2? If so, then the sensor is meant to be comfortably pollable at 1Hz so it shouldnt take longer than that for data ready to become truthy. I'll try to get some more exact bug report / reproduction steps / a video.
-EDIT-
When you sleep for 30 seconds, do you power down the i2c bus, or do you keep it powered? Going of the good enough air quality device code, I'm guessing the i2c line gets powered down?
If that's the case there's a few things--Unless you're using single shot measurement, the co2 sensor will be inaccurate for a period of time.
The above question was answered via discord chat: No power is not removed from the sensor during any sleep period and a second start_periodic_measurement is not sent, so the sensor should be sampling and we don't have to worry about the weird edge conditions of startup co2 measurement or single shot co2 measurement.