IOT - Final
IOT - Final
KEELAPALUR, ARIYALUR
N-SCHEME
LAB MANUAL
R. CHINNAA M.E
LECTURER/CSE
INDEX
SL.
NO DATE NAME OF THE EXPERIMENT MARKS SIGN
7. CASE STUDY
AIM:
To implement LED Blink and LED Pattern with Arduino
SOFTWARE REQUIREMENT:
1. Arduino SDK
COMPONENTS REQUIRED:
1. Arduino Uno -1Nos
2. Breadboard -1Nos
3. 5mm Led: Red - 2Nos
4. Resistor 1k Ohm -1Nos
5. Jumper Wires - 4Nos
PROCEDURE:
1. Connect LED in the bread board. (For Ex: In led big needle is positive and small needle is negative)
2. Connect jumper wire from RED LED to 11rd pin in arduino uno kit and GREEN LED to 5th pin in
arduino uno kit.
3. Connect one end of resistor to red LED negative and other end to ground of arduino .
4. Connect one end of resistor to GREEN LED negative and other end to ground of arduino .
6. In computer open arduino software and type the code in the arduino software.
CODE:
const int LED_red = 11;
const int LED_green =5;
void setup()
{
pinMode(LED_red, OUTPUT);
pinMode (LED_green,OUTPUT);
}
void loop()
{
digitalWrite (LED_red, HIGH);
digitalWrite (LED_green, LOW);
delay (1000);
digitalWrite (LED_red, LOW);
digitalWrite (LED_green, HIGH);
delay (1000);
}
RESULT:
Thus, the LED blink and LED pattern is implemented and executed successfully.
PANIMALAR POLYTECHNIC COLLEGE
EX. NO: 9
LED PATTERN WITH PUSH BUTTON
Date:
AIM:
To implement LED pattern with Push button control with Arduino.
SOFTWARE REQUIREMENT:
1. Arduino SDK
COMPONENTS REQUIRED:
PROCEDURE:
o Pin1 to 5V of Arduino.
CODE:
int buttonPin = 8;
int buttonState = 0;
int p=0;
void setup()
{
for(int i=1; i<=6; i++)
pinMode(i,OUTPUT);
PANIMALAR POLYTECHNIC COLLEGE
pinMode(buttonPin, INPUT);
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH)
{
p++;
delay(500);
}
if(p==1)
{
for(int i=1; i<=6; i++)
{
digitalWrite(i,HIGH);
delay(100);
digitalWrite(i,LOW);
delay(100);
}
}
if(p==2)
{
for(int i=1; i<=6; i++)
{
digitalWrite(i,HIGH);
delay(100);
}
for(int i=6; i>=1; i--)
{
digitalWrite(i,LOW);
delay(100);
}
}
}
RESULT:
Thus, LED pattern with push button control with Arduino is implemented and executed
successfully.
EX. NO: 10
DISPLAYING HELLO WORLD
Date:
AIM:
SOFTWARE REQUIREMENT:
1. Arduino SDK
COMPONENTS REQUIRED:
PROCEDURE:
1. Connect LCD display to I2C module and solder it using the pins.
5. Before running the code you must download two library files namely liquid crystal and wire
6. Then goto sketch -> include library->add zip library, import two library files which is
downloaded.
CODE
#include<Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
lcd.init();
lcd.backlight();
lcd.setCursor(1,0);
lcd.print("Hello");
lcd.setCursor(1,1);
lcd.print("CSE Dept");
}
void loop()
{}
RESULT:
Thus, “Hello World” in LCD 16x2 display with Arduino is implemented and executed
successfully.
EX. NO: 11
TO IMPLEMENT SERVO MOTOR CONTROL
Date:
AIM:
To implement Servo motor control with Arduino.
SOFTWARE REQUIREMENT:
1. Arduino SDK
COMPONENTS REQUIRED:
PROCEDURE:
Servo motor wires:
3. green color is the signal pin which we need to connect to the digital pin of the arduino
5. import the servo library file into the arduino uno software;
6. Run the code, the servo motor will be shifting from 0 degree to 180 degree as given in the code.
CODE
#include<Servo.h>
Servo s1;
void setup()
{
s1.attach(9);
}
void loop()
{
s1.write(0);
delay(1000);
s1.write(180);
delay(1000);
s1.write(0);
}
RESULT:
Thus, the servo motor control with arduino is implemented and executed successfully.
EX. NO: 12
IMPLEMENTATION OF LM35 TEMPERATURE SENSOR
Date:
AIM:
To implement and monitor LM35 temperature sensor and ultrasonic distance measurement
with Arduino.
SOFTWARE REQUIREMENT:
1. Arduino SDK
COMPONENTS REQUIRED:
PROCEDURE:
CIRCUIT DIAGRAM:
Measure Temperature using LM35 with Arduino Uno
Ultrasonic Sensor with Arduino
CODE:
Measure Temperature using LM35 with Arduino Uno
void loop() {
int temp_adc_val;
float temp_val;
temp_adc_val = analogRead(lm35_pin); // Read Temperature
temp_val = (temp_adc_val * 4.88); // Convert adc value to equivalent voltage
temp_val = (temp_val/10); // LM35 gives output of 10mv/°C
Serial.print("Temperature = ");
Serial.print(temp_val);
Serial.print(" Degree Celsius\n");
delay(1000);
}
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int trigPin = 2; //declare pin for trigger pin of UltraSonic sensor;
int echoPin = 3; //declare pin for echo pin of UltraSonic sensor;
float speed = 0.0347; //declare speed of sound in air @ room temp;
int dist; //declare variable for containing distance sensed;
float pingTime; //declare variable for containing echo time;
float distinch;
void setup() {
Serial.begin(9600);
RESULT
Thus the LM35 Temperature Sensor and Ultrasonic Distance Measurement with Arduino is
implemented and executed successfully
EX. NO: 13
IMPLEMENTATION OF IR SENSOR WITH ANALOG INPUT
Date:
AIM:
To implement IR Sensor with Analog input with Arduino.
SOFTWARE REQUIREMENT:
1. Arduino SDK
COMPONENTS REQUIRED:
PROCEDURE:
4. Upload the code and sensor will work with led light detection.
5. We can use buzzor for detection the sound.
void setup()
{
pinMode(7,INPUT);
pinMode(9,OUTPUT);
}
void loop()
{
If (digitalRead(7)== HIGH)
{
digitalWrite(9,HIGH);
}
else
{
digitalWrite(9,LOW);
}
}
RESULT:
Thus, the IR Sensor Analog Input with Arduino is implemented and executed successfully.
EX. NO: 14
TEMPERATURE SENSOR MONITORING WITH RASPBERRY PI
Date:
AIM:
To implement cloud reading temperature sensor using Raspberry Pi.
SOFTWARE REQUIREMENT:
1. Arduino SDK
COMPONENTS REQUIRED:
PROCEDURE:
• You will be receiving the confirmation mail link and click on the link and then continue to
sign in the thinkspeak account.
2. Click on create channel and enter the field details.Then channel will be created.
3. Click on API keys and there will be 2 keys write API and Read API keys,write API keys will store
the sensor values and write in think speak and when you give the think speak key value to arduino
board then it is called write API keys.
CODE:
#include "dht.h"
#define dht_apin A0
dht DHT;
#include <SoftwareSerial.h> //Software Serial library
SoftwareSerial espSerial(2, 3); //Pin 2 and 3 act as RX and TX. Connect them to TX and RX of ESP8266
#define DEBUG true
String mySSID = "GS"; // WiFi SSID
String myPWD = "ptleecnpt"; // WiFi Password
String myAPI = "IFNXUVCVENMT25D8"; // API Key
String myHOST = "api.thingspeak.com";
String myPORT = "80";
String myFIELD = "field1";
int sendVal;
void setup()
{
Serial.begin(9600);
Serial.println("DHT11 Humidity & temperature Sensor\n\n");
delay(1000);
espSerial.begin(115200);
espData("AT+RST", 1000, DEBUG); //Reset the ESP8266 module
espData("AT+CWMODE=1", 1000, DEBUG); //Set the ESP mode as
station mode
espData("AT+CWJAP=\"" + mySSID + "\",\"" + myPWD + "\"", 1000, DEBUG); //Connect to WiFi
delay(1000);
}
void loop(){
DHT.read11(dht_apin);
String sendData = "GET /update?api_key=" + myAPI + "&" + myFIELD + "=" +String(DHT.humidity);
espData("AT+CIPMUX=1", 1000, DEBUG); //Allow multiple connections
espData("AT+CIPSTART=0,\"TCP\",\"" + myHOST + "\"," + myPORT, 1000,DEBUG);
espData("AT+CIPSEND=0," + String(sendData.length() + 4), 1000, DEBUG);
espSerial.find(">");
espSerial.println(sendData);
Serial.print("Value to be sent: ");
Serial.println(DHT.humidity);
espData("AT+CIPCLOSE=0", 1000, DEBUG);
delay(10000);
}
String espData(String command, const int timeout, boolean debug)
{
Serial.print("AT Command ==> ");
Serial.print(command);
Serial.println(" ");
String response = "";
espSerial.println(command);
long int time = millis();
while ( (time + timeout) > millis())
{
while (espSerial.available())
{
char c = espSerial.read();
response += c;
}
}
if (debug)
{}
return response;
}