Home Elements Boards Recipes

Dallas Element

The DallasElement allows retrieving temperature values from DS18B20 aka. Dallas Temperature sensors and creates actions when new values are available.

Dallas pins

The DS18B20 is a temperature sensor most often in a simple to-92 housing like a transistor. Other forms and types are also available including those that can be in contact with water or other liquids without getting damaged.

The data transmission is using 1 wire only (the OneWire protocol). In addition to the sensor a 4.7k resistor is required to pull up the data line.

There have been older versions of this chip like DS1820 and DS18S20 and less accurate sensors like the DS18B20 so today the DS18B20 version is the most current one so only this type is supported by the element implementation.

See information in the links to application notes below.

Web UI for the DS18B20 Element

There is a dedicated card for this element available that shows the actual temperature.

Dallas Sensor UI

Using the Dallas Element

The Dallas Element is not part of the core set of elements because the low level communication to the chips the OneWire library is used and needs to be installed using the Arduino library manager.

The OneWireand the DallasTemperature library is required by this element and installed as dependency when installing the library.

The HOMEDING_INCLUDE_DALLAS must be defined in the main sketch to compile and register the element.

// Use some more Elements that need additional libraries
#define HOMEDING_INCLUDE_DALLAS
#include <HomeDing.h>

Connecting a Sensor

The Sensor can be driven by using the GND and 3.3 VCC from the processor board and only one data line to a free GPIO port.

In addition to the sensor a 4.7k resistor is required to pull up the data line.

ESP8266 ESP32 DS18B22 Description
GND GND 1 GND Ground
GPIO2(D4) IO32 2 Data Data with 4.7 K Resistor to VCC
3.3v 3.3v 3 VCC Power Supply

Element Configuration

The following properties are available for configuration of the element:

pin* - Specifies the hardware number of the pin that is used to connect the Dallas sensor for data.

onTemperature - These actions are emitted by the element when the temperature gets a new value. The action will not be sent when reading ne sensor values that stay the same.

From the base Sensor Element implementation the following properties are available for configuration:

readTime – Time between 2 probes being fetched from the sensor. Default value is 1m.

resendTime – The current values of the probe are resent after this specified time even when not changing.

warmupTime – This time is waited after powering the sensor on the first start or after a reset before the first data is fetched. The default time is set to 3 seconds.

restart – This property can be set to true to enable an automated restart when the sensor was not responding data.

From the base element implementation the following properties are available for configuration:

title – Caption text for the element. Used by the element specific cards on the dash boards.

description – A line of text that gives a short description of the device used in the web UI.

room – The location of the device.

loglevel – This property holds the element specific log level. The default value is LOGGER_LEVEL_ERR == 1.

startup – This property can be used to start the element using a different initialization phase. Possible values are “sys”, “net”, “time”. See The Startup sequence.

* This parameter must be specified.

Configuration Example

This example shows how to configure this element:

{
  "dallas": {
    "on": {
      "pin": "D4",
      "readtime": "10s",
      "resendtime": "60s",
      "ontemperature": "displaytext/temp?value=$v"
    }
  }
}

Element State

The following properties are available with the current values at runtime

active - Is set to true when the Element is active.

temperature - The last read temperature value from the sensor.

Example State

{
  "dallas/on": {
    "active":"true",
    "temperature":"27.30"
  }
}

See also

Notes from manufacturer:

Tags

Element Sensor