Page 1 of 1

Is it possible to programmatically find out whether the display is connected to I2C or not?

Posted: Sun Nov 26, 2023 6:20 am
by zhukovia
Is it possible to understand programmatically whether the display is physically connected?
When trying to initialize the display

Code: Select all

    ESP_LOGI(DISPLAY_TAG, "Install SSD1306 panel driver");
    esp_lcd_panel_handle_t panel_handle = NULL;
    esp_lcd_panel_dev_config_t panel_config = {
        .bits_per_pixel = 1,
        .reset_gpio_num = PIN_NUM_RST,
    };
    ESP_ERROR_CHECK(esp_lcd_new_panel_ssd1306(io_handle, &panel_config, &panel_handle));
    ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
    ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
in the monitor I get the error
E (2319) lcd_panel.io.i2c: panel_io_i2c_tx_buffer(177): i2c transaction failed
but ESP_ERROR_CHECK still outputs ESP_OK
I repeat again, the display itself may or may not be connected to ESP 32 and I need to determine this.

Re: Is it possible to programmatically find out whether the display is connected to I2C or not?

Posted: Sun Nov 26, 2023 10:46 am
by MicroController
Is it possible to understand programmatically whether the display is physically connected?
Yes, it is possible. But apparently, the IDF v5.1's 1306 LCD library functions never check for success of communications and just return ESP_OK no matter what. This seems to have been rectified in ESP-IDF v5.2.

Re: Is it possible to programmatically find out whether the display is connected to I2C or not?

Posted: Sun Nov 26, 2023 11:58 am
by zhukovia
Yes, it is possible. But apparently, the IDF v5.1's 1306 LCD library functions never check for success of communications and just return ESP_OK no matter what. This seems to have been rectified in ESP-IDF v5.2.
How can I do this? I have ESP-IDF v5.1.

Re: Is it possible to programmatically find out whether the display is connected to I2C or not?

Posted: Sun Nov 26, 2023 1:03 pm
by MicroController
zhukovia wrote:
Sun Nov 26, 2023 11:58 am
How can I do this? I have ESP-IDF v5.1.
a) upgrade to v5.2,
b) modify the respective function in your IDF, or
c) try to manually send a command (e.g. "display off") to the display via the I2C driver and check the result.

Re: Is it possible to programmatically find out whether the display is connected to I2C or not?

Posted: Sat Dec 02, 2023 8:21 am
by zhukovia
MicroController wrote:
Sun Nov 26, 2023 1:03 pm
zhukovia wrote:
Sun Nov 26, 2023 11:58 am
How can I do this? I have ESP-IDF v5.1.
a) upgrade to v5.2,
I see that the latest version is 5.1.2. Where did you find 5.2?

Re: Is it possible to programmatically find out whether the display is connected to I2C or not?

Posted: Sat Dec 02, 2023 11:01 am
by MicroController
https://github.com/espressif/esp-idf/tree/release/v5.2
Not sure if that's actually a release yet though.
But check out v5.1.2, which probably already includes the fix for issue #11741.