Smart Building Using PIR Sensor
Smart Building Using PIR Sensor
Smart buildings are the ones where various parameters like temperature, lights, water etc. are
monitored and analysed so as to make it highly efficient.
In this course, we will work on smart lights in a smart building and learn how to develop such a
system and how to send data from such a system to the cloud for analysis. The project you
develop can sense the number of occupants in the meeting room with the help of PIR sensors
and automatically switch the lights ON/ OFF based on occupancy. You will be able to analyse
the usage of the meeting room, number of persons at various times of the day, the time for
which lights are on and the power consumed.
COMPONENTS REQUIRED:-
Arduino Uno
ESP8266
PIR Sensors
Relay Driver Modules
USB to UART Cable
Buzzer
Bulb Holders
Barrel Connector
Breadboard & Wire
1 pin Connectors
Wooden Chassis
Screwdriver*
Wire Stripper*
ARDUINO UNO:-
Technical Specifications
Pins
General Pin functions
LED: There is a built-in LED driven by digital pin 13. When the pin is HIGH
value, the LED is on, when the pin is LOW, it's off.
VIN: The input voltage to the Arduino/Genuino board when it's using an
external power source (as opposed to 5 volts from the USB connection or other
regulated power source). You can supply voltage through this pin, or, if
supplying voltage via the power jack, access it through this pin.
5V: This pin outputs a regulated 5V from the regulator on the board. The board
can be supplied with power either from the DC power jack (7 - 20V), the USB
connector (5V), or the VIN pin of the board (7-20V). Supplying voltage via the
5V or 3.3V pins bypasses the regulator, and can damage the board.
3V3: A 3.3 volt supply generated by the on-board regulator. Maximum current
draw is 50 mA.
GND: Ground pins.
IOREF: This pin on the Arduino/Genuino board provides the voltage reference
with which the microcontroller operates. A properly configured shield can read
the IOREF pin voltage and select the appropriate power source or enable
voltage translators on the outputs to work with the 5V or 3.3V.
Reset: Typically used to add a reset button to shields which block the one on
the board.
Serial / UART: pins 0 (RX) and 1 (TX). Used to receive (RX) and transmit
(TX) TTL serial data. These pins are connected to the corresponding pins of the
ATmega8U2 USB-to-TTL Serial chip.
External Interrupts: pins 2 and 3. These pins can be configured to trigger an
interrupt on a low value, a rising or falling edge, or a change in value.
PWM (Pulse Width Modulation): 3, 5, 6, 9, 10, and 11 can provide 8-bit PWM
output with the analog Write function.
SPI (Serial Peripheral Interface): 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK).
These pins support SPI communication using the SPI library.
TWI (Two Wire Interface) / I2C: A4 or SDA pin and A5 or SCL pin. Support
TWI communication using the Wire library.
AREF (Analog REFerence): Reference voltage for the analog inputs.
Features
Processor:
L106 32-bit RISC microprocessor core based on the Tensilica Xtensa Diamond
Standard 106Micro running at 80 MHz
Memory:
32 KiB instruction RAM
32 KiB instruction cache RAM
80 KiB user-data RAM
16 KiB ETS system-data RAM
External QSPI flash: up to 16 MiB is supported (512 KiB to 4 MiB typically
included)
IEEE 802.11 b/g/n Wi-Fi
Integrated TR switch, balun, LNA, power amplifier and matching network
WEP or WPA/WPA2 authentication, or open networks
16 GPIO pins
SPI
I2C (software implementation)
I2S interfaces with DMA (sharing pins with GPIO)
UART on dedicated pins, plus a transmit-only UART can be enabled on GPIO2
10-bit ADC (successive approximation ADC)
Pinout of ESP-01
The pinout is as follows for the common ESP-01
module:
Module Pinout
Basic Connections
Connect from 1 to 4 channels to your microcontroller and relays as required. In this
example we've connected to D10 through D13 on the Eleven. This is a particularly
convenient method because it can also be done by fitting a 5-pin male breakaway
header to the 4-Channel Relay Driver Module, and plugging it directly into the
Arduino header so that GND on the module aligns with GND on the header.
Relays are connected directly to each output channel. In many tutorials about
relays you will see instructions that you must include a protection diode across the
relay terminals. You do not need to do that when using the 4-Channel Relay Driver
Module, because the protection diodes are built in to the module itself.
Operation
A PIR sensor can detect changes in the amount of infrared radiation impinging
upon it, which varies depending on the temperature and surface characteristics of
the objects in front of the sensor. When an object, such as a person, passes in front
of the background, such as a wall, the temperature at that point in the sensor's field
of view will rise from room temperature to body temperature, and then back again.
The sensor converts the resulting change in the incoming infrared radiation into a
change in the output voltage, and this triggers the detection. Objects of similar
temperature but different surface characteristics may also have a different infrared
emission pattern, and thus moving them with respect to the background may
trigger the detector as well.
PIRs come in many configurations for a wide variety of applications. The most
common models have numerous Fresnel lenses or mirror segments, an effective
range of about 10 meters (30 feet), and a field of view less than 180°. Models with
wider fields of view, including 360°, are available, typically designed to mount on
a ceiling. Some larger PIRs are made with single segment mirrors and can sense
changes in infrared energy over 30 meters (100 feet) from the PIR. There are also
PIRs designed with reversible orientation mirrors which allow either broad
coverage (110° wide) or very narrow "curtain" coverage, or with individually
selectable segments to "shape" the coverage.
Security applications
When used as part of a security system, the electronics in the PIR typically control
a small relay. This relay completes the circuit across a pair of electrical
contacts connected to a detection input zone of the burglar alarm control panel.
The system is usually designed such that if no motion is being detected, the relay
contact is closed—a 'normally closed' (NC) relay. If motion is detected, the relay
will open the circuit, triggering the alarm; or, if a wire is disconnected, the alarm
will also operate.
BARREL CONNECTOR:-
ELECTRICAL CONNECTORS:-
An electrical connector is an electro-mechanical device used to join electrical
terminations and create an electrical circuit. Electrical connectors consist of plugs
(male-ended) and jacks (female-ended). The connection may be temporary, as for
portable equipment, require a tool for assembly and removal, or serve as a
permanent electrical joint between two wires or devices.[1] An adapter can be used
to effectively bring together dissimilar connectors.
Hundreds of types of electrical connectors are manufactured for power, signal and
control applications. Connectors may join two lengths of flexible copper wire or
cable, or connect a wire or cable to an electrical terminal. n computing, an
electrical connector can also be known as a physical interface
Male to Female Connectors Male to Male Connectors
BULB HOLDER:-
A light bulb socket, light socket, lamp socket or lamp holder is a device which
mechanically supports and provides electrical connections for a compatible
electric lamp. Sockets allow lamps to be safely and conveniently replaced (re-
lamping). There are many different standards for lamp holders, including early de
facto standards and later standards created by various standards bodies.
USB TO UART CABLE:-
BUZZER:-
Note how all holes in the selected row are connected together, so the holes in the
selected column. The set of connected holes can be called a node:
To interconnect the selected row (node A) and column (node B) a cable going from
any hole in the row to any hole in the column is needed:
Now the selected column (node B) and row (node A) are interconnected:
CONNECTION DIOGRAM:-