IoT Based Temperature and Humidity Monitoring over ThingSpeak using Arduino UNO and ESP8266

IoT based Temperature and Humidity Monitoring System on Thingspeak using Arduino and ESP8266

In this project, we are using the DHT11 sensor for sending Temperature and Humidity data to Thingspeak using Arduino and ESP8266. By this method, we can monitor our DHT11 sensor’s temperature and humidity data over the internet using the ThingSpeak IoT server. And we can view the logged data and graph overtime on the Thingspeak website.

Here Arduino Uno reads the current temperature and humidity data from DHT11 and sends it to the ThingSpeak server for live monitoring from anywhere in the world. We previously used ThingSpeak with Raspberry Pi and ESP32 to upload the data on the cloud. ThingSpeak is an open data platform for monitoring your data online where you can set the data as private or public according to your choice. ThingSpeak takes a minimum of 15 seconds to update your readings. It's a great and very easy-to-use platform for building IoT projects.

 

Components Required

  • Arduino Uno
  • ESP8266 WiFi Module
  • DHT11 Sensor
  • Breadboard
  • Jumper Wires

 

Temperature and Humidity Monitoring System Circuit Diagram

ESP8266 Data logger Circuit Diagram

Data Monitoring over ThingSpeak using Arduino UNO and ESP826

 

Connections are given in below table: 

S.NO.

Pin Name

Arduino Pin

1

ESP8266 VCC

3.3V

2

ESP8266 RST

3.3V

3

ESP8266 CH-PD

3.3V

4

ESP8266 RX

TX

5

ESP8266 TX

RX

6

ESP8266 GND

GND

7

DHT-11 VCC

5V

8

DHT-11 Data

5

9

DHT-11 GND

GND

 

Step 1: ThingSpeak Setup for Temperature and Humidity Monitoring

For creating your channel on Thingspeak, you first need to Sign up on Thingspeak. In case if you already have an account on Thingspeak, just sign in using your id and password.

For creating your account go to www.thinspeak.com

ThingSpeak

 

Click on Sing up if you don’t have account and if you already have an account, then click on sign in.

After clicking on signup, fill in your details.

Sign up for ThingSpeak

After this, verify your E-mail id and click on continue.

 

Step 2: Create a Channel for Your Data

Once you Sign in after your account verification, Create a new channel by clicking “New Channel” button.

ThingSpeak Channel

 

After clicking on “New Channel”, enter the Name and Description of the data you want to upload on this channel. For example, I am sending my DHT11 sensor data, so I named it DHT11 data.

Enter the name of your data ‘Temperature’ in Field1 and ‘Humidity’ in Field2. If you want to use more Fields, you can check the box next to Field option and enter the name and description of your data.

After this, click on the save channel button to save your details.

 

Step 3: API Key

To send data to Thingspeak, we need a unique API key, which we will use later in our code to upload our sensor data to Thingspeak Website.

Click on “API Keys” button to get your unique API key for uploading your sensor data.

ThingSpeak API Key

Now copy your “Write API Key”. We will use this API key in our code.

 

Programming Arduino for Sending data to ThingSpeak

To program Arduino, open Arduino IDE and choose the correct board and port from the ‘tool’ menu.

Complete code is given at the end of this tutorial. Upload it in Arduino UNO. If you successfully upload your program, Serial monitor will look like this:

Programming Arduino for Sending data to ThingSpeak

 

After this navigate to your Thingspeak page and open your channel at Thingspeak and output will be shown as below:

ThingSpeak Data Monitoring

Hence, we have successfully monitored Temperature and Humidity data over ThingSpeak using Arudino and ESP32.

Code

#include <stdlib.h>

#include <DHT.h>

#define DHTPIN 5         // DHT data pin connected to Arduino pin 5

#define DHTTYPE DHT11     // DHT11 (DHT Sensor Type )

DHT dht(DHTPIN, DHTTYPE); // Initialize the DHT sensor

#define SSID "WiFi Name"     // "WiFi Name"

#define PASS "WiFi Password"       // "Password"

#define IP "184.106.153.149"// thingspeak.com ip

String msg = "GET /update?key=Your API Key"; //change it with your key...

float temp;

int hum;

String tempC;

int error;

void setup()

{

  Serial.begin(115200); // use default 115200.

  Serial.println("AT");

  delay(5000);

  if(Serial.find("OK")){

    connectWiFi();

  }

}

void loop(){

   start: 

  error=0;

  temp = dht.readTemperature();

  hum = dht.readHumidity();

  char buffer[10];

  tempC = dtostrf(temp, 4, 1, buffer);

  updateTemp();

  if (error==1){

    goto start;

  }

 

  delay(5000);

}

void updateTemp(){

  String cmd = "AT+CIPSTART=\"TCP\",\"";

  cmd += IP;

  cmd += "\",80";

  Serial.println(cmd);

  delay(2000);

  if(Serial.find("Error")){

    return;

  }

  cmd = msg ;

  cmd += "&field1=";  

  cmd += tempC;

  cmd += "&field2="; 

  cmd += String(hum);

  cmd += "\r\n";

  Serial.print("AT+CIPSEND=");

  Serial.println(cmd.length());

  if(Serial.find(">")){

    Serial.print(cmd);

  }

  else{

    Serial.println("AT+CIPCLOSE");

    //Resend...

    error=1;

  }

}

  boolean connectWiFi(){

  Serial.println("AT+CWMODE=1");

  delay(2000);

  String cmd="AT+CWJAP=\"";

  cmd+=SSID;

  cmd+="\",\"";

  cmd+=PASS;

  cmd+="\"";

  Serial.println(cmd);

  delay(5000);

  if(Serial.find("OK")){

    return true;

  }else{

    return false;

  }

}

