Nextion display with ESP8266 microcontroller (Wemos D1 mini) showing Home Assistant temperature sensors (temperature inside, outside and in the swiming pool) and weather forecast from the internet. But you might display any Hassio sensors, so if you wish to create own weather forecast, you can do that.
The Nextion display is connected via 4 wires: GND, +5V, RX, and TX. So to control the display is extremely easy - just connect these 4 wires to the corresponding ports in an Arduino board and you are set. In this project, I am using Wemos D1 mini. But in some other projects, I have the display connected to Sonoff 4ch or even Sonoff Basic (the only challenge with these is to find the pin with 5V, but this is not that hard).
The principle is very simple: I used Nextion Editor to create a layout for the display screen. There is a static image background with all graphics that do not change (including text, icons, frames, or color background). On top of the background, I created text or image objects for all the values that change. When the design is finished, you can upload the layout to the display from the NextionEditor using the serial connection (via USB FTDI board).
The program is then very simple - it just sets the text value for the individual text objects. For example, for the inside temperature it does this:
it.set_component_text_printf("inside","%2.1f",id(temperature_inside).state);
ESPHome can read Home Assistant sensors through API, so the ESPHome sensor "teplota_uvnitr" is linked to Home Assistant sensor sensor.teplota_uvnitr this way:
sensor:
- platform: homeassistant # Inside temperature
id: teperature_inside
entity_id: sensor.temperature_inside
The weather forecast uses a picture - I have loaded set of icons through the NextionEditor, so all I do us to change the picture id this way:
it.send_command_printf("%s.pic=%.0f", "weather",id(today_icon).state);
For the ESPHome to communicate, the HMI also needs to be configured not to send responses on the commands. It is also a good idea to increase the port speed. To do that, in the Nextion Editor, in the Program.s
tab, add these two commands before the page
line.
baud=115200
bkcmd=0
It is using the 2.4 inch Nextion display.
There are two more "nice to have" features: