ESPHome Nest thermostat clone on cheap rotary display

this is the thread on the ESPHone Server

There is nothing that can be done in YAML itā€™s all in the low level st7701s driver code. I probably need to work out who maintains the driver source and contact them to co-ordinate changes I guess?
I just get a ā€œyou do not have permissionā€¦ā€ error on that discord channel - no idea I donā€™t really use discord much.

Sent you an invite to the Discord server

That would be me.

The SPI conflict might be helped by using software SPI, which can be specified in YAML. It is also possible that the st7701s driver code needs tweaking so that the RGB setup is done after the SPI stuff is finished. Iā€™ll have a look when I get a moment.

I have another potential change for the driver upcoming - thereā€™s another related driver (rpi_dpi_rgb) that I have just modified so that the display is shutdown during OTA, without which the PSRAM runs out of bandwidth. The symptom was an network failure during OTA updates.

The same tweak might be needed for the st7701s. It does need ESP-IDF 5.x.

Since i almost threw this garbage away, I havenā€™t commented. But updated github, so it at least :white_check_mark: builds for S3 and S2. Donā€™t know if it runs thoā€¦

GitHub - velijv/nesp: Nest Thermostat clone on a rotary display running @esphome

2 Likes

Thanks to @col135 and the recent new delay feature PR#7373 by @clydebarrow Iā€™ve managed to get the test pattern working on the ZX2D10GE01R-V4848. Thereā€™s been discussion on Discord, but I thought Iā€™d outline all the steps here for the record.

The delay feature for ST7701s is currently in ESPHome 2024.9.0beta1 as of writing, but you still need to manually modify st7701s.cpp per the posts above to moving the init sequence earlier and destroying the SPI because of how the SPI pins are shared with the display on this device.

st7701s.cpp:
I donā€™t know how well these changes will impact any other ST7701s devices and I donā€™t have any other ones to test, so Iā€™m probably not the best person to raise a PR.


The yaml file:

