I2C Device not Detected from Cold Start

Hi - I’m trying to read from a PMSA003I air quality sensor over I2C which is connected and powered from an ESP 32.

When I start the ESP from no power, I get a message saying no I2C devices are found.

But if I 1) re-flash the firmware OR 2) reset the ESP, it finds the I2C device.

In both of the later two cases, power is maintained to the sensor while the ESP restarts. This leads me to think the I2C chip on the sensor isn’t starting up fast enough to be ready when the ESP looks for it, and then it doesn’t try again after nothing is found.

I also don’t get any luck setting I2C scanning to False and specifying the address of the I2C device directly.

Is there any way to delay the I2C polling for a bit when starting up?

Look at on_boot priorities.

You can try it at a sensor level too like this.

And then you could try this too…

1 Like

Setting the setup_priority to -100 seemed to do the trick to keep this from hanging. The logs still show no I2C device is found but the results from the sensor eventually appear, unlike if that parameter isn’t specified.

1 Like