0% found this document useful (0 votes)
3 views

Unit-4 iot

The document provides an overview of sensors and actuators, detailing their definitions, types, advantages, and disadvantages. It explains the differences between analog and digital sensors, their applications, and includes specific examples of interfacing temperature and ultrasonic sensors with Arduino for IoT projects. Additionally, it discusses the benefits and challenges of using these sensors in automation and monitoring systems.

Uploaded by

ragavihr131211
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Unit-4 iot

The document provides an overview of sensors and actuators, detailing their definitions, types, advantages, and disadvantages. It explains the differences between analog and digital sensors, their applications, and includes specific examples of interfacing temperature and ultrasonic sensors with Arduino for IoT projects. Additionally, it discusses the benefits and challenges of using these sensors in automation and monitoring systems.

Uploaded by

ragavihr131211
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Unit-4

SENSORS AND ACTUATORS


Sensor
Sensor is a device used for the conversion of physical events
or characteristics into the electrical signals.
This is a hardware device that takes the input from
environment and gives to the system by converting it.
For example, a thermometer takes the temperature as
physical characteristic and then converts it into electrical
signals for the system.
Types of Sensors
 Temperature Sensors: Take temperatures.
 Light Sensors: Light intensity sensors: It has the function
of detecting the intensity of the light.
 Pressure Sensors: To use it to measure pressure in gases
or liquids.
 Motion Sensors: Recognize motion in an established
region.
Advantages of Sensors
 Offer timely and accurate information as this is a critical
requirement by the high release frequency.
 Support automation and management of systems.
 Improve safety by maintaining check on important
parameters.
Disadvantages of Sensors
 Sometimes can be costly particularly the high precision
sensors.
 It can sometimes need some adjustments and can also
probably require maintenance in the long run.
 Interference from the environment is easy in this
process.

Actuator
Actuator is a device that converts the electrical
signals into the physical events or
characteristics. It takes the input from the
system and gives output to the environment. For
example, motors and heaters are some of the
commonly used actuators.
Types of Actuators
 Linear Actuators: Utilize a linear motion

to convert energy, Kinetic/pendulum.


 Rotary Actuators: This will affect the

creation of rotational motion.


 Hydraulic Actuators: How does fluid

power gives motion.


Pneumatic Actuators: Function with use
of compressed air.
Advantages of Actuators
 Assist in providing a fine level of control of

mechanical installations.
 They should enable automation and

therefore minimize the need for


intervention of human participants.
 Available in a range of variations and

suitability in multiple operations ranging


from everyday uses to industrial use.
Disadvantages of Actuators
 May consume much power in its operation

particularly when used in places that


involve much power such as in large
industries.
 May be large and costly to both install and

maintain.
 As a disadvantage there is a circumstance

that, with time the component is liable to


mechanical wear and tear.

Difference between Sensor and Actuator


SENSOR ACTUATOR

It converts physical
It converts electrical signals
characteristics into electrical
into physical characteristics.
signals.

It takes input from It takes input from output


environment. conditioning unit of system.

It gives output to input It gives output to


conditioning unit of system. environment.

Sensor generated electrical Actuator generates heat or


signals. motion.

It is placed at input port of It is placed at output port of


the system. the system.

It is used to measure the


It is used to measure the
continuous and discrete
physical quantity.
process parameters.

It gives information to the It accepts command to


system about environment. perform a function.

Example: Photo-voltaic cell Example: Stepper motor


SENSOR ACTUATOR

which converts light energy where electrical energy


into electrical energy. drives the motor.

ANALOG AND DIGITAL SENSORS


Analog and digital sensors are both used in the Internet of
Things (IoT) to detect environmental conditions and convert
them into signals. The choice between analog and digital
klsensors depends on the application's needs.
Analog sensors
 Provide a continuous range of values
 Are often used in industrial automation,
environmental monitoring, and scientific research
 Are simple and inexpensive
 Are more prone to noise interference
 Are useful for real-time data that requires fine-
grained resolution

Analog sensors measure physical quantities and produce a


continuous signal that varies in proportion to the physical
phenomenon.

These signals are usually in the form of voltage or current


that changes according to the input.
 Example of Analog Sensors:
