ESPHome: Temperature and humidity sensors DHT11/22
For temperature measurement in Home Assistant, there are a variety of different sensors and ways to integrate them. When using Zigbee, for example, Aquara sensors are available, but these have a decisive disadvantage: the battery. It has to be replaced after 2 years at the latest. A cost-effective and more robust alternative to battery-powered sensors is provided by an ESP32 microcontroller. With the right wiring, a single microcontroller can measure the temperature and/or humidity of all possible rooms in a house. Purely for a temperature measurement ,DS18B20 temperature sensors could be used. If you want to measure humidity as well as temperature, you can useDHT11 or DHT22 sensors.
Wiring
ESP Home Project
esphome:
name: esp
friendly_name: esp
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "???"
ota:
password: "???"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Test Fallback Hotspot"
password: "???"
sensor:
- platform: dht
pin: GPIO33
temperature:
name: "Room1 Temperature"
humidity:
name: "Room1 Humidity"
update_interval: 60s
captive_portal:
Incorporated in HA:
Conclusion
Placed relatively centrally, a single ESP32 microcontroller can provide a variety of sensors. In my house, an ESP32 in the boiler room ensures that in addition to the temperature values of the heating system, I can also record the outside temperature and the temperature and humidity values of certain rooms. Furthermore, the microcontroller monitors the water flow of the heating and controls it via a relay board.

{{percentage}} % positive

THANK YOU for your review!
Top articles in this section
Complementary to the article: DS18B20 Temperature Sensors ESP32, MQTT and WiFi - HowTo, I have meanwhile replaced the Arduino project with ESP-Home. Simple projects can be implemented much easier in ESPHome. As an example, in ESPHome these 2 lines are enough to address the temperature sensors:
As described on the article ESP32 programming, Arduino - install requirements, my first goal was to read out a TUF-2000M Ultrasonic Flow Meter via an ESP32. I found an example for an ESP8266 on the internet: Reading a TUF-2000M Ultrasonic Flow Meter with an Arduino or ESP8266 and https://forum.arduino.cc/t/comunicacion-rs485/698786/2. I described the setup of the TUF-2000M in the following article: Field Report: Ultrasonic Flow Meter TUF-2000M. To be able to read out the TUF-2000M via RS485, it...
In preparation for uploading sketches to a microcontroller, I installed the ESP32 board infromations and a USB to UART bridge driver, see: Preparations for programming an ESP32.