0% found this document useful (0 votes)
13 views24 pages

531 Iot PDF

The document describes three experiments involving controlling devices with Arduino. Experiment 1 involves controlling an LED and buzzer through serial monitor input. Experiment 2 involves creating LED patterns using push buttons. Experiment 3 controls a servo motor with a joystick and measures object distance with an ultrasonic sensor displaying it on an LCD.

Uploaded by

Sharmila Devi
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)
13 views24 pages

531 Iot PDF

The document describes three experiments involving controlling devices with Arduino. Experiment 1 involves controlling an LED and buzzer through serial monitor input. Experiment 2 involves creating LED patterns using push buttons. Experiment 3 controls a servo motor with a joystick and measures object distance with an ultrasonic sensor displaying it on an LCD.

Uploaded by

Sharmila Devi
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/ 24

INTERNET OF THINGS LAB REG NO: 20X51A0531

Date:

Experiment-1

a) Controlling actuators through Serial Monitor.


Software Requirements: Ardino IDE with supporting ESP-32 Board software
[Express if system version 2.0.9]
Hardware Requirements: ESP-32, IO Board, Connecting probes, LED,USB
cable to upload the code
Hardware Connections:
1. Connect the USB cable to ESP-32 Board.
2. Connect the Port to PC.
3. Connect the Power Plugs.
4. Connect LED Pin to D13 Pin of ESP-32.
5. Connect Buzzer Pin to D12 Pin of ESP-32.
6. Connect The Power Supply.

Source code:
char input;
const int led = 13;
const int buzzer = 12;

void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
digitalWrite(led, LOW);
digitalWrite(buzzer, LOW);
}

void loop()
{
if(Serial.available())
input = Serial.read();
if(input == '0')
digitalWrite(led, LOW);
if(input == '1')
digitalWrite(led, HIGH);
if(input == '2')
digitalWrite(buzzer, HIGH);
if(input == '3')

III-II CSE SREC ,NANDYAL Page 1


INTERNET OF THINGS LAB REG NO: 20X51A0531

digitalWrite(buzzer, LOW);
}
Outcome:

The LED’s on and off state is controlled using experimentation.

III-II CSE SREC ,NANDYAL Page 2


INTERNET OF THINGS LAB REG NO: 20X51A0531

Date:

b) Creating different led patterns and controlling them using push button
switches.

Software Requirements: Ardino IDE with supporting ESP-32 Board software


[Expressif system version 2.0.9]
Hardware Requirements: Push button switches, ESP-32, Io Board,
connecting probes, LED, USB cable to upload the code
Hardware Connections:
1. Connect the USB cable to ESP-32 Board.
2. Connect Green LED Pin to D12 Pin of ESP-32 Board.
3. Connect Yellow LED Pin to D13 Pin of ESP-32 Board.
4. Connect Switch 2 Pin to D23 Pin of ESP-32 Board.
5. Connect Switch 1 Pin to D22 Pin of ESP-32 Board.
6. Connect the Power Plugs.
7. Connect the Power Supply.

Source code:
const int led1 = 13;
const int led2 = 12;
const int led3 = 14;
const int sw1 = 23;
const int sw2 = 22;

void setup()
{
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(sw1, INPUT);
pinMode(sw2, INPUT);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
}

III-II CSE SREC ,NANDYAL Page 3


INTERNET OF THINGS LAB REG NO: 20X51A0531

void loop()
{
if(digitalRead(sw1)==LOW)
{
digitalWrite(led1, HIGH);
delay(300);
digitalWrite(led1, LOW);
delay(300);
digitalWrite(led1, HIGH);
delay(400);
digitalWrite(led1, LOW);
delay(400);
digitalWrite(led2, HIGH);
delay(400);
digitalWrite(led2, LOW);
delay(400);
digitalWrite(led3, HIGH);
delay(400);
digitalWrite(led3, LOW);
delay(400);
}
if(digitalRead(sw2)==LOW)
{
digitalWrite(led3, HIGH);
delay(300);
digitalWrite(led3, LOW);
delay(300);
digitalWrite(led3, HIGH);
delay(400);
digitalWrite(led3, LOW);
delay(400);
digitalWrite(led2, HIGH);
delay(400);
digitalWrite(led2, LOW);
delay(400);
digitalWrite(led1, HIGH);
delay(400);
digitalWrite(led1, LOW);
delay(400);
}
}
III-II CSE SREC ,NANDYAL Page 4
INTERNET OF THINGS LAB REG NO: 20X51A0531