o Temperature Sensors (e.g., thermocouples, thermistors):
Produce a continuous voltage corresponding to
temperature.
o Pressure Sensors: Convert pressure changes into
continuous analog signals.
o Light Sensors (e.g., LDRs): Output a voltage or current
proportional to the light intensity.
o Humidity Sensors: Output a continuous voltage signal
representing the humidity level.

 Key Characteristics:
o Continuous output: The value varies smoothly, offering
high-resolution data.
o Analog-to-digital conversion needed: To interface with
most digital IoT devices (like microcontrollers or
computers), the analog signal often needs to be converted
into a digital signal using an Analog-to-Digital Converter
(ADC).

Applications:
Analog Sensors: Often used in applications where smooth
and continuous data is needed, like audio recording or
temperature control.

Digital sensors
 Produce discrete values, such as 0s and 1s
 Are often used in modern intelligent systems
 Are more accurate and have higher interference
immunity
 Are less susceptible to noise interference
 Are easier to integrate

Digital sensors, on the other hand, generate data in a discrete


form.
They provide outputs that are typically binary (0s and 1s), or
they use protocols like I2C, SPI, or UART to send data in a
digital format.

Digital sensors often include built-in analog-to-digital


conversion.

 Example of Digital Sensors:


o Temperature Sensors (e.g., DS18B20): Directly

outputs temperature data in a digital format.


o Proximity Sensors (e.g., ultrasonic sensors):
Provide a digital signal indicating the presence or
distance of an object.
o Digital Accelerometers: Output digital signals
representing acceleration data.
o Motion Detectors (e.g., PIR sensors): Output a

digital signal indicating motion detection.


 Key Characteristics:
o Discrete output: The signal is more structured and

easier to process with digital devices.


o No need for ADC: Since the sensor already outputs

a digital signal, no analog-to-digital conversion is


required.
o Communication protocols: Often communicate
over established protocols like I2C, SPI, or UART,
making integration into IoT systems
straightforward.

Application
Digital Sensors: Ideal for applications requiring precise,
binary data, such as digital thermometers, GPS devices,
and most modern electronic devices.
INTERFACING TEMPERATURE SENSOR
 Interfacing a temperature sensor with an Arduino board
is a common task in IoT projects.
 It involves connecting the sensor to the Arduino, reading
the temperature data, and potentially sending this data
to an IoT platform for remote monitoring and control.
 Here, we will explore the process using the DS18B20
temperature sensor as an example.

1. Arduino Board (e.g., Arduino Uno)


2. Temperature Sensor (DS18B20)
3. 4.7k Ohm Resistor (if required)
4. Breadboard and Jumper Wires
5. USB Cable
6. Arduino IDE
Steps

1. Connecting the Sensor:


o Power: Connect the VCC pin of the DS18B20 to the

5V pin on the Arduino.


o Ground: Connect the GND pin to the ground pin on

the Arduino.
o Data: Connect the data pin to a digital pin on the

Arduino (e.g., D2).


o Pull-Up Resistor: Connect a 4.7k ohm resistor

between the VCC and data pin.


2. Installing Libraries:
o Open the Arduino IDE and go to Sketch -> Include

Library -> Manage Libraries.


o Install the One Wire and Dallas Temperature

libraries.
3. Writing the Code:

 Create a new sketch and include the libraries


at the beginning:
#include <OneWire.h>

#include <DallasTemperature.h>

 Define the pin and create sensor objects:

#define ONE_WIRE_BUS D2

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);
 In the setup function, initialize the serial communication
and the sensor:

cpp

