ESPHome: sensor and display on same esp board

Maybe a dumb question or a noob question, but is it possible to connect a screen on an esp32 board and use the same esp board to connect and read some sensors?

I would like to show several values on the display, but at the same time add some sensors to it for temperature/humidity/air quality…

Or do I need to use a second esp board for the sensors?

You can have as many sensors as you have available GPIO ports.

Or even more if you are using sensors with an I2C interface :slight_smile:

Ah thats great!

So the display can be the home station with it’s own sensor for several measurements.

I am using I2C sensors; I did test them once with a esp board, but that was not connected to Home Assistanr, but a stand alone project.

Because I am pretty new with esphome I was not sure if the display and the sensors would disturb eachother…

And even more, up to 128 if you use MCP23017 port expanders. Here is a YouTube video where someone demonstrates the port expander on ESPHome.

1 Like

I have ordered a 4 ich display, but today I have tested with a tiny 0.91 inch :grin:

But I succeeded in connecting a bme280 board and show its measured values on the display, which has been connected to the same esp board!
It is pretty easy!

And within the Home Assistant dashboard the sensors are also visible.

Tnx for your reply.

Did you check that the board is supported by ESPHome ??

Unless it’s one of the supported e-paper ones it is probably not supported as @Branko said. Got a link?

@gaz99 @zoogara
Hi, it is this board which should be used with ili9488 driver and it is mentioned on this esphome page:
ESPHome and ILI9xxx

The ordered display:
4 inch TFT

So, it should be good, not?

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.