Outcome:

 If push Button Switch 1 is pressed then LED’s are blinked from LEFT
to RIGHT on Universal board (or) Io Board
 If Push Button Switch 1 is pressed then LED’s are blinked from RIGHT
to LEFT on Universal board (or) Io Board.

III-II CSE SREC ,NANDYAL Page 5


INTERNET OF THINGS LAB REG NO: 20X51A0531

Date:

c) Controlling servo motor with the help of joystick.

Software Requirements:

Hardware Requirements:

Hardware Connections:

1. Connect the cable to ESP 32.


2. Connect the port to PC.
3. Connect the power plugs.
4. Connect the Joy Stick to the Board.
5. Connect Servo Brown-GND Pin.
6. Connect Servo Red ->+5V.
7. Connect Servo Yellow- SG_90
8. Connect VX Pin to VP(36) Pin of ESP 32 Board.
9. Connect the VY Pin to VN(39) Pin ESP32 Board.
10.Connect the Servp OUT Pin to D33 Pin of ESP-32.
11.Connect the Power Supply.

Source code:

#include <Servo.h>

#define VRX_PIN 36 // ESP32 pin GIOP36 (ADC0) connected to VRX pin

#define VRY_PIN 39 // ESP32 pin GIOP39 (ADC0) connected to VRY pin

#define SERVO_X_PIN 33 // ESP32 pin GIOP33 connected to Servo motor 1

Servo xServo; // create servo object to control a servo 1

