DS18b20

Environment - DS18b20 NORMAL

../_images/P004_DS18b20_1.jpg

Introduction

The DS18B20 manufactured by Dallas and Maxxim is a very simple to use temperature sensor with a tolerance of +/- 0.5°C.

Note

Cheap remakes from Chinese market might have bigger tolerance and also might have different pinouts.

It’s advantages: very simple to use due to “1-wire” data protocol. Chainable, it is possible to chain up to 100 sensors on one cable (remember ESP Easy has 12 tasks max…). No calibration necessary if the tolerance fits your needs as the sensor gives digital data directly. Many forms available from bare chip to waterproof and tube sensors.

Specifications:
  • Temperature (-55C to +125C)

  • Voltage requirements: 3.3-5V

Note

The DS18B20 runs well on 3.3V so no level shifter or special power supply is needed. But the official statement is that you should use 5V and a level shifter if you have multiple sensors on a long wire.

Wiring

../_images/P004_DS18b20_5.jpg
ESP               DS18b20
GPIO (14)  <-->   1-wire/D (yellow)

Power
3.3/5.0V   <-->   VDD (red)
GND        <-->   GND (black)

The sensor needs a pull up resistor. If you use the breakout board type the resistor usually is already on the board. This gets you into problems if using several DS18B20 breakout boards. There should be only one resistor fore the entire line so you might have to remove resistors leaving just one at one end of the line.

Do not use very thin cabling! Tested with a 3x0.14mm² cable the length with 5 Sensors was 10 meters, longer cabling did not work. Use a phone line cable (2x2x0.6mm²) instead if you need long distances up to 50..100 meters. remember: One (!) pull-up resistor for the whole line!

The preferred structure is a straight line. If possible avoid “stubs”. If necessary it can be cabled in a “star” infrastructure. But be aware that stubs and star form reduce the possible cable length.

Setup

../_images/P004_Setup_DS18b20_1.png

Task settings

  • Device: Name of plugin

  • Name: Name of the task (example name TempN, where N is a number).

  • Enable: Should the task be enabled or not

Sensor

  • GPIO <–> 1-wire: Pulse input is generally set to GPIO 14 (D5).

after pressing submit the following settings are revealed:

  • Device address: Pick your sensor address, hold your hand around it to see which one is changing temperature.

    Every DS18b20 has a unique address burned in at production time. This UID (Unique IDentifier) is used to tell the sensors apart on one single cable.

  • Device resolution: 9..12 bits, the lower the resolution the accuracy decreases and the speed increases.

    As temperatures do not change very fast usually a high accuracy can be chosen without problem.

Note

If you need a star infrastructure or stubs or if you need just longer cabling there is a way out. One line runs on one GPIO. But nobody said you can’t use two GPIO’s. If the cabling gets too long or you have too much stubs or star cables try to split into two circuits. Place the ESP in the mid and cut the line into two circuits, for example “Ground Floor” and “1st Floor”. Use two GPIO’s, one for each circuit.

Note

Usually the DS18B20 works without issues. It’s also usual that most problems result from cabling mistakes. With long cabling you might get wrong data sometimes. It might be helpful to reduce the resistor a bit, 2.2 kOhm is lowest possible. If nothing works disconnect all sensors from line and connect back one by one, checking every time. Cable may be too long (or too thin for the given distance). Keep cabling away from other cables to avoid interferences. If necessary place a 10µF capacitor on the sensors between 3.3v and GND.

Data acquisition

  • Send to controller 1..3: Check which controller (if any) you want to publish to. All or no controller can be used.

  • Interval: How often should the task publish its value (5..15 seconds is normal).

Rules examples

On Temp1#Celsius Do
 If [Temp1#Celsius]>37
   NeoPixelAll,255,0,0 //Your body temperature is too high!
 Else
   NeoPixelAll,0,255,0 //Body temperature is OK.
 EndIf
EndOn

Where to buy

Store

Link

AliExpress

Link 1 ($)

Banggood

Link 2 ($) Link 3 ($) Link 4 ($)

eBay

Link 5 ($)

$ = affiliate links which will give us some money to keep this project running, thank you for using those.

More pictures

../_images/P004_DS18b20_2.jpg ../_images/P004_DS18b20_3.jpg ../_images/P004_DS18b20_4.jpg