Arduino IOT: Temperature and Humidity ( With ESP8266 WiFi)

64,030

358

59

Published

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!

6 People Made This Project!

Recommendations

  • Water Contest

    Water Contest
  • Clocks Contest

    Clocks Contest
  • Creative Misuse Contest

    Creative Misuse Contest

59 Discussions

AT+CIPSEND=56

AT+CIPCLOSE


AT+CIPSTART="TCP","184.106.153.149",80

IT DOESENT WORK

1 reply

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

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.

screenshot.2018-01-05.png
1 reply

Same problem I am facing, do not get any data on ThingSpeak. So please help to sort out the issue !!

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 ?

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

1 reply
0
user
NinurtaA

Question 4 months ago

This code gives me comiling error.

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.

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.

1 reply

By the way, data shows up within seconds at Thingspeak.

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.

Data_gap.jpgnoisy_DTH-11.jpgtime_scale.jpg

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.

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?

2 replies

Here is the direct link for the source code hoping that it will help others:

https://codebender.cc/sketch:249309#ESP8266_DHT22_IOT.ino

The code is no longer accessible in the codebender link.

Could you please check?

Is there a way to hook up two DHT22 sensors to an Arduino?