Live Temperature and Humidity Monitoring over Internet using Arduino and ThingSpeak - Internet of Things

Live Temperature and Humidity Monitoring over Internet using Arduino and ThingSpeak

Temperature and Humidity Monitoring over Internet using ThingSpeak and Arduino

Humidity and Temperature are very common parameters for measuring at many places like farm, green house, medical, industries home and offices. We have already covered Humidity and Temperature Measurement using Arduino and displayed the data on LCD.
In this IoT project we are going to Monitor Humidity and Temperature over the internet using ThingSpeak where we will show the current Humidity & Temperature data over the Internet using the ThingSpeak server. It is accomplished by the data communications between Arduino, DHT11 Sensor Module, ESP8266 WIFI module and LCD. Celsius scale thermometer and percentage scale humidity meter displays the ambient temperature and humidity through a LCD display and also sends it to ThingSpeak server for live monitoring from anywhere in the world.

Working and ThingSpeak Setup:
This IoT based project having four sections, firstly Humidity and Temperature Sensor DHT11 senses the Humidity and Temperature Data. Secondly Arduino Uno extracts the DHT11 sensors data as suitable number in percentage and Celsius scale, and sends it to Wi-Fi Module. Thirdly Wi-Fi Module ESP8266 sends the data to ThingSpeaks Sever. And finally ThingSpeak analyses the data and shows it in a Graph form. Optional LCD is also used to display the Temperature and Humidity.
ThingSpeak provides very good tool for IoT based projects for Arduino. By using ThingSpeak site, we can monitor our data over the Internet from anywhere, and we can also control our system over the Internet, using the Channels and webpages provided by ThingSpeak. ThingSpeak Collects the data from the sensors, Analyze and Visualize the data and Acts by triggering a reaction. Here we are explaining about How to send Data to ThingSpeak server by using ESP8266 WIFI Module:

1. First of all, user needs to Create a Account on ThingSpeak.com, then Sign In and click on Get Started.

2. Now go to the Channelsmenu and click on New Channel option on the same page for further process.

3. Now you will see a form for creating the channel, fill in the Name and Description as per your choice. Then fill Humidityand Temperaturein Field 1 and Field 2 labels, tick the checkboxes for both Fields. Also tick the check box for Make Publicoption below in the form and finally Save the Channel. Now your new channel has been created.

4. Now click on API keystab and save the Write and Read API keys, here we are only using Write key. You need to Copy this key in char *api_key in the Code.

5. After it, click on Data Import/Exportand copy the Update Channel Feed GET Request URL, which is:

6. Now user need to open api.thingspeak.comusing the httpGet function with the postUrl as update?api_key=SIWOYBX26OXQ1WMS&field1=0and then send data using data feed or update request address.
Before sending the data, user needs to edit this query string or postUrl with temperature and humidity data fields, like shown below. Here we have added both parameters in the string that we need to send via using GET request to server, after it we have used httpGet to send the data to server. Check the full Code Below.
​sprintf(postUrl, "update?api_key=%s&field1=%s&field2=%s",api_key,humidStr,tempStr);
httpGet("api.thingspeak.com", postUrl, 80);​

The whole process is demonstrated in the Video section, at the end of this Article.

Working of this project is based on single wire serial communication for fetching data from DHT11. First Arduino sends a start signal to DHT module and then DHT gives a response signal with containing data. Arduino collects and extracts the data in two parts first is humidity and second is temperature and then send it to 16x2 LCD and ThingSpeak server. ThingSpeak displays the Data in form of Graph as below:
You can learn more about DHT11 Sensor and its Interfacing with Arduino here.

Circuit Description:
Connections for this ThingSpeak Temperature and Humidity Monitoring Project are very simple. Here a Liquid Crystal Display is used for displaying Temperature and Humidity, which is directly connected to Arduino in 4-bit mode. Pins of LCD namely RS, EN, D4, D5, D6 and D7 are connected to Arduino digital pin number 14, 15, 16, 17, 18 and 19. This LCD is optional.
DHT11 Sensor Module is connected to digital pin 12 of Arduino. Wi-Fi module ESP8266s Vcc and GND pins are directly connected to 3.3V and GND of Arduino and CH_PD is also connected with 3.3V. Tx and Rx pins of ESP8266 are directly connected to pin 2 and 3 of Arduino. Software Serial Library is also used here to allow serial communication on pin 2 and 3 of Arduino. We have already covered the Interfacing of ESP8266 Wi-Fi module to Arduino in detail.

Programming Part:
Programming part of this project plays a very important role to perform all the operations. First of all we include required libraries and initialize variables.
#include"dht.h"      // Including library for dht
#include<LiquidCrystal.h>
LiquidCrystal lcd(14,15,16,17,18,19);
#include<Timer.h>
Timer t;
#include <SoftwareSerial.h>
SoftwareSerial Serial1(2, 3);

After it enter your Write API key and take some strings.
char *api_key="SIWOYBX26OXQ1WMS";     // Enter your Write API key from ThingSpeak
static char postUrl[150];
int humi,tem;
void httpGet(String ip, String path, int port=80);

In void loop() function we reads temperature and humidity and then show those readings on the LCD.
void send2server() function is used to send the data to server. Send2server function is a timer interrupt service routine, calling in every 20 seconds. When we call update function, timer interrupt service routine is called.
void send2server()
{
  char tempStr[8];
  char humidStr[8];
  dtostrf(tem, 5, 3, tempStr);
  dtostrf(humi, 5, 3, humidStr);
  sprintf(postUrl, "update?api_key=%s&field1=%s&field2=%s",api_key,humidStr,tempStr);
  httpGet("api.thingspeak.com", postUrl, 80);
}


  Demo & Code


Live Temperature and Humidity Monitoring over Internet using Arduino and ThingSpeak Live Temperature and Humidity Monitoring over Internet using Arduino and ThingSpeak Reviewed by XXX on สิงหาคม 27, 2560 Rating: 5

ไม่มีความคิดเห็น