25 Comments

he seguido las instrucciones del post, pero en el monitor serial no me aparece igual al ejemplo. 

AT
AT+CIPSTART="TCP","184.106.153.149",80
AT+CIPSEND=55
AT+CIPCLOSE 

estas lineas son las que obtengo 

You can add more fields as shown below:

cmd = msg ;

cmd += "&field1=";

cmd += tempC;

cmd += "&field2=";

cmd += String(hum);

cmd += "&field3=";

cmd += String(data);

................................

.................................

My ESP8266 has the following pins: Gr,Tx, IO2, En, IO0, Rst, Rx, 3V3.
Can you please help me with the proper UNO pin connections for this ESP8266?

Thank you,

BrotherDan

I am just commenting to make you understand of the really good experience my wife's girl enjoyed viewing yuor web blog. She figured out a good number of details, which included what it is like to have an incredible coaching character to get the rest very easily have an understanding of various extremely tough issues. You really surpassed visitors' expected results. Thank you for distributing such good, safe, explanatory and in addition unique tips about this topic to Sandra.

I have to show my thanks to you for bailing me out of such a situation. Because of checking through the the web and getting solutions which were not powerful, I figured my entire life was over. Living without the solutions to the issues you have sorted out by way of the guideline is a critical case, as well as those which may have negatively affected my career if I had not noticed your blog post. Your personal skills and kindness in handling every aspect was priceless. I'm not sure what I would've done if I hadn't discovered such a solution like this. I can at this moment look ahead to my future. Thank you very much for this reliable and amazing guide. I will not be reluctant to refer the sites to any person who needs guidelines on this area.

I have to get across my gratitude for your generosity for those people who really need guidance on the concern. Your personal dedication to getting the message all over appeared to be pretty interesting and have always enabled others much like me to reach their ambitions. Your new useful hints and tips denotes this much a person like me and substantially more to my fellow workers. With thanks; from each one of us.

I would like to express thanks to you just for bailing me out of such a difficulty. Just after surfing around through the search engines and obtaining ways which were not helpful, I believed my life was well over. Existing without the presence of strategies to the difficulties you've fixed by way of your entire site is a serious case, and ones which could have adversely affected my career if I had not come across your web page. Your primary know-how and kindness in dealing with every item was helpful. I don't know what I would've done if I had not come upon such a step like this. I can now relish my future. Thanks for your time so much for the impressive and sensible help. I will not be reluctant to refer your web blog to anybody who wants and needs care on this issue.

I definitely wanted to write a brief remark so as to appreciate you for some of the stunning techniques you are writing here. My long internet search has finally been recognized with beneficial concept to go over with my co-workers. I 'd say that we visitors actually are truly blessed to dwell in a useful site with many brilliant people with valuable opinions. I feel extremely fortunate to have encountered the web site and look forward to tons of more amazing minutes reading here. Thanks a lot once more for all the details.

My husband and i felt absolutely joyous when Ervin managed to complete his studies using the precious recommendations he discovered in your web site. It's not at all simplistic to just find yourself giving freely things which usually most people have been making money from. And now we remember we now have the blog owner to thank because of that. The illustrations you've made, the simple website navigation, the friendships your site make it possible to engender - it's all fabulous, and it is letting our son in addition to our family imagine that that content is enjoyable, and that is extremely serious. Thank you for everything!

I and my buddies were found to be reading through the great strategies located on your web site while suddenly I had an awful feeling I had not expressed respect to the website owner for those secrets. All the men appeared to be for this reason stimulated to read them and have now in reality been tapping into them. Appreciate your really being indeed accommodating and for using certain incredible ideas millions of individuals are really desperate to learn about. My honest apologies for not expressing gratitude to you sooner.

After study a few of the blog posts on your website now, and I really like your method of blogging. I bookmarked it to my bookmark website list and might be checking again soon. Pls take a look at my web page as properly and let me know what you think.

My husband and i felt really more than happy when Chris could do his studies because of the ideas he obtained from your very own web site. It is now and again perplexing to just happen to be giving freely strategies that many some other people may have been trying to sell. So we keep in mind we need the blog owner to thank for this. The illustrations you made, the easy web site navigation, the friendships you will assist to create - it's most excellent, and it's assisting our son and us consider that that idea is interesting, and that's pretty indispensable. Many thanks for the whole lot!

I must express some thanks to you just for bailing me out of such a setting. Right after looking out throughout the the web and finding proposals which are not pleasant, I figured my entire life was well over. Being alive minus the approaches to the issues you have resolved as a result of your good review is a critical case, as well as those which may have in a negative way affected my career if I had not discovered your web page. Your main understanding and kindness in dealing with a lot of stuff was valuable. I'm not sure what I would've done if I hadn't discovered such a subject like this. I can at this moment look forward to my future. Thanks a lot very much for your impressive and amazing guide. I won't hesitate to suggest the website to any person who needs to have counselling on this topic.

I in addition to my pals came reading the nice thoughts located on your website and then immediately came up with a horrible suspicion I had not thanked you for those techniques. Most of the ladies appeared to be totally stimulated to read through all of them and now have honestly been taking advantage of those things. Appreciation for really being really thoughtful and also for selecting this sort of essential topics millions of individuals are really needing to be aware of. Our honest apologies for not saying thanks to you sooner.

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.