DS18B20 - Temperature sensors in ESP-Home
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:
dallas:
- pin: GPIO14
If the microcontroller is programmed, the IDs of the sensors appear in the output:
[09:58:14][D][dallas.sensor:082]: Found sensors:
[09:58:14][D][dallas.sensor:084]: 0xf2031689c848ff28
[09:58:14][D][dallas.sensor:084]: 0xea031689ce28ff28
[09:58:14][D][dallas.sensor:084]: 0xee031689cab2ff28
[09:58:14][D][dallas.sensor:084]: 0xcb0416928fceff28
[09:58:14][D][dallas.sensor:084]: 0x5d041692c80bff28
The IDs can be used in the YAML config file as follows:
dallas:
- pin: GPIO14
# Individual sensors
sensor:
- platform: dallas
address: 0xf2031689c848ff28
name: "heating/t1"
- platform: dallas
address: 0xea031689ce28ff28
name: "heating/t2"
...
The whole project will look like this:
esphome:
name: heating
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: "Heating Fallback Hotspot"
password: "??"
captive_portal:
dallas:
- pin: GPIO14
# Individual sensors
sensor:
- platform: dallas
address: 0xf2031689c848ff28
name: "heating/t1"
- platform: dallas
address: 0xea031689ce28ff28
name: "heating/t2"
...
For details about ESPHome, see: esp-home
An alternative to the DS18B20 sensors offer DHT11/DHT22 temperature and humidity sensors
{{percentage}} % positive
THANK YOU for your review!
Top articles in this section
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...
With ESPHome it is very easy to program your own microcontroller for use in HomeAssistant. My first use for a self-programmed microcontroller was to record the water flow and temperature values of my heater, see: ESP32 programming, Arduino - install requirements.
To be able to switch certain relays in Home Assistant via an ESP32, I tested a relay board and integrated it via ESP-Home.