void setup() {

Serial.begin(9600);

sensors.begin();

 In the loop function, request temperature readings and


print the values:

cpp

void loop() {

sensors.requestTemperatures();

Serial.print("Temperature: ");

Serial.print(sensors.getTempCByIndex(0));

Serial.println(" °C");

delay(1000);

4.Uploading the Code:

 Connect the Arduino to your computer via the USB


cable.
 Select the correct board and port from the Tools menu.
 Click the Upload button to upload the code to the
Arduino.

5. Reading the Data:

 Open the Serial Monitor in the Arduino IDE to view the


temperature readings.

6.IoT Connectivity:

 Use platforms like Arduino IoT Cloud or Blynk to send


the temperature data to the cloud.
 Set up an account, configure the device, and create a
dashboard to visualize the data.

Advantages

1. Real-Time Data: Provides instant temperature readings,


enabling real-time monitoring and control.
2. Automation: Facilitates automation in applications like
HVAC systems, greenhouses, and industrial processes.
3. Remote Monitoring: Using IoT platforms, temperature
data can be accessed from anywhere in the world.
4. Accuracy: High precision sensors offer accurate and
reliable temperature measurements.
5. Energy Efficiency: Helps optimize energy usage by
controlling heating and cooling systems based on actual
temperature readings.

Disadvantages

1. Initial Setup Cost: Requires investment in hardware


(sensors, microcontroller, connectivity modules) and
software.
2. Complexity: Involves programming and integration with
IoT platforms, which may require technical expertise.
3. Data Security: Ensuring the security of data transmitted
over IoT networks can be challenging.
4. Maintenance: Sensors and other components may need
regular maintenance and calibration for accurate
readings.

Benefits

1. Convenience: Automates temperature control, reducing


manual intervention.
2. Cost Savings: Optimizes energy consumption, leading to
lower utility bills.
3. Enhanced Control: Provides precise control over
environmental conditions, improving comfort and
efficiency.
4. Predictive Maintenance: Enables predictive
maintenance by identifying temperature anomalies and
potential issues before they become critical.
5. Data Analytics: Collects valuable data that can be
analyzed for insights and further optimization of
processes.

Ultra sound sensor


 An ultrasonic sensor is a commonly used device for
measuring distances by emitting high-frequency
sound waves.

 In Arduino-based IoT applications, the sensor


can help monitor distances in various environments
and send this data over the internet for remote
access and control
 it involves connecting the sensor to the Arduino,
reading the distance data, and sending this data to
an IoT platform for remote monitoring and control.

 The HC-SR04 ultrasonic sensor is widely used for


this purpose due to its simplicity and effectiveness.
1. Arduino Board (e.g., Arduino Uno)
2. HC-SR04 Ultrasonic Sensor
3. Breadboard and Jumper Wires
4. USB Cable
5. Arduino IDE
Steps:
1. Connecting the Sensor:
o Power: Connect the VCC pin of the HC-SR04 to the
5V pin on the Arduino.
o Ground: Connect the GND pin to the ground pin on

the Arduino.
o Trigger: Connect the TRIG pin to a digital pin on the

Arduino (e.g., D9).


o Echo: Connect the ECHO pin to another digital pin

on the Arduino (e.g., D10).


2. Installing Libraries:
o No additional libraries are required for basic

distance measurement with the HC-SR04 sensor.


3. Writing the Code:
o Create a new sketch and include the necessary

setup:
cpp
const int TRIG_PIN = 9;
const int ECHO_PIN = 10;
long duration;
long distance;

void setup() {
Serial.begin(9600);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
}

void loop() {
// Send a pulse to the TRIG pin
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);

// Read the echo pin


duration = pulseIn(ECHO_PIN, HIGH);
distance = (duration * 0.034) / 2;

Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");

delay(1000); // Wait for 1 second before next


measurement
}
o This code sends a pulse to the TRIG pin, waits for

the echo, and calculates the distance based on the


time taken for the sound wave to return.
4. Uploading the Code:
o Connect the Arduino to your computer via the USB

cable.
o Select the correct board and port from the Tools

menu.
o Click the Upload button to upload the code to the

Arduino.
5. Reading the Data:
o Open the Serial Monitor in the Arduino IDE to view

the distance measurements.


6. IoT Connectivity:
o Arduino IoT Cloud: Use the Arduino IoT Cloud to

send the distance data to the cloud.


 Create an account on the Arduino IoT Cloud,

add your Arduino device, and set up a Thing


with a variable for distance.
 Configure the dashboard to visualize the

distance data.
 Advantages

 Non-contact Detection: They can detect


objects without physical contact, making them
suitable for various applications.
 Wide Range of Applications: Used in distance

measurement, object detection, level control,


and more.
 High Sensitivity: They can detect objects with

different shapes, sizes, and materials.


 Adverse Conditions: They work well in
environments with dust, rain, or snow.
 High Accuracy: They provide accurate distance

measurements.
 Disadvantages

 Temperature Sensitivity: Their performance

can be affected by temperature variations.


 Difficulty with Soft Objects: They may struggle

with soft, curved, or thin objects.


 False Readings: Loud noises or high-density

surfaces can cause false readings.


 Minimum Sensing Distance: They have a
minimum sensing distance that must be
considered.
 Benefits in IoT
 Automation: Ideal for automating processes
like door openers, parking sensors, and smart
home systems.
 Cost-Effective: Generally affordable and easy
to integrate with Arduino boards.
 Versatility: Can be used in various IoT
applications, from industrial automation to
consumer electronics.
 Reliability: Provide consistent performance in
different environmental conditions.
Infrared sensor with arduino
 An infrared (IR) sensor with Arduino in IoT is a device
that detects objects by emitting and receiving infrared
light.
 It's used in smart home systems, security systems, and
industrial automation to detect the presence or
movement of objects without physical contact.
 An infrared (IR) sensor in Arduino IoT refers to a sensor
that detects infrared radiation (heat or light) and is used
in conjunction with an Arduino board to monitor and
measure environmental conditions.
Components:
1. IR Sensor:
o IR Distance Sensor (e.g., Sharp GP2Y0A21YK0F):

Measures the distance of an object by reflecting


infrared light and calculating the time it takes for
the reflection to return.
o IR Motion Sensor (e.g., HC-SR501): Detects
movement in its range by sensing changes in
infrared radiation from the environment.
2. Arduino Board:
o Common choices are Arduino Uno (for simple

setups) or ESP8266/ESP32 (for IoT-enabled devices


with built-in Wi-Fi for cloud communication).
3. Wi-Fi Module (if using Arduino Uno): Allows the Arduino
to connect to the internet, typically using ESP8266 or
ESP32 boards that provide Wi-Fi connectivity.
4. Cloud Platform: Data is sent to a cloud platform like
ThingSpeak, Blynk, or Adafruit IO, where the sensor
data is displayed and can be remotely monitored.
5. Power Supply: Batteries or USB power supply to power
the Arduino and sensors.

Working Principle:
The operation of the IR sensor with Arduino in an IoT
setup involves the following steps:
1. Sensing with IR Sensor:
o The IR distance sensor emits infrared light, and the

sensor calculates the distance by measuring the


reflection time.
o The IR motion sensor detects infrared radiation

from objects in its field of view, typically by sensing


the motion of people or animals.
2. Data Collection by Arduino:
o The Arduino reads the analog or digital data from

the IR sensor. For example, an IR distance sensor


might provide an analog output representing the
distance to an object, while a motion sensor gives a
digital HIGH or LOW signal depending on motion.
3. Wi-Fi Communication:
o If using an ESP8266/ESP32 board, the Arduino

sends the sensor data over Wi-Fi to the internet.


o The data can be sent using an HTTP protocol to a

cloud platform or IoT server.


4. Data Upload to Cloud:
o Once connected to Wi-Fi, the Arduino sends the

sensor data to an IoT platform like ThingSpeak or


Blynk.
o The data is uploaded via HTTP or MQTT protocols,

where the sensor values are stored and displayed in


real-time.
5. Remote Monitoring:
o The cloud platform stores and visualizes the data.

o Users can monitor the sensor readings remotely

from any internet-enabled device (PC, smartphone,


etc.).

Applications:
1. Smart Home Automation:
o Presence Detection: Use IR motion sensors to

detect human presence and trigger smart actions


(e.g., turning on lights, adjusting temperature).
o Security: Motion sensors can be used in security

systems to detect unauthorized movement.


2. Distance Measurement:
o Object Monitoring: Measure the distance of
objects to ensure proper placement or detect
obstacles in robotic applications.
3. Smart Healthcare:
o Patient Monitoring: Use IR sensors to monitor the

presence or movement of patients in hospitals or


care homes.
4. Industrial Automation:
o Proximity Sensing: In factories, IR sensors can

detect the presence of objects or measure the


distance between moving parts.
5. Environmental Monitoring:
o Parking Sensors: IR sensors can be used in parking

systems to detect available parking spaces.

Example Code:
cpp
Copy
int sensorValue = analogRead(A0); // Read IR sensor
data
WiFiClient client;
if (client.connect("api.thingspeak.com", 80)) {
client.print("GET /update?
api_key=YOUR_API_KEY&field1=" +
String(sensorValue));
}
Advantages
1. Non-contact Detection: IR sensors can detect objects
without physical contact.
2. Versatile Applications: Used in obstacle detection, line
following robots, and proximity sensing.
3. Affordable: Generally inexpensive and easy to use with
Arduino.
Disadvantages
1. Sensitivity to Light: Performance can be affected by
ambient light.
2. Short Range: Typically effective only at short distances.
3. Material Dependence: Performance varies with the type
and color of objects detected.
interfacing led and buzzer with arduino
 Interfacing an LED and a buzzer with an
Arduino in IoT means connecting these
components to the Arduino to create a system
that can produce both visual (LED) and
auditory (buzzer) signals.
 This setup is often used in IoT projects to
indicate alerts or notifications based on sensor
data, such as
 motion detection
 temperature changes
 or other monitored conditions

 The Arduino controls the LED and buzzer


based on the programmed instructions,
providing feedback to users in smart home
systems, security systems, and other
automated applications.
Components Required:
1. Arduino Board (e.g., Arduino Uno, ESP8266, or ESP32)
2. LED (Light Emitting Diode)
3. Buzzer (Active or Passive)
4. Resistors (for the LED, usually 220Ω to 330Ω)
5. Jumper Wires
6. Breadboard
7. Wi-Fi Module (if not using ESP8266/ESP32)
8. Cloud Platform (e.g., ThingSpeak, Blynk) for IoT
integration

Basic Circuit Setup:


1. LED Setup:
o Connect the longer leg (anode) of the LED to a

digital pin on the Arduino (e.g., Pin 13).


o Connect the shorter leg (cathode) of the LED to

ground through a 220Ω resistor.


2. Buzzer Setup:
o Connect the positive leg of the buzzer to a digital

pin on the Arduino (e.g., Pin 8).


o Connect the negative leg of the buzzer to ground.

Code Example
int ledPin = 3;
int buzzerPin = 4;

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}

