Today we will use the DHT22 sensor and NodeMCU platform to make a smart thermometer.
For this project you will need:
- DHT22 Temperature and Humidity Sensor
- NodeMCU – D1 Mini
- Some wires
- Soldering kit for beginners
- Node-RED (optional but recommended)
Step 1: Soldering NodeMCU and temperature sensor
Cut the connectors and strip the wires. Below you will find pictures of how you should solder them.
Take a look at the DHT22 pinout to figure out the pins. First pin should be connected to 5V, second to D3 and fourth to the ground.
Step 4: Uploading Tasmota to NodeMCU
Connect the microusb cable to WeMos/NodeMCU and open nodeMCU-flasher. In the first tab (Operation) select the COM port for your device. In the second tab (Config) select the Tasmota .bin file.
On the advanced tab, please make sure the settings are matching:
Click on “Flash” and get your phone ready .
When the upload is done, the board will create an access point for you to connect to. Search for a “sonoff-…” open wifi network and connect to it. Open your favorite browser and type http://192.168.4.1
You will get a wifi setup page as shown in the picture below. Enter your wifi network details and click save.
For further configuration you will have to find your device on your network. You can scan the entire network or take a look at the dhcp list on your router.
Step 3: Module Configuration
After you have successful connected the board to your wifi network open a browser and navigate to its IP.
Click on the “Configuration” button and then “Configure Module”. Select “18 Generic” as your module type and hit save. The device will restart.
Again open the “Configuration Module” and set “D1 GPIO0” to “03 SI7021” then save.
You should have something like this:
These steps are identical to the ones found in our “Smart Relay” tutorial.
Step 7: Add your smart thermometer to Node-RED
We will need a MQTT input node, a json node, a change node and an output ui-text node.
MQTT input node configuration:
- Server: mqtt.iotwithus.com
- Topic: (the topic you chose at Step 4)/tele/SENSOR
- QoS: 2
- Name: Temperature (or whatever you want to name the node)
Ui-text output node:
Let’s add a group for our smart thermometer. Double click on the node and select “Add new ui_group” from the dropdown list and then the pencil icon. We will name it “Smart Thermometer”.
The node settings should be:
Navigate to http://your-node-red-ip/ui
The output will be in degrees Celsius. Converting it in Fahrenheit is the “homework” for you. If you know how to do it, post the solution in the comment section.