r/esp32 • • 2d ago

Hardware help needed Esp32s3 × ILI9341 Micropython is not working, help

So, i was vibecoding a little test-screen thing, and screen was just on, it was not showing anything but darkness, here is the code:

from machine import Pin, SPI

import time

print("Start hard test...")

spi = SPI(2, baudrate=10000000, polarity=0, phase=0, sck=Pin(18), mosi=Pin(11))

cs = Pin(10, Pin.OUT)

dc = Pin(9, Pin.OUT)

rst = Pin(14, Pin.OUT)

def cmd(c):

dc(0)

cs(0)

spi.write(bytearray([c]))

cs(1)

def data(d):

dc(1)

cs(0)

spi.write(bytearray(d))

cs(1)

rst(0)

time.sleep(0.1)

rst(1)

time.sleep(0.1)

cmd(0x01) # Software reset

time.sleep(0.1)

cmd(0x11) # Sleep out

time.sleep(0.1)

cmd(0x3A) # Pixel format

data([0x55]) # 16-bit color

cmd(0x29) # Display ON

time.sleep(0.1)

cmd(0x2A) # Column address set

data([0x00, 0x00, 0x00, 0xEF])

cmd(0x2B) # Page address set

data([0x00, 0x00, 0x01, 0x3F])

cmd(0x2C) # Memory write

print("Sending color...")

data([0xF8, 0x00] * 240)

print("Done! If screen is red, hardware is OK.")

2 Upvotes

6 comments sorted by

•

u/AutoModerator 2d ago

Hardware Troubleshooting Notice: If you are experiencing unreliable connections, boot loops, or missing serial communication, verify your hardware footprint:

  1. Are your headers soldered? Pushing un-soldered raw header pins through module vias into a breadboard violates basic physics. Loose connections create parasitic capacitance and intermittent open circuits. Solder your board.
  2. Did you include a schematic? Custom circuit issues require a legible schematic drawing.

If your hardware relies on putty, tape, or friction, please resolve your connections before demanding assistance from our domain experts.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/n_sh_44 2d ago

Your SPI writes look fine, but the memory write only sends 240 pixels. At 16 bits per pixel that is 480 bytes, which fills just the first row of a 240 by 320 panel, so a single thin red line at the top is easy to mistake for a dead screen. I'd send 240 x 320 x 2 = 153600 bytes in chunks of a few hundred bytes after command 0x2C, and also add 0x36 (MADCTL) with 0x48 so the orientation and RGB order are sane. Give the sleep out command 120 ms before anything else too. If it still stays dark, check that the LED or BL pin is tied to 3.3 V, and that the module's reset pin is really on GPIO14. As a quick test, read the ID with command 0x04 over MISO to confirm the controller answers.

1

u/IAMSHUCKS 2d ago

So smth like that?: from machine import Pin, SPI import time

spi = SPI(2, baudrate=1000000, sck=Pin(18), mosi=Pin(11), miso=Pin(13)) cs = Pin(10, Pin.OUT) dc = Pin(9, Pin.OUT) rst = Pin(14, Pin.OUT)

rst(0) time.sleep(0.1) rst(1) time.sleep(0.12)

dc(0) cs(0) spi.write(b'\x04') cs(1)

dc(1) cs(0) res = spi.read(4) cs(1)

print("ID:", [hex(x) for x in res])

1

u/obdevel 2d ago

Did you switch on the backlight ?

1

u/IAMSHUCKS 2d ago

Like LED pin? Yea i did, it is on 3v3

1

u/rattushackus 1 say I make awesome posts. 2d ago