void loop() {
digitalWrite(ledPin, HIGH);
digitalWrite(buzzerPin, HIGH);
delay(1000);

digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
delay(1000);

Serial.println("LED and Buzzer are toggling.");


}
Explanation
 pinMode(): Sets the specified digital pins as outputs.
 digitalWrite(): Turns the LED and buzzer on and off.
 delay(): Pauses the program for a specified time (in
milliseconds).
 Serial.println(): Prints messages to the Serial Monitor for
debugging.
Applications in IoT
 Alert Systems: Use the LED and buzzer to create alert
systems for various sensors (e.g., temperature, motion).
 Smart Home Automation: Integrate with other sensors
to create interactive smart home projects.
Advantages
1. Simplicity: Interfacing an LED and buzzer with Arduino is
straightforward and easy to understand, making it great
for beginners.
2. Cost-Effective: LEDs and buzzers are inexpensive
components, making this an affordable setup.
3. Versatile Applications: Can be used in a variety of IoT
projects such as alarms, indicators, and notifications.
4. Visual and Auditory Feedback: Provides both visual
(LED) and auditory (buzzer) signals, enhancing user
awareness and interaction.
Disadvantages
1. Limited Information Output: LEDs and buzzers can only
provide basic signals and may not convey detailed
information.
2. Power Consumption: Continuous use of the buzzer can
consume a significant amount of power.
3. Noise Pollution: The buzzer can be loud and potentially
annoying in quiet environments.
Benefits in IoT
1. Immediate Feedback: Instant alerts and notifications
through LED and buzzer signals improve response time.
2. Enhanced User Interaction: Combining visual and
auditory signals makes it easier for users to notice and
respond to alerts.
3. Easy Integration: Simple to integrate with Arduino,
allowing for quick prototyping and development of IoT
projects.
4. Improved Safety: Useful in safety-critical applications
like security systems and alarms, ensuring that alerts are
noticed promptly.

You might also like