0% found this document useful (0 votes)
11 views11 pages

Zeeshan IOT Assignment#2

The document is an assignment from the Department of Computer Science at MY University, focusing on the Internet of Things course. It details the wiring and coding for various sensors, including a PIR sensor for motion detection, an LDR module for light detection, and a MAX30100 heart rate sensor. Each section provides wiring steps, code examples, and explanations of the sensors' functionalities.

Uploaded by

ZeeshaN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views11 pages

Zeeshan IOT Assignment#2

The document is an assignment from the Department of Computer Science at MY University, focusing on the Internet of Things course. It details the wiring and coding for various sensors, including a PIR sensor for motion detection, an LDR module for light detection, and a MAX30100 heart rate sensor. Each section provides wiring steps, code examples, and explanations of the sensors' functionalities.

Uploaded by

ZeeshaN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Department

of Computer
Science MY
University,
Islamabad.

Assignment No: Assignment # 2

Course Title: Internet of Things (IS 301)

Group Names: Muhammad Zeeshan

Registration No: ASE222002

Batch: FALL-2022

Program: Software engineering

Semester: 5th

Course Instructor: Mr. Rana Mudassar Rasool

Submission Date: 12/9/2024


Assignment # 2

Question #1
Human motion sensor ( PIR sensor )

PIR sensor is a sensor that can detect the motion of humans (or animals). It's widely used to
detect the presence of humans in many applications (automatically turning ON/OFF light bulb,
opening/closing the door, activating/deactivating escalator, detecting an intruder ...)

PIR and Arduino Wiring Steps

1. VCC Pin: Connect the VCC pin of the PIR sensor to the 5V pin on the Arduino. This will
power the PIR sensor.

2. GND Pin: Connect the GND pin of the PIR sensor to one of the GND (Ground) pins on
the Arduino. This establishes a common ground for the circuit.

3. OUT Pin: Connect the OUT pin of the PIR sensor to a digital input pin on the Arduino.
Any digital pin can be used, but for this example, let’s use pin 12.

Diagram
Implementation

Pin Diagram
Code
Code
int pirPin = 12;
int motionStatus = 0; // variable to store the PIR sensor's motion status (high or low)
void setup() {
Serial.begin(9600);
pinMode(pirPin, INPUT); // set the Arduino pin that PIR sensor is connected to as an INPUT
}
void loop() {
motionStatus = digitalRead(pirPin); // read the PIR pin's current output (is it high or low?)
if (motionStatus == HIGH) {
Serial.println("Motion Detected");
else { Serial.println ("Motion Ended"); }
delay(100);

LDR Module(Light Sensor Module)

The LDR light sensor module can be utilized to detect the presence of light or measure the light
level in the surrounding environment. It provides two options via a digital output pin and analog
output pin.

LDR and Arduino Wiring Steps

1. VCC pin: It needs to be connected to VCC (3.3V to 5V).

2. GND pin: It needs to be connected to GND (0V).


3. DO pin: It is a digital output pin. It is HIGH if it is dark and LOW if it is light. The
threshold value between darkness and lightness can be adjusted using a built-in
potentiometer.

4. AO pin: It is an analog output pin. The output value decreases as the light gets
brighter, and it increases as the light gets darker.

Diagram

Pin diagram
Code

Code
#define DO_PIN 2 // Arduino's pin connected to DO pin of the ldr module
void setup() {
Serial.begin(9600); // initialize serial communication
pinMode(DO_PIN, INPUT); // initialize the Arduino's pin as an input
}
void loop() {
int lightState = digitalRead(DO_PIN);
if (lightState == HIGH)
Serial.println("The light is NOT present");
else
Serial.println("The light is present");

Hearth Rate sensor ( MAX30100 / MAX30102)

The MAX30100 is a Pulse Oximetry heart rate monitor and calculate SP02 sensor solution. It
combines two LEDs, a photodetector, optimized optics, and low-noise analog signal processing
to detect pulse oximetry and heart-rate signals. You can use this sensor with any microcontroller
like Arduino, ESP8266, or ESP32 and easily measure the patient’s health parameters. This
cheap DIY Pulse Oximeter sensor just cost around 350.RS and can be used in multiple
applications if you are a beginner or an Electronics enthusiast.

MAX30102 and Arduino Wiring Steps


1. VIN is the power pin. You can connect it to 3.3V or 5V output from your Arduino.
2. SCL is the I2C clock pin, connect to your Arduino’s I2C clock line.
3. SDA is the I2C data pin, connect to your Arduino’s I2C data line.
4. GND is the ground.

Diagram

Pin diagram
Code

Code
#include <Wire.h>
#include "MAX30105.h"
MAX30105 particleSensor;
void setup() {
Serial.begin(9600);
// Initialize sensor
if (particleSensor.begin() == false) {
Serial.println("MAX30102 was not found. Please check wiring/power.");
while (1);
}
particleSensor.setup(); //Configure sensor. Use 6.4mA for LED drive
}
void loop() {
Serial.print(" R[");
Serial.print(particleSensor.getRed());
Serial.print("] IR[");
Serial.print(particleSensor.getIR());
Serial.println("]");
}

You might also like