*NOTE* THIS PROJECT IS DONE BY A GROUP OF SINGAPORE POLYTECHNIC STUDENTS
The tools and components were provided by our FYP supervisor Mr Teo Shin Jen.
Today, we'll be briefly touching upon interfacing a DHT11 with a NodeMCU board. In my personal context, I'm using the setup to monitor the change in ambient humidity and temperature in an enclosed space with food.
In a future iteration, I will show you how to interface a Thermopile to take temperature measurements off the surface of the food so that you'll be able to know how hot the food is!
Step 1: Bill of Materials
Firstly, let's discuss what's needed for this simple project!
1. 1 x NodeMCU Amica LUA R2 Board
2. 1 x DHT11/DHT22 Humidity/Temperature Sensor
3. 1 x Stripboard
4. 1 x 2.2kΩ resistor
5. Single Core Cable (for making some connections)
(available from: http://benlo.com/esp8266/)
Step 2: Circuit Diagram
Now, here's how the thing works. Make the following connections (as per the circuit diagram)
1. Connect the Data Output Pin to Pin D4 of the NodeMCU board.
2. Connect a 2.2kΩ resistor between the data pin and the power supply pin. This pulls up the data pin to the relevant input voltage.
3. Connect the 3.3V pin to the power supply pin of the DHT 11, and logically, the ground pin of the DHT11 is connected to the ground pin of the NodeMCU board.
Step 3: Upload Code
The code used from the following GitHub link is used to program the NodeMCU board:
Do note that in the init.lua file (edit this file in your favourite editor of choice, e.g. Notepad++), change the following line:
wifi.sta.config("SSID","PASSWORD"), where SSID is the name of the WiFi connection which you are trying to connect to, and PASSWORD, is the password.
In the dht11.lua file, make the following changes:
1. (Replace XXXXXXXXXX) with the API key given in your ThingSpeak account channel.
conn:send("GET /update?key=XXXXXXXXXX&field1="..Temperature.."."..TemperatureDec.."&field2="..Humidity.."."..HumidityDec.." HTTP/1.1\r\n")
2. Change pin = 3 to pin = 4 (this one is just a personal preference, as I previously soldered the data connection to pin D4. If you would like to retain the original reference to pin D3, feel free to leave the code as is, and solder the data connection to pin D3 instead!)
After making the following changes, upload the code using LuaLoader.
Do remember to select the correct Baud Rate (either 9600/115200), and the correct COM channel!
Step 4: Enjoy!
If done correctly, your simple Humidity and Temperature sensors should work. You can use it in any place which you deem fit!