Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views22 pages

Lab Evaluation 2 Process Finall

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 22

Table of Contents:

Chapter No. Particular Page No.


1 Introduction 2
2 Code 8

3 Working 12
4 Reference 14

PAGE 1
Chapter 1: Introduction
In this project, we have to create a room monitoring system. In which , our
target is to measure the average temperature and humidity in the room.
Also to count the number of persons entered in the room and left the room
that is to count the total number of persons in the room.

To perform this project we will need some apparatus such as jumping


wires,breadboard,3 DHT 11 sensors, 2 ultrasonic sensors(src04),PIR sensor
and ESP32 board.

PAGE 2
Figure 1ESP32

Figure 2CONNECTING WIRES

Figure 3DHT11 SENSOR

Figure 4ULRASONIC SENSORS

PAGE 3
Figure 5BREADBOARD

PAGE 4
# DHT11 Sensor

DHT11 is a low-cost digital sensor for sensing temperature and


humidity. This sensor can be easily interfaced with any micro-controller
such as Arduino, Raspberry Pi etc… to measure humidity and
temperature instantaneously.

DHT11 humidity and temperature sensor is available as a sensor and as


a module. The difference between this sensor and module is the pull-up
resistor and a power-on LED. DHT11 is a relative humidity sensor. To
measure the surrounding air this sensor uses a thermistor and a
capacitive humidity sensor.

#ESP32 Board

ESP32 is a series of low-cost, low-power system on chip microcontroller


with integrated W-Fi and dual-mode Bluetooth
ESP32 is a series of low-cost, low-power system on a
chip microcontrollers with integrated Wi-Fi and dual-
mode Bluetooth. The ESP32 series employs either
a Tensilica Xtensa LX6 microprocessor in both dual-core
and single-core variations, Xtensa LX7 dual-core microprocessor
or a single-core RISC-V microprocessor and includes built-in
antenna switches, RF balun, power amplifier, low-noise receive
amplifier, filters, and power-management modules. ESP32 is
created and developed by Espressif Systems, a Shanghai-based
Chinese company, and is manufactured by TSMC using their
40 nm process.[2] It is a successor to the ESP8266 microcontroller.

PAGE 5
.
Fig 1 ESP32 with Its Pin Function
ULTRASONIC:

An ultrasonic sensor is a device that uses sound waves with frequencies


higher than the human audible range (typically above 20kHz) to detect the
distance or presence of objects.

The basic theory behind the operation of an ultrasonic sensor involves the
emission of high-frequency sound waves from a transmitter, which then
bounce off an object and return to a receiver. The time taken for the sound
wave to travel to the object and back is used to calculate the distance
between the sensor and the object.

The ultrasonic sensor consists of a transmitter, receiver, and a control


circuit. The transmitter emits a high-frequency sound wave, which travels
through the air until it hits an object. When the sound wave hits the object, it
reflects back towards the sensor and is detected by the receiver. The time
taken for the sound wave to travel to the object and back is then calculated
by the control circuit, which uses this information to determine the distance
to the object.

There are various types of ultrasonic sensors available, including single- and
multi-element transducers, and sensors with different beam patterns. The
choice of sensor depends on the specific application, such as distance
measurement, obstacle detection, or level sensing.

PAGE 6
Overall, ultrasonic sensors are widely used in automation, robotics,
automotive, and security industries, among others, due to their non-contact
nature, high accuracy, and reliability.

PAGE 7
CODE:
#include <WiFi.h>

#include <DHT.h>

#define DHTY DHT11

#define LED 2

#define max_dist 100

DHT dht[3] = {DHT(4,DHTY),DHT(5,DHTY),DHT(18,DHTY)};