void setup() {

III-II CSE SREC ,NANDYAL Page 6


INTERNET OF THINGS LAB REG NO: 20X51A0531

Serial.begin(9600) ;

xServo.attach(SERVO_X_PIN);

void loop() {

// read X and Y analog values

int valueX = analogRead(VRX_PIN);

int valueY = analogRead(VRY_PIN);

int xAngle = map(valueX, 0, 4095, 0, 180); // scale it to the servo's angle (0 to 180)

xServo.write(xAngle); // rotate servo motor 1

// print data to Serial Monitor on Arduino IDE

Serial.print("Joystick: ");

Serial.print(valueX);

Serial.print(", ");

Serial.print(valueY);

Serial.print(" => Servo Motor: ");

Serial.print(xAngle);

Serial.print("°, ");

III-II CSE SREC ,NANDYAL Page 7


INTERNET OF THINGS LAB REG NO: 20X51A0531

Outcome:

III-II CSE SREC ,NANDYAL Page 8


INTERNET OF THINGS LAB REG NO: 20X51A0531

Date:
Experiment-2

Calculate the distance to an object with the help of an ultrasonic sensor and
display it on an LCD.

Software Requirements: Ardino IDE with supporting ESP-32 Board software


[Express if system version 2.0.9]
Hardware Requirements: Ultrasonic sensor, LCD, ESP-32, Io Board,
Connecting probes, LED, USB cable to upload the code
Hardware Connections:
1. Connect the LCD on the Development Board.
2. Connect the USB cable to ESP-32.
3. Connect the Port to pc.
4. Connect the RS(Reset) pin to D5 pin of the ESP-32.
5. Connect EN(Enable) pin to D18 pin of the ESP-32.
6. Connect D4(Data pin) to D19 PIN OF the ESP-32.
7. Connect D5(Data pin) to D21 pin of the ESP-32.
8. Connect D6(Data pin) to D22 pin of the ESP-32.
9. Connect D7(Data pin) to D23 pin of the ESP-32.
10.Connect the ECHO pin to D27 pin of ESP-32.
11.Connect TRIG pin to D33 pin of ESP-32.
12.Connect the power plugs.
13.Connect the power supply.

Source code:

#include <LiquidCrystal.h>

LiquidCrystal lcd(5,18,19,21,22,23);

const int trigPin = 33;

const int echoPin = 27;

long duration;

III-II CSE SREC ,NANDYAL Page 9


INTERNET OF THINGS LAB REG NO: 20X51A0531

int distance;

void setup()

lcd.begin(16,2);

pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin, INPUT); // Sets the echoPin as an Input

project_name();

void loop(){

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance= duration*0.034/2;

lcd.setCursor(0, 0);

lcd.print("Distance: ");

lcd.setCursor(9, 0);

lcd.print(distance);

lcd.setCursor(13, 0);

lcd.print("Cm");

lcd.setCursor(0, 1);

III-II CSE SREC ,NANDYAL Page 10


INTERNET OF THINGS LAB REG NO: 20X51A0531

lcd.print(" ");

delay(500);

void project_name()

lcd.setCursor(0, 0);

lcd.print(" STT-MANI ");

lcd.setCursor(0, 1);

lcd.print("www.sttmani.com ");

delay(3000);

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("Measuring dist");

lcd.setCursor(0, 1);

lcd.print("Of An Object");

delay(2000);

lcd.clear();

III-II CSE SREC ,NANDYAL Page 11


INTERNET OF THINGS LAB REG NO: 20X51A0531

Outcome:

By using Ultrasonic sensor an object is detected and it’s distance is displayed


on LCD in centimeters

III-II CSE SREC ,NANDYAL Page 12


INTERNET OF THINGS LAB REG NO: 20X51A0531

Date:

Experiment-3
a) Controlling relay state based on ambient light levels using LDR sensor.

Software Requirements: Ardino IDE with supporting ESP-32 Board software


[Expressif system version 2.0.9]
Hardware Requirements: LDR sensor,LCD,ESP-32, Io Board, Connecting
probes, LED,USB cable to upload the code
Hardware Connections:

1. Connect the USB cable to ESP-32 Board.


2. Connect the port to PC.
3. Connect the Power Plugs.
4. Connect the LCD to the Board.
5. Connect RS(Reset) pin to D5 pin of ESP-32 Board.
6. Connect EN(Enable) pin to D18 pin of ESP-32 Board.
7. Connect D4(Data pin)to D19 pin of ESP-32 Board.
8. Connect D5(Data pin)to D21 pin of ESP-32 Board.
9. Connect D6 (Data pin)to D22 pin of ESP-32 Board.
10.Connect D7 (Data pin)to D23 pin of ESP-32 Board.
11.Connect LDR OUTPUT pin to D32 pin of ESP-32 Board.
12.Connect DC-RLY2 pin to D26 pin of ESP-32 Board.
13.Connect the Power Supply.

Source code:
#include<LiquidCrystal.h>

LiquidCrystal lcd(5, 18, 19, 21, 22, 23);

int relay=26;

void setup()

lcd.begin(16, 2);

III-II CSE SREC ,NANDYAL Page 13


INTERNET OF THINGS LAB REG NO: 20X51A0531

pinMode(relay,OUTPUT);

digitalWrite(relay,LOW);

project();

void loop()

int ldr_sensor_data=analogRead(32);

lcd.setCursor(0,0);

lcd.print("LDR DATA: ");

lcd.setCursor(0,1);

lcd.print(" ");

lcd.setCursor(9,0);

lcd.print(ldr_sensor_data);

delay(500);

if(ldr_sensor_data > 4000)

digitalWrite(relay,HIGH);

else

digitalWrite(relay,LOW);

delay(500);

void project()

III-II CSE SREC ,NANDYAL Page 14


INTERNET OF THINGS LAB REG NO: 20X51A0531

lcd.setCursor(0,0);

lcd.print(" Light Control ");

lcd.setCursor(0,1);

lcd.print(" By LDR ");

delay(3000);

lcd.clear();

III-II CSE SREC ,NANDYAL Page 15


INTERNET OF THINGS LAB REG NO: 20X51A0531

Outcome:

The “AMBIENT “ light levels measured by LDR and displayed on LCD

III-II CSE SREC ,NANDYAL Page 16


INTERNET OF THINGS LAB REG NO: 20X51A0531

Date:

b) Basic Burglar alarm security system with the help of PIR sensor and
buzzer.
Software Requirements:

ESP 32 board-Expressif system version 2.0.9


Hardware Requirements:
ESP32, IO board, IR Sensor, LCD, Connecting probes
Hardware Connections :
1. Connect the USB Cable to ESP-32 Board.
2. Connect the port to PC.
3. Connect the Power plugs.
4. Connect the LCD to the Board.
5. Connect buzzer to the 2nd pin of ESP 32.
6. Connect IR out to the 3rd pin of ESP 32.

Source code:
#include <LiquidCrystal.h>

#define PIR_sensor_value 13Qq20060suioplj;.,

#define buzzer 25

LiquidCrystal lcd(5, 18, 19, 21, 22, 23);

