Temperature Sensor Tutorial for DS18B20 and DS1822, DS1820, MAX31820, MAX31850

In this section we’ll walk through creating a Temperature Sensor using ESP32, ESP8266 and then view the temperature via Alexa, Google Home or SmartThings.

Prerequisites :

  1. ESP32, ESP8266 x 1.
  2. DS18B20 or DS1822, DS1820, MAX31820, MAX31850 x 1.
  3. 4.7k Ohm resistor x 1
  4. Jumper Wires.

Quick introduction to Temperature Sensor

The DS18B20 is a digital temperature sensor that communicates over a 1-Wire bus. It is a popular choice for many applications, including home automation, environmental monitoring, and industrial automation. The DS18B20 works by measuring the resistance of a thermistor. The thermistor is a semiconductor device whose resistance changes with temperature. The DS18B20 has a built-in 12-bit ADC that converts the thermistor’s resistance to a digital value.

Wiring

Sinric Pro esp8266 DS18B20 wiring

If you are using the DS18B20, ground pins 1 and 3. The centre pin is the data line ‘1-wire’.

MCU GPIO Pin
ESP32 16
ESP8266 14 (D5)

Let’s verify that temperature is wired correctly and working.

Arduino IDE Serial Monitor will show the current temperature like this

Sinric Pro DS18B20 Temperature Sensor

Step 1 : Create a new device in Sinric Pro

Sinric Pro create device alexa

Sinric Pro temperature sensor device notifications

You can set the threshold here to receive a push notification via the Sinric Pro app when the temperature goes below or above a certain temperature. Use the Retrigger Time to set the delay between notifications.

Sinric Pro copy device id

Step 2 : Connect to Sinric Pro

Step 2.1 Install Sinric Pro Library

Sinric Pro install SinricPro library

You can generate the code using Zero Code feature or write it by your self. If you do not have programming experice, we recommend to use Zero Code feature in the Portal to generate the code, download and flash.

2.2 Complete Code

Now you should be able to view the temperature via Sinric Pro App

Sinric Pro App Temperature Sensor

Please note that Google Home App shows the temperature sensor as a Thermostat due to Google Home limitations.

Troubleshooting

  1. error: DallasTemperature.h: No such file or directory

    Solution: Please make sure correct temperature library is installed. https://github.com/milesburton/Arduino-Temperature-Control-Library

  2. Reading invalid values like -127.00C, -196.60F, -127.00C, -196.60F

    Solution: Make sure you have wired correcrly or you do not have loose connection.

Sinric Pro App Temperature Sensor

  1. Please refer to our Troubleshooting page for more details.

This document is open source. See a typo? Please create an issue