My actual goal was a device based on a Wemos Mini D1 and ESPHome ESPHomeFramework for configuring ESP32/ESP8266 microcontrollers that automatically integrate into Home Assistant. Ideal for DIY sensors and actuators to read out several 1-Wire temperature sensors that I mounted on the flow and return lines of our heating system, as well as at the top, middle and bottom of our buffer storage tank. The 1-Wire sensors of type DS18B20 are not only affordable and sufficiently accurate for this task, but can also be extended well and about 100 sensors can be operated on a single data line.
In my case, however, it’s only about 9 sensors: underfloor heating flow/return, wall radiator flow/return, water-carrying fireplace flow/return and the 3 sensors in the buffer storage tank.
⚠ [affiliate] Keine Produkte mit Cache für home-assistant.
Bitte affiliate-sync --lang en ausführen.

However, I always find it a shame when you use an ESP for only one task and leave the other pins unused. So why not also use a BME280 sensor right away to measure the humidity and temperature in the utility room? Thanks to the built-in air pressure sensor, you can then also have the absolute humidity and dew point calculated.
And if you already have the data, wouldn’t a display be quite nice? I also had some Nokia 5110 displays from the PCD 8544 lying around. With its 84x48 pixels, it is optimally suited for this task. With the right font, you can display 6 lines of 14 characters legibly. You simply get more on it than with a two-line HD44780 display and can also use graphics.
In addition, the ESPHome platform also supports “Pages” for this display, so you can very easily scroll through several pages and displays and thus present a lot of information clearly. However, scrolling also requires a control element and here I decided on a simple button, because there weren’t enough pins left for a rotary encoder. On the other hand, the display can be controlled in brightness via Home Assistant and a WS2812 LED strip with 8 RGB LEDs provides information about various operating states.
The build
It’s always a good idea to first build and test such more extensive projects on a breadboard before you dare to pick up the soldering iron. If the flying build works as desired, you can then tackle the implementation on a circuit board.

I’ve always been a fan of stripboard. I tinkered with it when I was 9 years old, worked with it during my apprenticeship and I prefer the stripboard philosophy to those solder rivers on perfboard. I also follow the “pure doctrine”, namely that wire bridges only run in one direction. Wemos Mini, display and BME280 sensor are plugged in so that they could also be quickly replaced.

For connecting the 9 1-Wire sensors, I decided on 9-pin spring clamp terminal blocks . 3 of them fit next to each other on a Euro board width and are ideally suited for the thin wires of the DS18B20 sensors. The data line of the sensors must be pulled to High (3.3 volt operating voltage) with a 4.7 kOhm resistor and a 10 uF electrolytic capacitor directly at the power supply of the sensors ensures more stable operation. The 1-Wire sensors are always connected in the order DATA (Yellow), VCC (Red), GND (Black) from left to right.

The complete build fit on less than half a Euro card and looks quite neat in my opinion.

Of course, you could also design and have a real circuit board made. However, I will only need this build once, so the effort is not justified here and a cleanly built stripboard is just as reliable.
Programming with ESPHome
ESPHome is a grandiose solution for your own sensors and actuators. It is based on Arduino libraries, but is mainly configured with YAML YAMLData format (YAML Ain’t Markup Language). Used in Home Assistant for configurations, automations and scenes. Easy to read but error-prone with incorrect indentation rather than programmed. Nevertheless, complex functions and calculations can also be implemented with it, by using so-called lambdas to also use C code within the YAML configuration. However, what simplifies programming even further is the integration of the ESPHome platform directly into Home Assistant. If you have the ESPHome integration in HA, you can do without flash tools, etc.
For this, you only need the Chrome browser or Edge (presumably other browsers based on Chromium also work), because these offer the Web Serial interface. With this, you connect the ESP via USB to the computer you’re currently sitting at, open the ESPHome integration in HA in the browser and can flash the ESP directly with it. The only important thing here is that the connection to Home Assistant is via SSL.

