Page 1 of 1

How to gracefully handle failed i2c connection

Posted: Wed Jan 17, 2024 5:23 am
by flimsy
I've implemented an OLED display over i2c, and I'm trying to figure out whether there is a graceful way to fail to initialize the display gracefully and continue executing the rest of the behavior without the display. Currently when the display is not connected, the ESP boot loops with an error when `i2c_master_cmd_begin` executes. Is there a way to simply handle this failure and move on?

Re: How to gracefully handle failed i2c connection

Posted: Wed Jan 17, 2024 5:59 am
by ESP_Sprite
You'd catch that error manually (I imagine at the moment it's caught by an ESP_ERROR_CHECK macro or something that causes the panic and reboot) and then set a flag so the rest of the program won't try to write to the non-existent display anymore.

Re: How to gracefully handle failed i2c connection

Posted: Wed Jan 17, 2024 6:24 pm
by flimsy
Ah OK, I think I understand what's going on. Thank you!