void distance(int trig, int echo,unsigned long &T){

uint32_t distance;

pinMode(trig,OUTPUT);

pinMode(echo,INPUT);

digitalWrite(trig,LOW);

delayMicroseconds(2);

digitalWrite(trig,HIGH);

delayMicroseconds(15);

digitalWrite(trig,LOW);

long timetofly= pulseIn(echo, HIGH);

T = timetofly*0.034/2;

unsigned long dist1 = 0;

unsigned long dist2 = 0;

PAGE 8
int s1 = 0;

int s2 = 0;

unsigned long Total = 0;

unsigned long In = 0;

unsigned long Out = 0;

void setup() {

Serial.begin(115200);

delay(30);

pinMode(LED,OUTPUT);

for (int i = 0; i < 3; ++i){

dht[i].begin();

Serial.println();

void loop() {

float h=0;

float t=0;

for (int i = 0 ; i < 3; ++i){

h+= (dht[i].readHumidity()/3);

t+= (dht[i].readTemperature()/3);

PAGE 9
distance(13, 12, dist1);

delay(5);

distance(14, 27, dist2);

delay(5);

if(dist1<90 && s1==0){

s1=1;

if(s2==0){

Total = Total+1;

In = In + 1;

digitalWrite(LED,HIGH);

delay(150);

digitalWrite(LED,LOW);

delay(100);

if(dist2<90 && s2==0){

s2=1;

if(s1==0){

Total = Total-1;

Out = Out + 1;

digitalWrite(LED,HIGH);

delay(150);

digitalWrite(LED,LOW);

if(dist1>90 && dist2>90 && s1==1 && s2==1){

PAGE 10
s1=0, s2=0;

delay(1000);

Serial.println("\nTemperature is: ");

Serial.print(t);

Serial.print("*C\tHumidity is: ");

Serial.print(h);

Serial.print("%\nPeople Entered: ");

Serial.print(In);

Serial.print("\tPeople Left: ");

Serial.print(Out);

Serial.print("\nTotal People in the Room: ");

Serial.print(Total);

delay(100);

PAGE 11
PAGE 7
PAGE 8
PAGE 9
Chapter 3 : Working
1. The code is written in C++ and runs on a microcontroller board
ESP32.

2. The project consists of four main components: a DHT11


temperature and humidity sensor, two ultrasonic sensors, a PIR (Passive
Infrared) motion sensor, and an ESP32 Wi-Fi module.

3. The DHT11 sensor is used to measure the temperature and


humidity in the room, while the ultrasonic sensors are used to detect the
presence of people entering or leaving the room.

4. The PIR motion sensor is used to detect human motion within the
room.

5. The code starts by initializing the necessary libraries and the


sensors. It then connects to a Wi-Fi network using the Wi-Fi module.
Once connected, the code establishes a connection with the Adafruit IO
MQTT server using the Adafruit MQTT library. This is where the data
collected from the sensors is published to be viewed and analyzed.

6. The code then enters the main loop where it reads the sensor values
and publishes them to the Adafruit IO server. The PIR sensor is used to
determine if there is any human presence in the room. If there is, the
ultrasonic sensors are used to determine whether someone is entering or
leaving the room. The number of people entering and leaving the room is
tracked and the total number of people in the room is calculated.

7. The temperature, humidity, number of people entering, number of


people leaving, and the total number of people in the room are all
published to the Adafruit IO server via MQTT. This data can be viewed
and analyzed in real-time through the Adafruit IO dashboard.

PAGE 19
#Output :

Fig : Connection Diagram

Fig : Output On serial Monitor

PAGE 20
References:
2) ESP32 : https://en.wikipedia.org/wiki/ESP32 3) Fig 1 ESP32 with Its Pin
Functions : https://www.mischianti.org/wp-content/uploads/2021/07/ESP32-DEV

4) https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.javatpoint.com
%2Fmqttprotocol&psig=AOvVaw0VpmnHYAjXkMOyW8LM966C&ust=1682011
055300000&source=images&cd=vfe&ved=0CBEQjRxqFwoTCLCWsbq7tv4CFQA
AAAAdAAAAABAE
5) https://youtu.be/tQmXWNd1pNk
6)
7) Arduino ide examples
8) https://www.sciencedirect.com/topics/computer-science/passive-
infraredsensor#:~:text=A%20PIR%20sensor%20is%20an,in%20the%20form%20of%20r
adiation.
9) https://wokwi.com/projects/322410731508073042

PAGE 21

You might also like