Introduction: Arduino IOT: Temperature and Humidity ( With ESP8266 WiFi)
Hello everyone! I am Michalis Vasilakis from www.ardumotive.com and in this Instructables I will show you how to make your own Internet Of Things (IOT) thermometer by using the Arduino uno board.
You can use it at home, at the office, or anywhere there is an internet connection, for indoor or outdoor data logging. Ιn this project we will use the DHT-22 sensor to take temperature (oC) and humidity (%) values every one hour. For the internet connection we will use the ESP8266 WiFi (serial) module because it's small,cheap and easy to use, and for data logging we will use the open data platform for the Internet of Things "ThingSpeak" (www.thingspeak.com).
You can also make monthly or yearly average charts and see how your climate change affects your area!
So, let's get started!
P.S.: Updates and Q&A here: http://www.ardumotive.com/iot-wifi-temp-and-humidity.html
Step 1: What We Will Need
For this project we will need:
- Arduino uno board (or any other Arduino board) (link)
- Small breadboard (or an breadboard shield) (link)
- DHT-22 sensor (link)
- ESP8266 WiFi serial module (link)
...and off course some breadboard wires.
Update - Note:
Some users reported me that you may need an external 3.3V power supply for powering up the ESP8266. You can try to use the LD1117V33 (LD33V3) voltage regulator.
Step 2: The Circuit
The connections are pretty easy, watch the above image with the breadboard circuit schematic.
Notes:
DHT-22
- DHT-22 Vcc to Arduino 5V
- DHT-22 Data to Arduino pin 2
ESP8266
- Vcc, RST and CH_PD to Arduino 3.3V
- RXD to Arduino pin 1 (TX)
- TXD to Arduino pin 0 (RX)
Update - Note:
If you have any power problems with your ESP8266 module use one 3.3V voltage regulator (e.g. LD1117V33), connect the Vin pin of regulator with the Vin pin of Arduino uno board.
Step 3: ThingSpeak Account
Visit www.thingspeak.com and click on the "Get Started" button to make a free account.
Now click on the "New Channel" (second image above). Give it a name and select two fields. If you want you can fill more info about your channel, e.g. Latitude and Longitude of your sensor. If you want to share sensor info with your friends (and more..) click on the "Make Public?" check box option. Finally click on the "Save Channel" button.
Click on your new channel and select the API keys tab (third image above). Copy your "Write API Key" , you will need it in the next step.
Step 4: The Code
Here's the code, embedded using Codebender!
Before you proceed:
- Remove the RX and TX cables from the Arduino board
- Add your information in the code below by pressing the "Edit" button:
- #define SSID "name" // "SSID-WiFiname"
- #define PASS "password" // "password"
- String msg = "GET /update?key=YOUR_WRITE_KEY"; //change it with your key...
Try downloading the Codebender plugin and clicking on the "Run on Arduino" button to program your Arduino board with this sketch. And that's it, you've programmed your Arduino board directly from your browser!
Now you can re-connect the RX and TX cables. Now check your ThingSpeak channel to see the first sensor's info!
The "delay(3600000);" will send data to your ThingSpeak channel every one hour. It's not the best way for counting, but it's working fine ;).
How to find time in milliseconds:
1 minute has 60000ms, so for example: 15 minutes have 60000x15=900000ms
Step 5: Data Logger
You can see my channel here: https://thingspeak.com/channels/90526
Check it again in one hour!
You can also download the "ThingView" application to your android device!
Step 6: What Next?
You can make your own Arduino-based circuit and put it in a small box, just make sure that the sensor will be out of it.
I made mine and placed it on the wall outside of my house, you can check my temperature and humidity values here!
Future updates:
- add a real clock circuit to control the time of data sending with accuracy
- add a rechargeable battery and one small solar panel
- add more charts for monthly and yearly average values
Step 7: Well Done!
You have successfully completed this guide and now you have your own Arduino IOT device up and running!
For more Arduino tutorials and cool projects you can visit our web page: www.ardumotive.com
I hope you liked this, let me know in the comments!

