How to avoid flickering with ILI9341 display

I’m using a ILI9341 touch screen with an ESP32 (ESP-WROOM-32). Everything works, but I get a flicker with each refresh of the screen (screen flashes brighter, or at least that’s how it seems). Are there any tricks to avoid/reduce flicker?

Here’s my minimal config to duplicate the problem:

spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19

display:
  - platform: ili9341
    model: TFT 2.4
    cs_pin: 5
    dc_pin: 27
    reset_pin: 17
    auto_clear_enabled: false
    update_interval: 1s
    id: my_display
    lambda: |-
      it.filled_rectangle(0, 0, it.get_width() - 1, it.get_height() - 1, Color(242, 140, 38));

This fills the screen with a solid color every second. The auto_clear_enabled: false option makes it so it doesn’t clear the screen before re-drawing, so it seems like this shouldn’t cause any noticeable flicker…

I’ve tried changing the lambda so it doesn’t redraw the full screen each time:

    lambda: |-
      static bool first = true;
      if (first) //Fill the full screen on the first draw
      {
        it.filled_rectangle(0, 0, it.get_width() - 1, it.get_height() - 1, Color(242, 140, 38));
        first = false;
      }
      it.filled_rectangle(0, 0, 100, 100, Color(122, 122, 122)); //Draw a small rectangle

But this still causes the whole screen to flicker on each draw.

I have the LED pin on the ILI9341 connected to 3.3v. I’ve also tried connecting it to a GPIO pin and setting the led_pin option, but that doesn’t seem to have any effect.

Has anyone else noticed flickering when working with a display component? If so, were you able to find any way to improve it?

What about doing something normal, like writing text? Does it still flicker?

I do still see flickering with writing text or drawing images, but it seems to be proportional to the size of the font or image. If I use a smaller font, and not too much text, the flicker is barely noticeable.

The strange part to me is that the whole screen flickers, not just the area being redrawn. Maybe it’s just a cheap display, and I need to try a nicer one…

Hi Ryan,

I’m having the same problem. Have you solved it?
I got two screens with the same setup and only one has the problem. Somehow I think it is related to the wiring. When I use black and white, there is no flickering at all.

Best regards,
Axel

I never figured out how to get that particular display to work without flickering. I ended up switching to a Nextion display, which has worked better for me.

I use several ILI9341 2.8 "flicker-free ones.
I use 5V power supply.