int sensor_value = 0;

void setup()

lcd.begin(16, 2);

pinMode(buzzer, OUTPUT);

digitalWrite(buzzer, LOW);

III-II CSE SREC ,NANDYAL Page 17


INTERNET OF THINGS LAB REG NO: 20X51A0531

pinMode(PIR_sensor_value, INPUT);

lcd.setCursor(0, 0);

lcd.print("Burglar Alaram ");

lcd.setCursor(0, 1);

lcd.print("Security By PIR");

delay(1000);

void loop()

if (digitalRead(PIR_sensor_value) == HIGH)

lcd.setCursor(0, 0);

lcd.print("Unknown Person ");

lcd.setCursor(0, 1);

lcd.print("Entered In Room");

buzzer_sound();

else

lcd.setCursor(0, 0);

lcd.print("Motion stopped! ");

lcd.setCursor(0, 1);

lcd.print(" ");

delay(50);

III-II CSE SREC ,NANDYAL Page 18


INTERNET OF THINGS LAB REG NO: 20X51A0531

void buzzer_sound()

digitalWrite(buzzer, HIGH);

delay(600);

digitalWrite(buzzer, LOW);

delay(400);

digitalWrite(buzzer, HIGH);

delay(600);

digitalWrite(buzzer, LOW);

delay(400);

digitalWrite(buzzer, HIGH);

delay(600);

digitalWrite(buzzer, LOW);

delay(400);

III-II CSE SREC ,NANDYAL Page 19


INTERNET OF THINGS LAB REG NO: 20X51A0531

Outcome:

If IR sensor detects any object movement then “unknown person entered into room”
message is displayed on LCD and the Buzzer rings otherwise “ Motion stopped “ message is
displayed on LCD

III-II CSE SREC ,NANDYAL Page 20


INTERNET OF THINGS LAB REG NO: 20X51A0531

Date:

C ) Displaying humidity and temperature values on LCD

Software Requirements: Ardino IDE with supporting ESP-32 Board software


[Expressif system version 2.0.9]
Hardware Requirements:DHT 11 sensor, LDC, ESP-32, Io Board,
Connecting probes, LED, USB cable to upload the code.

Hardware Connections:

1. Connect the USB Cable to ESP-32 Board.


2. Connect the port to PC.
3. Connect the Power plugs.
4. Connect the LCD to the Board.
5. Connect the RS(Reset) pin to D5 pin of ESP-32 Board.
6. Connect the EN(Enable) pin to the D18 pin of ESP-32 Board.
7. Connect the D4(Data Pin)to D19 pin of ESP-32Board.
8. Connect the D5(Data pin)to D21 pin of ESP-32 board.
9. Connect the D6(Data pin)to D22 pin of ESP-32 board.
10.Connect the D7(Data pin)to D23 pin of ESP-32 Board.
11.Connect the DHT11 OUT pin to D33 pin of ESP-32 Board.
12.Connect the Power Supply.

Source code:
#include<LiquidCrystal.h>

#include "DHT.h"

#include <Wire.h>

#define DHT11PIN 33

LiquidCrystal lcd(5, 18, 19, 21, 22, 23);

DHT dht(DHT11PIN, DHT11);

void setup()

III-II CSE SREC ,NANDYAL Page 21


INTERNET OF THINGS LAB REG NO: 20X51A0531

lcd.begin(16,2);

dht.begin();

project_name();

void loop()

float humi = dht.readHumidity();

float temp = dht.readTemperature();

lcd.setCursor(0,0);

lcd.print("Temperature: ");

lcd.setCursor(12,0);

lcd.print(temp);

lcd.setCursor(0,1);

lcd.print("Humidity: ");

lcd.setCursor(9,1);

lcd.print(humi);

lcd.print("%");

delay(1000);

void project_name()

lcd.setCursor(0,0);

lcd.print("Temperature and ");

lcd.setCursor(0,1);

III-II CSE SREC ,NANDYAL Page 22


INTERNET OF THINGS LAB REG NO: 20X51A0531

lcd.print("Humidity Display");

delay(2000);

lcd.clear();

III-II CSE SREC ,NANDYAL Page 23


INTERNET OF THINGS LAB REG NO: 20X51A0531

Outcome:

The measured Temperature and Humidity values by the DHT 11 sensor are
displayed on LDC

III-II CSE SREC ,NANDYAL Page 24

You might also like