ESPHome: sensor and display on same esp board

That looks pretty good. the largest ILI9488 I could find a while back was 3.2 inch. I use heaps of them and the driver and resolution are the same so this should be fine.

Let us know how you go.

You can also make sensors from different boards appear on the screen without or with Home assistant.

https://esphome.io/cookbook/http_request_sensor

I will keep you up-to-date! :slight_smile:

1 Like

Thank you, interesting, I will read your info about it!

I have received the display and the esp32.
I will now have to experiment.

To be honest, besides of the small oled display, I am a newbie with tft screens.
If I search the internet I found a lot of posts about it, but for the moment I did not find a clear tutorial about the connection between the display and the esp32. There are about 13 pins or so on this display, but I have to find out the function of each, which ones I really need and how to implement in esphome.

If one of you have a good tutorial, I would be interested!

Maybe I must try first without esphome, and with Arduino ide?

The pins are described in the product’s description in your Aliexpress link in case you missed it, with picture (assuming it’s right…).
You might want to take a look at this post.

I thought I should mention the One-Wire bus, which also allows you to use multiple sensors on the same pin: ESPHome dallas. The DS18B20 allows for distant readings; you can find versions up to 10m (33ft) on Aliexpress, though I personally only used ones up to 3m (10ft). Works great in a greenhouse for example to measure outside/inside/soil temperatures from a single ESPHome device; low cost.

At the least, post a photo of the board clearly showing the labelled pins. They are relatively easy to hook up but sometimes the pin abbreviations need a bit of guesswork.

Good idea!
Here are some images from display pins and the esp32 board!
Thanks for your help!


NOTE: I assume you have a WROVER ESP32 with extra PSRAM? A WROOM chip will not have enough memory.

I am also assuming you got a touchscreen variant and it’s an XPT2046 touchscreen - the purchase page specs don’t say. You may also get “strapping pin” warnings - ignore them.

spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19

output:
  - platform: ledc
    pin: 32
    id: backlight_pwm

# define as light
light:
  - platform: monochromatic
    output: backlight_pwm
    name: "Backlight"
    id: back_light
    restore_mode: ALWAYS_ON

touchscreen:
  platform: xpt2046
  id: touchscreen1
  cs_pin: 21
  interrupt_pin: 27
  update_interval: 50ms
  report_interval: 1s
  threshold: 350
  calibration_x_min: 280
  calibration_x_max: 3806
  calibration_y_min: 185
  calibration_y_max: 3884
  swap_x_y: false

binary_sensor:

  # Screen is one big button, read touchscreen docs if you want to divide up
  - platform: touchscreen
    id: touch_key0
    x_min: 0
    x_max: 240
    y_min: 0
    y_max: 320
    on_press:
      then:
        # actions to do on touch.

display:
  - platform: ili9xxx
    model: ili9488
    id: my_display
    rotation: 180 # put whatever rotation you need for your application
    dc_pin: GPIO22
    cs_pin: GPIO15
    reset_pin: GPIO16
    # Display pages and code goes here

Good luck.

Hi Daryl,

Thank you for your clear explanation!
I do have the touchscreen variant.
Unfortunatelly I was trying it with a WOOM esp32…

I have another board lying around and I have ordered one. Is one of those usable (As I see, they both do have PSRAM?)

I have two of these (same board, different webshop?):
S2 Mini w/PSRAM

S2 Mini 2MB PSRAM

On the website they point to this instructions:
S2 Mini manual

Do those boards have anough functionality and capacity?
I do miss some of the pun numbers, but they are different on these boards?

When I look at This scheme, which pin numbers do I need?
It seems in every scheme the names/numbers of the pins are different…I tried it, but please can you take a look with me?

1 VCC power input (3.3V~5V) ------------------------------------------ 3V3
2 GND power supply ground ------------------------------------------- GND
3 CS LCD film selection ------------------------------------------------- GPIO 10 or 34
4 RESET LCD reset ------------------------------------------------------ GPIO ?
5 DC LCD bus command/data selection ----------------------------- GPIO ?
6 SDI (MoSi) LCD SPI display bus data input ---------------------- GPIO 11 or 35*
7 SCK LCD SPI display bus clock signal ---------------------------- GPIO 12 or 36 *
8 LED LCD backlight control (high level lighting) ------------------ GPIO ?
9 SDO (MISO) LCD SPI display bus data input and output ----- N/A (37)
10 t _ clk SPI bus clock signal of touch panel ----------------------- GPIO 12 or 36 *
11 t _ cs touch panel - Chip selection of SPI bus for -------------- GPIO 10 or 34
12 t _ din touch panel SPI bus data input ---------------------------- GPIO11 or 35 *
13 t _ do touch panel SPI bus data output --------------------------- GPIO ?
14 t _ IRQ touch panel interrupts IRQ signal ------------------------ GPIO ?

I have found also this scheme

Try it and see. Pins are different on S2 so some that you shouldn’t use on an ESP32 are fine. You are not likely to break anything.

Just ignore touch to start with, get the display working then add the touch components.

Tnx! I will give it a try and let you know!
I do like experimenting, but was a bit confused with the different names and pin desciptions and of course it is good to know that it is not likely that something will be broken.

@zoogara
YES!!

Finally I did succeed with your help!
I have used an esp32 S2 mini with the pin last numbers you have given.

First I had a problem that I was not able to do the initial flash on the S2 mini but it turns out, esphome has problems with flashing this board.
Now I did the first flashing with:
Adafruit esp tool

I am so happy! Tnx!
Now I have to try touchscreen and than I can start designing my display layout!

1 Like

Next challenge is to get the touchscreen working.
At the moment it does not work… I think…

Should I be able to see in the log when the touchscreen has been triggered?

Have a read in the touchscreen component about calibration. There is an example of printing the raw data - which can be handy for testing:

touchscreen:
  platform: xpt2046
  id: my_touchscreen
  cs_pin: 17
  on_touch:
    - lambda: |-
          ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
              id(my_touchscreen).x,
              id(my_touchscreen).y,
              id(my_touchscreen).x_raw,
              id(my_touchscreen).y_raw
              );

Also - I couldn’t find anywhere in the page for the display mention of what touchscreen controller is in use. It may be a different one…

Oh, sorry, I did not mention! The touchscreen chip on the display board shows “xpt2046” so that should be alright!

I did see the page about xpt2046 calibration, but have to look how I get this test to work.
I will let you know!

A question - did the display come with a little plastic pen? If it didn’t it may be a capacitive touch display…

EDIT - already answered :smiley:

You could also try:

  • a different pin for touch CS
  • connecting the display MISO to the touch MISO - there was some weird note about LCD MISO in the reviews

To be sure, do I read the calibration values in the log of the esphome instance:
diplay test

I could also try your other suggestions.
You mean I can connect the unconnected SDO (MISO) to the display MISO pin 37 (so both are using the same pin 37?)
miso

Yes

As a last resort. None of my displays have needed it.