Once you’ve done that, the newly created and flashed ESP is displayed as “online” in the ESPHome interface and can be programmed directly via the web interface from then on. The logs of the ESP are also output via it and ESPs can also be updated from there. I used to use Tasmota TasmotaOpen source firmware for ESP8266/ESP32-based smart home devices (sockets, lights, relays). Replaces manufacturer firmware for local control without cloud and ESPeasy , but ESPHome is so much simpler, more elegant and more flexible to use - especially if you have several such devices in use. The ESPHome devices can be programmed from practically anywhere you have access to your Home Assistant server.
The code for the multi-sensor with display
Here is the complete program code of my ESPHome multi-sensor. The YAML configuration is largely self-explanatory. The most important sections are explained in detail below the code.
|
|
Since I don’t need the serial interface of the ESP, I disable logging for it in line 8. This allows me to use the two pins as normal GPIOs.
The most important configurations and functions in detail
Much in the code are standard functions that you can simply look up. I’d like to briefly explain the more interesting parts individually here.
The WS2812 LED strip with 8 RGB LEDs is set up with the fastled_clockless platform. For each LED, the partition platform is created so each LED can be addressed individually later. For example, you could use it to indicate when you should ventilate or when the heating burner is active.
The display backlight is connected to the former RX pin (GPIO03) and can be controlled and dimmed from HA via PWM.
The DS18D20 1-Wire temperature sensors are defined with their unique IDs. Either you connect each sensor individually one at a time, note down the ID and mark it on the sensor, or you connect all sensors at the same time, briefly warm up each sensor and check in the log which ID is currently showing a higher temperature.
The ESP uptime is converted into a human-readable format (e.g. “2d 5h 30m 15s”) using a lambda function, so it can be nicely displayed.
Sensors from Home Assistant can also be read - here I get the outside temperature from my LCN LCNLCN (Local Control Network) – German bus system for building automation by Issendorff. Uses existing 230V wiring as bus line. Can be integrated into Home Assistant via LCN-VISU or custom integration -WIH weather station.
With lambdas and C code, the absolute humidity, altitude-corrected air pressure and dew point are calculated from the BME280 values. The formulas come from the internet. For the air pressure, make sure to enter the correct altitude - the BME280 outputs uncompensated values.
The Nokia 5110 display - fonts, icons and display
Fonts must be defined for the Nokia 5110 PCD8544 display. Any TrueType font (.ttf) can be used, but for the smallest legible display, 7x5 pixel fonts are ideal. I use the hd44780.ttf for small text and VCR_OSD_MONO.ttf for large values. The fonts are loaded into a directory below the esphome directory via the VSCode integration in HA.

Icons (thermometer, water drop, 3 smileys for humidity) are defined as GIF files. I only had success with GIFs - PNGs always showed a black block.

The display is configured with the pcd8544 platform. The contrast setting is critical: the official documentation specifies 0x7f, but this results in a completely black display. With 0x3f, the font is displayed ideally.
With pages, content is distributed across multiple display pages. Page1 is the main screen showing room temperature and humidity with icons, absolute humidity, a smiley based on humidity level, and the current time/date. Pages 2-5 show the heating circuit temperatures, page 6 shows network information.

A button on GPIO01 with internal pullup switches through the display pages.

Tips
There are many discussions about the BME280 sensor online. The sensor was originally developed by Bosch . According to the Bosch datasheet , the sensors must be soldered in a special process and then dried and burned in under defined conditions.
With the cheap Chinese sensors, you can’t really be sure whether they are Bosch types or copies, and the processing process is certainly not adhered to. That’s why it’s always said that these Chinese variants are inaccurate. However, if you make sure that the sensor is mounted as far away from heat sources like the ESP8266 as possible and the leads are as long (and thin) as possible, the BME280 delivers very accurate values according to my experience and also comparison measurements with saturated salt solutions (see also: /guenstige-xiaomi-mijia-ble-sensoren-mit-home-assistant-nutzen/ ).
Often the expectation of a measurement is simply nonsense. It’s not about getting the best and most accurate measurement, but the measurement that fits the application. The air temperature differs even in small rooms and depending on the measurement height and position in the room, not infrequently by 2 °C. The same applies to humidity. So is 22.7 °C more correct than 23.4 °C? No! Because if you omit the decimal place, a completely sufficient 23 degrees would come out as the measurement for this application.

Yet even here, the measurement says nothing about whether you feel comfortable at this temperature. The comfort climate is defined by temperature, humidity and air movement. The perceived temperature increases with rising humidity and vice versa. 21 °C air temperature feels like 23 °C at 55% rel. humidity and like 26 °C at 75%. That’s why quite warm but dry heating air in winter doesn’t feel as muggy as one would often expect. If a slight air movement is also added, 23 °C can feel like 20 °C.
You should hang all DS18B20 sensors in a bucket of water whose temperature has been measured with a trustworthy thermometer. This allows you to select the sensors by accuracy and deviation. When measuring the flow and return of a low-temperature heating system, 1 °C deviation already makes a difference. If the return temperature is then higher than the flow, you can’t build a sensible control on it. Therefore, both sensors should deliver the same relative measurements. Deviations from the actual measurement can then possibly also be compensated via software.
Components and costs
The entire project costs less than 10 euros. The 5110 displays are available for less than 2 euros from various Chinese suppliers (pay attention to the new regulations for shipping from China - see HERE !). An ESP Wemos Mini also only costs 2 euros. If you order it from Germany, you have to reckon with about 4.50 euros. BME280 sensor , circuit board and the terminals are available for another 3-4 euros.
Not included in the costs are the DS18B20 1-Wire sensors. You can get 10 pieces for under 20 euros . Based on this basic code, you can cheaply produce many universal smart home sensors with a display. Since you have both an I2C and an SPI bus available, you can easily integrate additional sensors and thus expand the range of functions according to your own wishes and requirements.
What do you think? Leave a comment!
Share your thoughts, questions or experiences with the community.