display:
  - platform: st7701s
    id: ${device_name}_display
    spi_mode: MODE0
    data_rate: 10MHz
    color_order: RGB
    # XXX DEBUG
    show_test_card: true
    # XXX
    dimensions:
      width: 480
      height: 480
    cs_pin: 21
    de_pin: 39
    vsync_pin: 48
    hsync_pin: 40
    pclk_pin:
      number: 45
      ignore_strapping_warning: true
    pclk_frequency: 15MHz
    pclk_inverted: false
    hsync_pulse_width: 10
    hsync_back_porch:  10
    hsync_front_porch: 10
    vsync_pulse_width:  2
    vsync_back_porch:  12
    vsync_front_porch: 14
    data_pins:
      blue:
        - number: 47                # LCD_D0  = b0
          allow_other_uses: true
        - number: 41                # LCD_D1  = b1
          allow_other_uses: true
        - 0                         # LCD_D2  = b2
        - 42                        # LCD_D3  = b3
        - 14                        # LCD_D4  = b4
      green:
        - 8                         # LCD_D5  = g0
        - 13                        # LCD_D6  = g1
        - 18                        # LCD_D7  = g2
        - 12                        # LCD_D8  = g3
        - 11                        # LCD_D9  = g4
        - 17                        # LCD_D10 = g5
      red:
        - 10                        # LCD_D11 = r0
        - 16                        # LCD_D12 = r1
        - 9                         # LCD_D13 = r2
        - 15                        # LCD_D14 = r3
        - 46                        # LCD_D15 = r4
    init_sequence:
      # Reference: wireless-tag sample code: 
      # https://github.com/wireless-tag-com/ZX2D10GE01R-V4848/blob/ad21b3659527618fdd752cc0801b0a36f6c5e52c/main/screen.c
      - [0xFF, 0x77, 0x01, 0x00, 0x00, 0x13]
      - [0xEF, 0x08]
      - [0xFF, 0x77, 0x01, 0x00, 0x00, 0x10]    # CMD2_BKSEL (already in esphome ST7701S::write_init_sequence_)
      - [0xC0, 0x3B, 0x00]                      # Scan line
      - [0xC1, 0x0B, 0x02]                      # VBP
      - [0xC2, 0x07, 0x02]
      - [0xCC, 0x10]
      - [0xCD, 0x08]                            # RGB format | ?565??? 666??
      - [0xB0, 0x00, 0x11, 0x16, 0x0e, 0x11, 0x06, 0x05, 0x09, 0x08, 0x21, 0x06, 0x13, 0x10, 0x29, 0x31, 0x18]   # IPS | 255 | 251 | 247 down | 239 | 231 | 203 | 175 | 147 | 108 | 80 | 52 | 24 | 16 | 8 down | 4 | 0
      - [0xB1, 0x00, 0x11, 0x16, 0x0e, 0x11, 0x07, 0x05, 0x09, 0x09, 0x21, 0x05, 0x13, 0x11, 0x2a, 0x31, 0x18]   # IPS | 255 | 251 | 247 down | 239 | 231 | 203 | 175 | 147 | 108 | 80 | 52 | 24 | 16 | 8 down | 4 | 0
      - [0xFF, 0x77, 0x01, 0x00, 0x00, 0x11]
      - [0xB0, 0x6d]                            # VOP  3.5375+ *x 0.0125 | 5D
      - [0xB1, 0x37]                            # VCOM amplitude setting
      - [0xB2, 0x81]                            # VGH Voltage setting | 12V
      - [0xB3, 0x80]
      - [0xB5, 0x43]                            # VGL Voltage setting | -8.3V
      - [0xB7, 0x85]
      - [0xB8, 0x20]
      - [0xC1, 0x78]
      - [0xC2, 0x78]
      - [0xD0, 0x88]
      - [0xE0, 0x00, 0x00, 0x02]
      - [0xE1, 0x03, 0xA0, 0x00, 0x00, 0x04, 0xA0, 0x00, 0x00, 0x00, 0x20, 0x20]
      - [0xE2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
      - [0xE3, 0x00, 0x00, 0x11, 0x00]
      - [0xE4, 0x22, 0x00]
      - [0xE5, 0x05, 0xEC, 0xA0, 0xA0, 0x07, 0xEE, 0xA0, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
      - [0xE6, 0x00, 0x00, 0x11, 0x00]
      - [0xE7, 0x22, 0x00]
      - [0xE8, 0x06, 0xED, 0xA0, 0xA0, 0x08, 0xEF, 0xA0, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
      - [0xEB, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00]
      - [0xED, 0xFF, 0xFF, 0xFF, 0xBA, 0x0A, 0xBF, 0x45, 0xFF, 0xFF, 0x54, 0xFB, 0xA0, 0xAB, 0xFF, 0xFF, 0xFF]
      - [0xEF, 0x10, 0x0D, 0x04, 0x08, 0x3F, 0x1F]
      - [0xFF, 0x77, 0x01, 0x00, 0x00, 0x13]
      - [0xEF, 0x08]
      - [0xFF, 0x77, 0x01, 0x00, 0x00, 0x00]
      - [0x36, 0x00]                            # MADCTL_CMD (already in esphome ST7701S::write_init_sequence_)
      - [0x3A, 0x66]                            # COLMOD 55/50=16bit(RGB565); 66=18bit(RGB666); 77?????3AH?=24bit(RGB888)
      - [0x11]                                  # SLEEP_OUT (already in esphome)
      - delay 120ms
      - [0x29]                                  # DISPLAY_ON (already in esphome)
      - delay 20ms
2 Likes

Hello everybody,
my name is Nicola and Iā€™m the founder of seedlabs.it. We are building open source devices that helps optimize the energy consumption of your home.
We recently commercialised a dev kit based on the haptic smart knob that Scott developed, and we are now building a consumer grade version.

I really like the work being done here, and fwiw, our main use case for the consumer version is to do a thermostat that is easy to use and open to any system, so hopefully you get to play with it soon (in case you didnā€™t get a SmartKnob Dev Kit already)

Did that mean it will be open source?

The dev kit is already open source (both hardware and software), and the consumer product will also be open source (hardware and software).
Depending on the architecture weā€™ll use for the prediction part of the software (forecasting and energy optimization) we might not opensource that, but thatā€™s the only part it is still TBD.

Could you please direct us to your hardware and software repositories?

Iā€™m getting this error when compiling and clearing the build files, is this because I havenā€™t uopdated the cpp file?

    Expected integer, but cannot parse delay 120ms as an integer.
    - delay 120ms
    - - 41
    
    Expected integer, but cannot parse delay 20ms as an integer.
    - delay 20ms

@nickrout sure, SeedLabs Ā· GitHub
or you can access them from seedlabs.it

1 Like

Are you using the ESPHome beta version? The delay feature is not in the current release. The other changes (to the CPP file) are now in a PR you can use as an external component.

1 Like

Ah, yeah no Beta, iā€™ll sort out the beta i think soni can have a play, cheers

On ESPHome Dev now and it compiled :grinning: but screen isnt working yet. I see i still need to update the .cpp file? Where do I find that and where do I put it? Sorry if this is a simple question

If youā€™re using the Dev branch then the CPP file changes are already there.

Hmm, ok, i copied them across anyway and got this


Iā€™ll maybe reinstall the dev branch

OK so uninstalling everything and reinstalling ESPHome Beta is working! :slight_smile:

2 Likes

Soo, what is everyones project with this device

Playing around with lvgl and pulling data from the Home Assistant climate entity.

Trying to see I can get it to change the temp with just the rotary sensor without needing to scroll and select lvgl widgets.

2 Likes