Unit-4 iot
Unit-4 iot
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
mechanical installations.
They should enable automation and
maintain.
As a disadvantage there is a circumstance
It converts physical
It converts electrical signals
characteristics into electrical
into physical characteristics.
signals.
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
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.
the Arduino.
o Data: Connect the data pin to a digital pin on the
libraries.
3. Writing the Code:
#include <DallasTemperature.h>
#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();
cpp
void loop() {
sensors.requestTemperatures();
Serial.print("Temperature: ");
Serial.print(sensors.getTempCByIndex(0));
Serial.println(" °C");
delay(1000);
6.IoT Connectivity:
Advantages
Disadvantages
Benefits
the Arduino.
o Trigger: Connect the TRIG pin to a digital pin on the
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);
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
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
distance data.
Advantages
measurements.
Disadvantages
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
Applications:
1. Smart Home Automation:
o Presence Detection: Use IR motion sensors to
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
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);