Participated in the
Hack Your Day Contest
8 People Made This Project!
- Müñtázárƛ made it!
- arhinovator made it!
- botronics made it!
- ΠαντελήςΓ made it!
See 4 More
55 Comments
2 years ago
I want to avoid thinkspeak. Can you help me "How to go ahead with my own domain"
Tip 3 years ago
The code for this project ran great until Spring/2019 and then all of a sudden stopped working?
I discovered that if you add the following, noted, line of code to the Arduino sketch the project comes back to life:
void setup()
{
Serial.begin(115200); //or use default 115200.
dht.begin(); // Added this line of code to restore the operation of this project.
Serial.println("AT");
delay(5000);
if (Serial.find("OK")) {
connectWiFi();
}
}
Question 3 years ago
Could this kind of project work if i used DHT11 instead of DHT22?
4 years ago
AT+CIPSEND=56
AT+CIPCLOSE
AT+CIPSTART="TCP","184.106.153.149",80
IT DOESENT WORK
Reply 4 years ago
Hi There
I had encountered the same problem and I have rectified it. On line 78 replace > with = and everything will start working. If you are working with DHT11 sensor then you need to replace DHT22 with DHT11 on line 14.
Hope it helps
5 years ago
Hi their I tried following your guide to see if I could get my Grove DHT11 Temp & Humidity sensor to capture and upload data to my ThingSpeak account, but unfortunately no data is showing up on the site.
The only modifications I have made to the code is the pin i'm using and the code specific to my DHT11. Any help would be greatly appreciated.
Reply 4 years ago
Same problem I am facing, do not get any data on ThingSpeak. So please help to sort out the issue !!
Question 4 years ago
I had strictly followed all the steps given in article but still I don't get any output on ThingSpeak. I had use the same program from article. So is this because of Incomplete Program ?
4 years ago
Arduino: 1.8.5 (Windows 8), Board: "Arduino/Genuino Uno"
WARNING: Category 'Schedulers' in library TaskScheduler is not valid. Setting to 'Uncategorized'
In file included from C:\Users\karthik\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.cpp:22:0:
C:\Users\karthik\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.h:25:29: fatal error: Adafruit_Sensor.h: No such file or directory
#include
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
this type of error was happening,what can do for it
Reply 4 years ago
You need to install "Adafruit_Sensor" library to Arduino. You can install it from here: https://github.com/adafruit/Adafruit_Sensor
Question 4 years ago
This code gives me comiling error.
5 years ago
will this work with a dht11
Reply 4 years ago
It will work with a DTH-11 if you change the #define to DTH11. I found the DTH-11 to be a unreliable sensor and suggest you use a HDC1080. You will need to use the libaray from Closedcube and some of ther example code.
4 years ago
How long does it take for data to show up on my account? I built it, loaded the code and have not seen data yet. The ESP8266 give a blue blink (is that a good sign?) so I think its working.
Reply 4 years ago
By the way, data shows up within seconds at Thingspeak.
4 years ago
I was able to expand out the code to read other sensors such as light and LM34 temperature sensors. Just add additional fields. I had a problem with character transmission if the value was less than 10. Any additional fields being sent after a low value sensor will not be graphed. It will just make a gap till the value come above 10. This was a problem when I was using a light sensor such as a CDS cell. I found if you not use the dtostrf command and just send the value as a floating variable, it work with numbers approaching zero. I also used a DTH-11 as a sensor and they are unreliable and noisy. Will be using a HDC1080 instead. I also discovered that time scales do not match across data fields. Yet they do when the graphs are zoomed and compared.
4 years ago
Arduino: 1.8.5 (Windows 8), Board: "Arduino/Genuino Uno"
WARNING: Category 'Schedulers' in library TaskScheduler is not valid. Setting to 'Uncategorized'
In file included from C:\Users\karthik\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.cpp:22:0:
C:\Users\karthik\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.h:25:29: fatal error: Adafruit_Sensor.h: No such file or directory
#include
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
6 years ago
I got nearly the same problem as reported
AT
AT+CIPSTART="TCP","184.106.153.149",80
AT+CIPSEND=56
AT+CIPCLOSE
But I was able to do 2 transmissions which I can see on my ThingSpeak Channel.
So, api_key and programming must be ok. Could it be a power supply issue?
Reply 4 years ago
Me too. Anyone help me!! PLs
Reply 4 years ago
Success. Baud rate 115200.