0% found this document useful (0 votes)
55 views50 pages

Intern Iot

This document discusses interfacing a DHT11 temperature and humidity sensor with an Arduino Uno and ESP8266 WiFi module to monitor and upload sensor data to an IoT cloud. The circuit connects the DHT11 sensor to an Arduino, which processes the sensor values and sends them to the ESP8266. The ESP8266 then uploads the data to the ThingSpeak cloud platform.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views50 pages

Intern Iot

This document discusses interfacing a DHT11 temperature and humidity sensor with an Arduino Uno and ESP8266 WiFi module to monitor and upload sensor data to an IoT cloud. The circuit connects the DHT11 sensor to an Arduino, which processes the sensor values and sends them to the ESP8266. The ESP8266 then uploads the data to the ThingSpeak cloud platform.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

LED LED : light emitting

diode
• LED is a
semiconductor
light source that
emits light when
current flows
through it
• Resistor is used in
series with led to
reduce the current
flow through the
LED
GPIO programming
• GPIO :general purpose input/ output is an
uncommitted digital signal pin on an
integrated circuit whose behaviour - including
whether it acts as input or output-is
controllable by the user at the run time
• GPIOs have no predefined purpose and are
unused by the default
Program for blinking LED
int led = 9; //9th pin is attached to led
void setup() //to program the pin as i/p or o/p
{
pinMode(led,OUTPUT); //assigning as output
}
Void loop()
{
digitalWrite(led,HIGH); // Turning on LED
delay(1000);
digitalWrite(led,LOW); //Turning off LED
Delay(1000);
}
LED BLINKING
GPIO Program
int led =9;
Void setup()
{
pinMode(led, Output);
Void loop()
{
digitalWrite(led,HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
}
MULTIPLE GPIO PROGRAM
int led =9;
int led1=4;
Void setup()
{
pinMode(led, Output);
Void loop()
{
digitalWrite(led,HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
digitalWrite(led,HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
}
MULTIPLE GPIO PROGRAM
IR SENSOR
• An infrared sensor is
an electronic device
that emits in order to
sense some aspects
of the surroundings
IR sensor interfaced with Arduino uno
atmega328
IR SENSOR PROGRAM
define ledPin 5
define switchPin 8
int val=0;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(switchPin, INPUT);
}
void loop()
{
val = digitalRead(switchPin);
if(vaL == LOW)
{
digitalWrite(ledPin, LOW);
}
digitalWrite(ledPin, HIGH);
}
}
IR sensor interfaced with Arduino uno
LCD
• LCD :- liquid crystal display
• LCD is an electronic display module used to
display the alphanumeric charecters
• A 16*2 LCD display is very basic module and is
very commonly used in various devices and
circuits
• A 16*2 LCD means it has 16 coloums and 2
rows, so that it can display 16 characters per
line and there are 2 such lines
16*2 LCD DISPLAY
PIN description of 16*2 LCD Display
LCD CODE
#include <LiquidCrystal.h> // initialize library
LiquidCrystal lcd(8,9,10,11,12,13);
void setup()
{
lcd.begin(16,2); // selecting both rows and 16 columns
}

void loop()
{
lcd.clear(); /// clear the data in LCD
lcd.setCursor(0,0); //column 0 and line (row) 1
lcd.print(“Object Detected");
lcd.setCursor(0,1); //column 0 and line 2
lcd.print(“Buzzer");
delay(1000);
}
LCD display interfaced to ARDUINO
UNO ATMEGA328
Applications of LCD Diaplay
LCD (Liquid Crystal Display) screen is an
electronic display module and find a wide range
of applications. A 16x2 LCD display is very basic
module and is very commonly used in various
devices and circuits. ... A 16x2 LCD means it can
display 16 characters per line and there are 2
such lines.
Communication
• Communication is the process of exchanging
the data or information between two
communication network.
• Types of communication:-
1.Wired Communication
2.Wireless Communication
Types of Wired communication

SERAIL COMMUNICATION PARLELL COMMUNICATION


Serial v/s parallel communication
In serial communication we have two types, they are:-
1.Synchronous serial communication
2.Asynchronous serial communication

1.Synchronous serial communication:-


Synchronous communication requires that the clocks in
the transmitting and receiving devices are synchronized –
running at the same rate – so the receiver can sample the
signal at the same time intervals used by the transmitter.
2.Asynchronous serial communication:-
Asynchronous serial communication is a form of serial
communication in which the communicating endpoints'
interfaces are not continuously synchronized by a
common clock signal.
Synchronous v/s asynchronous
communication
Difference between serial and parrallel communication
UART
• UART :- universal asynchronous receiver
transmitter
• It is a computer hardware device for
asynchronous serial communication in which the
data formats and transmission speeds are
configurable
• It is an inbuilt peripheral of ATMEGA328
controller
• Baud rate :- 9600 bits/sec
• Start bit , stop bit ,and parity bits are added to
the character to be transmitted
UART program
void setup()
{
Serial.begin (9600);
}
void loop()
{
Serial.print("NRET INTERNSHIP");
delay(1000);
}
Block diagram of IOT with
WIFI module
• The ESP8266 WIFI
Module is a self
contained SOC with
integrated TCP/IP
protocol stack that can
give any
microcontroller access
to your WIFI network
• ThingSpeak is an open-
source Internet of
Things application
• And API to store and
retrieve data from
things using HTTP
protocol
• And over the internet
or via a local area
network
ESP WIFI MODEL
#include<SoftwareSerial.h>
SoftwareSerial soft = SoftwareSerial(8,9);
String ssid = "Network";
String password = "sorry no network";//yathi1234
String apikey = "MM01LW1NIMDYQMEL";
String TCP = "TCP";
String IP = "184.106.153.149";
String port = "80";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
soft.begin(115200);
pinMode(2, INPUT);
}
void showresponse(int waitTime){
long t=millis();
char c;
while (t+waitTime>millis()){
if (soft.available()){
c=soft.read();
Serial.print(c);
}
}
}
void wifiinit(void)
{
//soft.println("AT+RST");
//showresponse(10000);
soft.println("AT+CWMODE=3\r\n");
showresponse(10000);
soft.println("AT+CWJAP=\""+ssid+"\",\""+password+"\"\r\n");
showresponse(10000);
}
void thingspeak(unsigned int x)
{
soft.println("AT+CIPMODE=0\r\n");
showresponse(10000);
soft.println("AT+CIPMUX=0\r\n");
showresponse(10000);
String cmd = "AT+CIPSTART=\"TCP\",\""; // TCP connection
cmd += "184.106.153.149"; // api.thingspeak.com
cmd += "\",80\r\n\r\n";

soft.println(cmd);
if(soft.find("Error"))
{
Serial.println("AT+CIPSTART error");
}
else
{
Serial.println("AT+CIPSTART success");
}
String getStr = "GET https://api.thingspeak.com/update?api_key="; // prepare
GET string
getStr += apikey;
getStr +="&field1=";
getStr += x;

getStr += "\r\n";

cmd = "AT+CIPSEND=";
cmd += String(getStr.length());
//cmd += "\r\n\r\n";
soft.println(cmd);
//showresponse(10000);
if(soft.find(">")){
soft.print(getStr);
}
else{
soft.println("AT+CIPCLOSE\r\n");
Serial.println("AT+CIPCLOSE");
}
}
void loop()
{
int x = digitalRead(2);
if(x == HIGH)
{
wifiinit();
thingspeak(1);
}
else
{
wifiinit();
thingspeak(0);
}
}
WIFI MODULE INTERFACED WITH ARDUNO
UNO 328 USING THINGSPEAK
CONNECTED CIRCUIT RESULT
IOT enabled weather monitoring system
Introduction
Using Internet of Things (IOT), we can control any electronic
equipment in homes and industries. Moreover, you can read a data
from any sensor and analyse it graphically from anywhere in the
world. Here, we can read temperature and humidity data from
DHT11 sensor and upload it to a ThingSpeak cloud using Arduino
Uno and ESP8266-01 module. Arduino Uno is MCU, it fetch a data
of humidity and temperature from DHT11 sensor and Process it and
give it to a ESP8266 Module.ESP8266 is a WiFi module, it is one of
the leading platform for Internet of Things. It can transfer a data to
IOT cloud.
Components Required

Hardware Requirements
• Arduino Uno
• ESP8266-01
• DHT11
• AMS1117-3.3V
• 9V battery

Software Requirements
• Arduino IDE
DHT11 Humidity Sensor on Arduino
Circuit and Working
First make the connection as shown in fig.The 2nd pin is of DHT11 is a data
pin, it can send a temperature and humidity value to the 5thpin of Arduino
Uno.1st and 4th pin of DHT11 is a Vcc and Gnd and 3rd pin is no connection.
The Arduino Uno process a temperature and humidity value and send it to
a ESP8266 WiFi module. The Tx and Rx pin of ESP8266 is connected to the
2nd (Rx) and 3rd (Tx) of Arduino Uno. Make sure that input voltage
of ESP8266 must be 3.3V, not a 5V (otherwise it would damage a device).For
that, we are using AMS1117 Voltage regulator circuit. It can regulate a voltage
from 9V to 3.3V and will give it to Vcc pin of ESP8266.The Ch_Pd is a chip
enable pin of ESP8266 and should be pullup to 3.3V through 3.3KΩ resistor.
For reset the module pull down the RST pin of ESP8266 to Gnd.ESP8266 have
2 GPIO pins GPIO 0 and GPIO 2.
Circuit diagram for monitoring Humidity
and Temperature in IOT cloud
Component Description

DHT11 Temperature and


Humidity Sensor

The DHT11 Humidity and


Temperature Sensor consists of 3
main components. A resistive type
humidity sensor, an NTC (negative
temperature coefficient) thermistor
(to measure the temperature) and
an 8-bit microcontroller, which
converts the analog signals from
both the sensors and sends out
single digital signal.
DHT11 Humidity Sensor
consists of 4 pins: VCC, Data
Out, Not Connected (NC) and
GND. The range of voltage for
VCC pin is 3.5V to 5.5V. A 5V
supply would do fine. The data
from the Data Out pin is a
serial digital data.
The following image
shows a typical
application circuit for
DHT11 Humidity and
Temperature Sensor.
DHT11 Sensor can
measure a humidity
value in the range of
20 – 90% of Relative
Humidity (RH) and a
temperature in the
range of 0 – 500C.
Construction and Testing
ThingSpeak is an open source platform to store and retrieve a data for
Internet of Things application. To use this, you need to register in
ThingSpeak cloud and then login to your account. After create a new
channel with temperature in one field and humidity in another field as
shown in Fig. Once you created a new channel, it will generate a two
API keys, they are READ API keys and WRITE API keys. First, copy the
WRITE API keys from ThingsSpeak and paste it into the line (String
apiKey = "OX9T8Y9OL9HD0UBP";) of the program. Next, replace the
Host_Name and Password with your WiFi name and WiFi password in
the two lines given below in the program. (String Host_Name = “NRET"
and String Password = “NRET123")
The Arduino program Uses DHT library, if it is not presented in your
arduino IDE, select Sketch Include library Manage libraries Install DHT
Sensor library. Then compile the program and upload to a Arduino Uno
through Arduino IDE. Ensure that WiFi modem and internet
connection in your Smartphone or PC are working properly. After
uploaded a program, the Temperature and Humidity data is uploaded
on ThingSpeak platform. You can see it graphically in the private view
window of your channel as shown in Fig . And you can able to see the
uploaded data from serial port of Arduino IDE.
Creating new channel on ThingSpeak cloud
Graphical representation of Humidity and
Temperature data
Arduino code
#include "DHT.h“
#include #define DHTPIN 5 // Digital Pin 5
#define DHTTYPE DHT11 // We are Using DHT11
String apiKey = "OX9T8Y9OL9HD0UBP"; // Edit this API key according to your Account
String Host_Name = "Pantech"; // Edit Host_
Name String Password = "pantech123"; // Edit Password
SoftwareSerial ser(2, 3); // RX, TX
int i=1;
DHT dht(DHTPIN, DHTTYPE); // Initialising Pin and Type of DHT
void setup() {
Serial.begin(115200); // enable software serial
ser.begin(115200); // reset ESP8266
ser.println("AT+RST"); // Resetting ESP8266
dht.begin(); // Enabling DHT11
char inv ='"';
String cmd = "AT+CWJAP";
cmd+= "=";
cmd+= inv;
cmd+= Host_Name;
cmd+= inv; cmd+= ",";
cmd+= inv;
cmd+= Password;
cmd+= inv; ser.println(cmd); // Connecting ESP8266 to your WiFi Router
}
// the loop
void loop()
{
int humidity = dht.readHumidity(); // Reading Humidity Value
int temperature = dht.readTemperature(); // Reading Temperature Value
String state1=String(humidity); // Converting them to string
String state2=String(temperature); // as to send it through URL\
String cmd = "AT+CIPSTART=\"TCP\",\""; // Establishing TCP connection
cmd += "184.106.153.149"; // api.thingspeak.com
cmd += "\",80"; // port 80
ser.println(cmd);
Serial.println(cmd);
if(ser.find("Error")){
Serial.println("AT+CIPSTART error");
return;
}
String getStr = "GET /update?api_key="; // prepare GET string
getStr += apiKey;
getStr +="&field1=";
getStr += String(state1); // Humidity Data
getStr +="&field2=";
getStr += String(state2); // Temperature Data
getStr += "\r\n\r\n";
cmd = "AT+CIPSEND=";
cmd += String(getStr.length()); // Total Length of data ser.println(cmd);
Serial.println(cmd);
if(ser.find(">"))
{
ser.print(getStr);
Serial.print(getStr);
}
else{ ser.println("AT+CIPCLOSE"); // closing connection
// alert user
Serial.println("AT+CIPCLOSE");
}
delay(1000); // Update after every 15 seconds
}
Applications

• DHT11 Relative Humidity and Temperature Sensor


can be used in many applications like:
• HVAC (Heating, Ventilation and Air Conditioning)
Systems
• Weather Stations
• Medical Equipment for measuring humidity
• Home Automation Systems
• Automotive and other weather control applications

You might also like