Experiment 2.1: 2. Objectives
Experiment 2.1: 2. Objectives
Experiment 2.1: 2. Objectives
1
1. Aim:
Formulate distance of an object using an ultrasonic sensor.
2. Objectives:
1. Learn about IoT based simulations.
2. Testing and model in IoT based simulation platform.
4. Hardware Required:
5. Theory:
Arduino: It is an open-source electronics platform. It consists ATmega328 8-bit Micro controller. It
can be able to read inputs from different sensors & we can send instructions to the micro controller in
the Arduino. It provides Arduino IDE to write code & connect the hardware devices like Arduino
boards & sensors.
Ultrasonic Sensor: An ultrasonic Sensor is a device used to measure the distance between the sensor
and an object without physical contact. This device works based on time-to-distance conversion.
Working Principle of Ultrasonic Sensor: Ultrasonic sensors measure distance by sending and
receiving the ultrasonic wave. The ultrasonic sensor has a sender to emit the ultrasonic waves and a
receiver to receive the ultrasonic waves. The transmitted ultrasonic wave travels through the air and
is reflected by hitting the Object. Arduino calculates the time taken by the ultrasonic pulse wave to
reach the receiver from the sender. We know that the speed of sound in air is nearly 344 m/s. So, the
known parameters are time and speed (constant). Using these parameters, we can calculate the
distance travelled by the sound wave. Formula: Distance = Speed * Time. In the code, the “duration”
variable stores the time taken by the sound wave traveling from the emitter to the receiver. That is
double the time to reach the object, whereas the sensor returns the total time including sender to
object and object to receiver. Then, the time taken to reach the object is half of the time taken to
reach the receiver. So we can write the expression as, Distance = Speed of Sound in Air * (Time
Taken / 2).
7. Code:
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20, 16, 2); // Format -> (Address,Width,Height )
#define echoPin 2 // attach pin D2 Arduino to Echo pin of Sensor module
#define trigPin 3 // attach pin D3 Arduino to Trig pin of Sensor module
long duration; // Declare variable to store echo time duration
int distance; // Declare variable to store the result (distance)
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight(); // Turn on the Backlight
pinMode(trigPin,OUTPUT); // Sets the trigPin as an OUTPUT
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
// Serial Communication is starting with 9600 of baudrate speed
Serial.begin(9600);
// The text to be printed in serial monitor
Serial.println("Distance measurement using Arduino Uno");
delay(500);
}
void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.0344 / 2;
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
lcd.clear(); // Clear the display buffer
lcd.setCursor(0, 0); // Set cursor for "Distance:" (Column, Row)
lcd.print("Distance:"); // print "Distance:" at (0, 0)
lcd.setCursor(0,1); // Set cursor for output value (0, 1)
lcd.print(distance); // print Output in cm at (0, 1)
Course Name: IoT Course Code: 21CSP-344
Lab Name: Darshit Sheth UID: 21BCS7782
lcd.setCursor(4, 1); // move cursor to (4, 1)
lcd.print("cm"); // print "cm" at (4, 1)
delay(1000);
delay(100);
}
8. Results:
Experiment – 3.1
Objectives:
Components Required:
Serial.begin(9600); pinMode(13,
OUTPUT);
}
void loop()
sensorValue = analogRead(A5); if
(sensorValue < 150 && sensorValue >64)
Serial.print(sensorValue, DEC);
Serial.println(" (NORMAL)");
}
else
delay(1000);
(b) Connections -
Result:
Experiment – 2.2
1. Aim:
To investigate real-time relationship between humidity and temperature in IoT.
2. Objectives:
1. Learn about IoT based simulations.
2. Testing and model in IoT based simulation platform.
3. Components Required:
Arduino Board
Breadboard
Jumper Wires
DH11 Temperature and Humidity Sensor
4. Theory:
DH11 Sensor: DHT11 Module features a temperature & humidity sensor complex with a calibrated
digital signal output. The exclusive digital-signal-acquisition technique and temperature & humidity
sensing technology ensure high reliability and excellent long-term stability. This sensor includes an
NTC for temperature measurement and a resistive-type humidity measurement component for
humidity measurement. These are connected to a high-performance 8-bit microcontroller, offering
excellent quality, fast response, anti-interference ability, and cost-effectiveness.
5. Procedure:
A. Hardware Connections:
Connect the DHT22 sensor to the Arduino:
VCC pin to 5V
GND pin to GND
DATA pin to digital pin 2
Connect one leg of the first LED to digital pin 13 through a resistor.
Connect one leg of the second LED to digital pin 12 through another resistor.
B. Upload Code:
Open Arduino IDE.
Copy and paste the provided code into a new sketch.
Ensure that the "DHT" library is installed in the Arduino IDE.
Select your Arduino board and COM port in the Tools menu.
Upload the code to the Arduino.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Serial.print(temperature);
Serial.println(F("°C "));
// Wait a few seconds between measurements.
delay(2000);
}
7. Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
8. Learning Outcomes:
a) Interfacing DHT11 Sensor with Arduino.
b) Learnt about Arduino Uno board.
c) Learnt about Sensor Data Interpretation
d) Implemented code on C++ language.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Experiment – 2.3
1. Aim:
Assemble and Controlling of multiple actuators using Arduino Uno for any IoT Application
2. Objectives:
1. Learn about IoT based simulations.
2. Testing and model in IoT based simulation platform.
3. Components Required:
1x Arduino
1x LED
1x Motor
1x Buzzer
4. Theory:
Actuators
Servo Motors: Servomotors have three wires: power, ground, and signal. The power wire is typically
red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black
or brown and should be connected to a ground pin on the board. The signal pin is typically yellow or
orange and should be connected to PWM pin on the board. In these examples, it is pin number 9.
5. Procedure:
1. Connect the Hardware:
- Attach the servo motor's signal wire to a digital pin (e.g., pin 9), the power wire to 5V, and the
ground wire to GND on the Arduino.
2. Install Arduino IDE:
- Download and install the Arduino IDE on your computer if you haven't already.
3. Open the Sketch:
- Launch Arduino IDE and open the "Sweep" sketch.
4. Upload the Sketch:
- Connect your Arduino board to the computer via USB.
- Select the board and port in the "Tools" menu.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
void loop()
{
// sweep the servo from 0 to 180 degrees in steps
// of 1 degrees
for (pos = 0; pos <= 180; pos += 1) {
// tell servo to go to position in variable 'pos'
servo_9.write(pos);
// wait 15 ms for servo to reach the position
delay(15); // Wait for 15 millisecond(s)
}
for (pos = 180; pos >= 0; pos -= 1) {
// tell servo to go to position in variable 'pos'
servo_9.write(pos);
// wait 15 ms for servo to reach the position
delay(15); // Wait for 15 millisecond(s)
}
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
6. Output:
8. Learning Outcomes:
a) Interfacing Actuators with Arduino.
b) Learnt about Arduino Uno board.
c) Learnt about Servo motors.
d) Implemented code on C++ language.
Experiment No. – 3.2
AIM:
Case study of Agriculture 4.0 using IoT and to develop an IoT model for the agriculture sector.
COMPONENTS REQUIRED:
• 1 Arduino UNO
• 1 Resistor 1k ohm
• Jumper Wires
• Soil Moisture Sensor
• NPK Sensor
• Leaf Wetness Sensor
• Temperature and Humidity sensor
THEORY:
Introduction:
With India's population crossing 1.3 billion in 2016, a balance between the optimum population
growth and a healthy of nation is far to be achieved. The rising population, there is a need for
increased agricultural production. Irrigated agriculture has been an extremely important source
increased agricultural production. Now a days people wants to observe their work from anywhere
on their digital devices such as Smartphone and tablet or laptop. Several things were made easy
by using Internet of Thing (IoT).
Proposed System:
All the sensors i.e. moisture sensor, humidity sensor, temperature sensor, is connected to the
microcontroller 5volts of power is supplied to the micro controller. From that microcontroller a
relay gets the information about the percent of the moisture in the soil.
Future Scope:
Smart farming based on IoT technologies enables growers and farmers to reduce waste and
enhance productivity ranging from the quantity of fertiliser utilised to the number of journeys the
farm vehicles have made, and enabling efficient utilisation of resources such as water, electricity,
etc. IoT smart farming solutions is a system that is built for monitoring the crop field with the help
of sensors (light, humidity, temperature, soil moisture, crop health, etc.) and automating the
irrigation system.
1) We conclude that this system is easy to implement and time, money and manpower saving
solution for irrigating fields.
2) A farmer should visualize his agricultural land’s moisture content from time to time and
water level of source is sufficient or not. IOT based smart irrigation system displays the values of
the sensors continuously in smart phone or on computer’s web page and farmer can operate them
anytime from and anywhere.
LEARNING OUTCOMES:
• Learnt about the iot in farming sector .
• Learnt how to connect equipment to iot to make smart device for agriculture.