Skip to content

DS18x20 temperature sensor~

DS18x20 driver supports DS18B20, DS18S20 and DS1822 1-Wire digital temperature sensors.

Configuration~

Wiring~

DS18b20 ESP266
1 GND GND
2 Data GPIO 0..15
3 VCC 3.3v

Warning: DS18x20 is not supported on GPIO16

You need to connect a 4.7K pullup resistor from data to 3.3V.
Wiring

Tasmota Settings~

In the Configuration -> Configure Module page assign:

  • GPIOx to DS18x20 (4)

After a reboot webUI will display temperature measured.

Sensor sends a tele/%topic%/SENSOR JSON reponse:

{"Time":"2019-01-01T00:00:00","DS18B20":{"Temperature":49.7},"TempUnit":"C"}

Commands~

SetOption74 is used to enable/disable internal pullup when using a single DS18x20 sensor (for multiplse sensors, you must use an external pullup resistor).

TempOffset can be used for calibrating the measured temperature. This setting affects all temperature sensors on the device.

Multiple Sensors~

Tasmota supports multiple DS18x20 sensors connected to a single ESP8266 chip using a single GPIO (multiple DS18x20 GPIO are not supported). The default maximum is set to 8 (driver code). It is possible to override this number in user_config_override.h by adding a line with #define DS18X20_MAX_SENSORS <new-value> (ESP8266 only). However one should take into account that:

  • Display on the console is limited and SENSOR log will be truncated above 11 DS18x20.
  • MQTT buffer length is limited and SENSOR message will be truncated above 18 DS18x20.
  • Even less if other sensors are attached to the ESP device and present in the SENSOR message.
  • 1-wire has been designed to be a board-bus, not to run through long distances across a whole house. At minimum, use a shielded cable.

Note

If you increase the value above default, you are on your own. No support will be provided.

multiple wiring

Every sensors will get a unique ID used in webUI and MQTT telemetry.

{"Time":"2021-01-02T09:09:44","DS18B20-1":{"Id":"00000566CC39","Temperature":13.3},"DS18B20-2":{"Id":"0000059352D4","Temperature":1.2},"DS18B20-3":{"Id":"000005937C90","Temperature":22.5},"TempUnit":"C"}

Sensor Versions~

Sensor variations

Pinout when looking at the flat side of the TO-92 package sensor: GND, Signal, VDD. Pinout of the wired sensor: black: GND; yellow or white: Signal, red: VDD

ESP01 Module~

Danger

BEWARE OF MANY VISUALLY SIMILAR BOARDS TO THIS RELAY BOARD but different schematics

ESP-01S

Some modules have culprits: * "CH_PD" is not set to HI (3.3V) as actually required. Usually this is done with a 10K resistor or directly to 3.3V, I have connected directly to the 3.3V * A resistor (R2 10k) which is connected between the terminal GPIO0 to ground. This ensures that the GPIO0 is always pulled to ground, which actually places the ESP-01 in program mode (flashing). To make the module working it is necessary to remove (solder out).

Connect DS18B20 to the GPIO2 (see diagram below - soldering not necessary, it is possible to put the wires and the resistor directly in to the female part of the connector together with ESP 01S module pins)

After flashing, set up Tasmota (see images below): * "Generic module" * GPIO0 as Relay1 (21) * GPIO2 as DS18x20(4)

Retrieving the temperature via HTTP

http://tasmota-ip/cm?user=<USER>&password=<PASS>&cmnd=status%2010

The temperature information will put published by MQTT to the tele/%topic%/SENSOR in the format of:

"Time":"2018-06-14T07:56:34","DS18B20":{"Temperature":21.9},"TempUnit":"C"}

Rule Triggers~

The following trigger events are supported for use in Rules:

Single sensor attached:

  ON DS1820#Temperature DO <command> ENDON
Multiple sensors attached:
  ON DS1820_1#Temperature DO <command> ENDON
  ON DS1820_2#Temperature DO <command> ENDON
  ON DS1820_3#Temperature DO <command> ENDON
  ON DS1820_..#Temperature DO <command> ENDON
Example:
 ON DS1820_1#Temperature!=%Var1% DO backlog publish espTempertature/sensor/DS1820_1/data %value%; Var1 %value% ENDON