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.
- ESP32, ESP8266 x 1.
- DS18B20 or DS1822, DS1820, MAX31820, MAX31850 x 1.
- 4.7k Ohm resistor x 1
- 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.
If you are using the DS18B20, ground pins 1 and 3. The centre pin is the data line ‘1-wire’.
Let’s verify that temperature is wired correctly and working.
Arduino IDE Serial Monitor will show the current temperature like this
Step 1 : Create a new device in Sinric Pro
- Login to your Sinric Pro account, go to Devices menu on your left and click Add Device button (On top left).
- Enter the device name Temperature Sensor, description My Temperature Sensor and select the device type as Temperature Sensor.
- Click Next the in the Notifications tab
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.
Click Others tab and Click Save
Next screen will show the credentials required to connect the device you just created.
- Copy the Device Id, App Key and App Secret Keep these values secure. DO NOT SHARE THEM ON PUBLIC FORUMS !
Step 2 : Connect to Sinric Pro
Step 2.1 Install Sinric Pro 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
Please note that Google Home App shows the temperature sensor as a Thermostat due to Google Home limitations.
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
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.
- Please refer to our Troubleshooting page for more details.
This document is open source. See a typo? Please create an issue