ESPHome: sensor and display on same esp board

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.

I do see a lot of repeating log entries, but if I am right, you mentioned this also in another post and it is related to larger screens and not a problem?

I tried another pin for CS and combined the both MISO pins, but still no luckā€¦ I may need to take some more time and check all the connections (maybe I was mistaken somewhere or maybe one of the breadboard pins did not contact very well)

By the way, what is the reason you did not connect the ā€œ9 SDO (MISO) LCD SPI display bus data input and outputā€ in the first place? In some other schemes it is connected to its own pin on the esp boardā€¦

I still do not get the coordinates with the test code for the touch panel.
I have tried the touch cs on different pins (and changed the code according to it), but no result in the logsā€¦

If I pull out the wire to de touch cs, then there appears one line with coordinatesā€¦ but of course it is no reaction to a touch on the screen, but onlys by unplugging the wireā€¦

The screen does not output any data, itā€™s purely taking input from the esp.

This is a resistive touch screen. Some of mine arenā€™t very sensitive, best results are with a stylus.

But if I run the testcode en touch the screen, the touchscreen part is read and the coordinates of the must be visible in the logscreen of the laptop, where I am running Home Assistant and esphome?

I still have no luck, even when using the stylus, even when touching a little more firmly or longerā€¦

In the meantime I have done some other experiments. I am able to let the code change to another page, every few secondsā€¦
But I would like to change the page by touching a butting, so I will keep trying! :slight_smile:
I appreciate your (quick) help! With your help, I have my first visible things on the display :slight_smile:

One last thing to try - what happens if you remove the SPI bus connections to the display but leave the touch screen connected?

Are those three the right ones to remove for testing?

Here is a sample wiring diagram that shows the connections on an ESP32. Apart from PIN numbers you can see it matches yourā€™s.

You did buy the touch screen version though? The boards are exactly the same (including screen printing XPT2046) but the touchscreen chip is not soldered on.

Yes plus CS. Donā€™t forget to comment out the display code.

It is the display with touchscreen, on the image below you can see the touchscreen chip:

And it is the XPT2046:

And this is the esp32 S2 mini:

Sorry to say I am out of ideas.

Now that you understand the display connections and how a shared SPI bus works you could try some Arduino examples.

You could also try OpenHASP which will run with that display on your other ESP32.

That will confirm if itā€™s an issue with ESPHome or something else.