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 on ESPHome, see: www.libe.net/en-esp-home

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Publication: 2023-03-09 from Bernhard | Übersetzung Deutsch |🔔

DS18B20 Temperature Sensors ESP32, MQTT and WiFi - HowTo | ESP

Top articles in this section


ESP32 Flowmeter - RS485 Modbus

As described in the first article of this series, my first goal was to read out a TUF-2000M Ultrasonic Flow Meter via an ESP32. For this purpose 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 the TUF-2000M via RS485, it must first be c...


ESP32 WiFi example

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.


ESP32 MQTT - Send data

To be able to receive data from an ESP32, I have prepared an MQTT broker as a Docker container. The container can be integrated into Home-Assistant and thus forward the data from the ESP32 to Home-Assistant via MQTT. On the part of ESP32, I tested sending with the following sketch and later integrated the relevant parts into another sketch.

Questions / Comments