Thursday, September 01, 2022

ESP32 with 2.8 inch LCD display

I wrote recently about a little ESP32 board with a tiny LCD display from Lilygo that worked "out of the box" for me.

Another board from AliExpress, with a larger 2.8 inch display, gave me a lot of trouble before I got it going.

Described as "ESP32 Arduino LVGL WIFI&Bluetooth Development Board 2.8" 240*320 Smart Display Screen 2.8inch LCD TFT Module With Touch WROOM"

The board has an ILI9341 display board bonded to the PCB and connected via an SPI interface.

After trying all sorts of combinations of pins for the SPI interface, and having the screen remain dark, I shone a torch obliquely at the screen and found that it was working fine but without the backlight was not visible.

Switching to MicroPython makes experimenting a bit easier. I used this ili9341 python library and with the generous help of the author rdagger, figured out that the backlight is connected to GPIO pin 21.

Here's how I set it up for drawing:

from ili9341 import Display

from machine import Pin, SPI

Pin(21, Pin.OUT).on()

spi = SPI(1, baudrate=40000000, sck=Pin(14), mosi=Pin(13))

display = Display(spi, dc=Pin(2), cs=Pin(15), rst=Pin(12))

display.draw_text8x8(0, 0, 'Built-in', color565(255, 0, 255))

As mentioned in other posts, I'm currently using these things to monitor solar power generation so I can time the use of high energy appliances with the sun hitting the panels here. A device like this, that can use internet services has all sorts of applications and a larger screen could be handy.

No comments: