For the past couple of weeks, I’ve been cooking up a HMI for my garage. The motivator was to cover the area that was previously occupied by a very old alarm keypad I removed the panel a couple weeks ago. And you know, provide cool features to my home automation setup while doing so!
First attempt at using ESPHome’s LVGL component.
Quick video of it in action:
So far it’s working OK. A couple of bugs and glitches I hope to get fixed in a timely manner.
But it’s good enough as it is to share.
This is not a templateable project. It’s very much tailored to my needs. But I think anyone willing to put in a modest effort could adapt it for his needs.
All the info is in there:
Screenshot in the repo were taken from the SDL simulator on my Windows PC (running in WSL) and not the unit itself. Because yes, you can test most of your code without actually requiring to flash your device over and over!
There’s a mix of french and english stuff in there. Living in Quebec will do that to you.
Have fun and comment.
Questions are welcomed but please read the documentation in the github repo before asking.
Sorry, can you explain me first time connection to home assistant? I don’t know if I connect to USB and prepare for first time use with HA (as I do with others esp in the past), but when I connect after first upload the device is unreachable…
Thanks, I’ve other esp32 installed and working on my home assistant (some temperature and humidity sensors in bedrooms, tank level, and other…) But with this one, I connect usb-c uart, go on esphome builder-new device-esphome web and find it. Upload code for first time use, set wifi essid and password, but then the device isn’t reachable… maybe can be break…
Check the Settings page on the device, you should see its IP address (if it’s connected to your network).
At the top right corner of the screen, there is a wifi signal indicator that should turn green if the device connects to wifi. Right beside is a small Home Assistant logo that will light blue if it connects successfully to API server.
Have you correctly populated your secrets.yaml file with your Wifi’s SSID and passphrase?
“I built a Midea heat pump monitoring device with this panel to expand the service capabilities. I also added a DS18B20 temperature sensor, which displays its address on the screen for identification purposes. It was placed in a nice plastic enclosure.”
Very impressive project! I learned several things just from reviewing your code. I was unaware of the SDL Host that allows me to simulate the display on my computer, what a time saver!!! I’m curious if you have issues doing OTA updates? When I try to do OTA, about 95% of the time the process of transferring the file to the esp32 device errors or times out and the entire upload process is very slow (about 5 min if it succeeds). I wonder if it could be that the 120hz refresh rate is causing the cpu to be too busy. Have you run into this issue at all? I end up plugging the screen into my computer to flash it but that’s not going to be an ideal solution once I have the screen mounted on the wall.
Thanks for the kind words.
The SDL host is indeed a real game changer. Unfortunately touch controls(mouse clicks) aren’t very responsive inside the window. I assume this has to do with WSL tho. But still, it’s way better than spending time waiting for device to OTA update!
I too noticed very long OTA transfer times and drop-outs on very rare occasions.
While LVGL is active, SPI Flash and PSRAM are getting heavily utilized, which slows down any other operations to a crawl. Currently, it would seem ESPHome framework does not pause LVGL for you while an OTA is being transferred.
Two ways to go around it. Either pause LVGL execution on your own. I have my device setup so it pauses after a period of inactivity thus it’s in paused state most of the time.
Second way is to implement a reboot into safe mode button you could manually activate from within Home Assistant prior to pushing your OTA. It reboots your device, connects to wifi and enables only the bare minimum to activate ESPHome’s API. This is the most reliable way IMO and what I do.
I have the same panel and use SDL Host to develop, but do so on a Ubuntu VM running on VirtualBox on a Windows machine. No issues with mouse responsiveness for me so you are perhaps correct something to do with WSL. With regard to slow OTA I also found this, I’m not convinced the Wi-Fi reception is great on this board, seems to make a difference if you move it around during the OTA for some reason.
I have done the following to pause LVGL during the OTA update and switch off the backlight as I found the screen jumped around and annoyed me!
Awesome I’ll try using that lvgl pause and see if that helps. Are you guys using an editor like SquareLine Studio to work on UI or just adding yaml and testing and retesting a hundred times like I am? Would love to have a quicker way to see changes.
I also use Visual studio code, I use packages so have three yaml configs one for the SDL Host, one for the real physical device, then a common yaml with the majority of the config in that is referenced by the host/and physical yaml. Doing this allows for differences between the SDL Host and the physical device and means you only need to change the code once for both devices. I would say there are no shortcuts to physical coding, think mine is about 2000 lines long.
packages:
# An external package that defines the common config
Common: !include ProjectFolder/common.yaml
Have you had any issues with these devices not being able to use wifi? I had great success with my first two screens and they’re working perfectly. I ordered another two and both of them are giving me errors connecting to wifi. The code is unchanged from one of my other working projects but I get the following output:
[15:48:53][D][esp32.preferences:114]: Saving 1 preferences to flash...
[15:48:53][D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[15:48:53][I][app:029]: Running through setup()...
[15:48:53][C][i2c.idf:021]: Setting up I2C bus...
[15:48:53][I][i2c.idf:260]: Performing I2C bus recovery
[15:48:53][D][esp-idf:000]: I (991) gpi[I][wifi:313]: WiFi Connecting to 'Cetra'...
[15:48:53][W][wifi_esp32:244]: esp_wifi_set_mode failed: ESP_ERR_WIFI_NOT_INIT
[15:48:53][E][wifi:369]: wifi_sta_connect_ failed!
[15:48:56][D][esp32.preferences:114]: Saving 1 preferences to flash...
[15:48:56][D][esp32.preferences:142]: Saving 1 preferences to flash: 1 cached, 0 written, 0 failed
[15:48:56][I][wifi:313]: WiFi Connecting to 'Cetra'...
[15:48:56][W][wifi_esp32:244]: esp_wifi_set_mode failed: ESP_ERR_WIFI_NOT_INIT
[15:48:56][E][wifi:369]: wifi_sta_connect_ failed!
[15:49:01][I][wifi:313]: WiFi Connecting to 'Cetra'...
[15:49:01][W][wifi_esp32:244]: esp_wifi_set_mode failed: ESP_ERR_WIFI_NOT_INIT
[15:49:01][E][wifi:369]: wifi_sta_connect_ failed!
[15:49:06][I][wifi:313]: WiFi Connecting to 'Cetra'...
[15:49:06][W][wifi_esp32:244]: esp_wifi_set_mode failed: ESP_ERR_WIFI_NOT_INIT
[15:49:06][E][wifi:369]: wifi_sta_connect_ failed!
[15:49:06][D][wifi:697]: Retrying with hidden networks...
[15:49:11][I][wifi:313]: WiFi Connecting to 'Cetra'...
[15:49:11][W][wifi_esp32:244]: esp_wifi_set_mode failed: ESP_ERR_WIFI_NOT_INIT
[15:49:11][E][wifi:369]: wifi_sta_connect_ failed!
[15:49:11][D][wifi:697]: Retrying with hidden networks...
[15:49:16][I][wifi:313]: WiFi Connecting to 'Cetra'...
[15:49:16][W][wifi_esp32:244]: esp_wifi_set_mode failed: ESP_ERR_WIFI_NOT_INIT
[15:49:16][E][wifi:369]: wifi_sta_connect_ failed!
[15:49:16][W][wifi:690]: Restarting WiFi adapter...
[15:49:19][D][text_sensor:064]: 'Uptime Human Readable': Sending state '34s'
[15:49:19][D][sensor:093]: 'Uptime Sensor': Sending state 34.09800 s with 0 decimals of accuracy
[15:49:21][I][wifi:313]: WiFi Connecting to 'Cetra'...
[15:49:21][W][wifi_esp32:244]: esp_wifi_set_mode failed: ESP_ERR_WIFI_NOT_INIT
[15:49:21][E][wifi:369]: wifi_sta_connect_ failed!
[15:49:26][I][wifi:313]: WiFi Connecting to 'Cetra'...
[15:49:26][W][wifi_esp32:244]: esp_wifi_set_mode failed: ESP_ERR_WIFI_NOT_INIT
[15:49:26][E][wifi:369]: wifi_sta_connect_ failed!
[15:49:31][I][wifi:313]: WiFi Connecting to 'Cetra'...
[15:49:31][W][wifi_esp32:244]: esp_wifi_set_mode failed: ESP_ERR_WIFI_NOT_INIT
[15:49:31][E][wifi:369]: wifi_sta_connect_ failed!
[15:49:36][I][wifi:313]: WiFi Connecting to 'Cetra'...
Hi, could someone possibly help me? I have Waveshare 7" and 4.3" displays, and I’m trying to add an XL9535 2-channel relay using the YAML code below.
I’ve tested the code and relays on an ESP32 WROOM using SDA: 21 and SCL: 22, and everything works fine. So I connected it to both my 7" and 4.3" screens, changing to SDA: 8 and SCL: 9. For the most part, it works.
The problem I have is that I cannot control Relay 1 - Relay 2 works. I’ve tried changing the pin number from 0–7 and 10–17, but nothing works. I’ve also tried changing inverted: false to true, but there’s no change.