100% found this document useful (4 votes)
318 views34 pages

Arduino Sensor Integration Guide

Here are the key steps to control a lamp with a relay module and PIR motion sensor using Arduino: 1. Connect the PIR sensor's output pin to an Arduino digital pin. 2. Connect the relay module's IN pin to an Arduino digital pin and VCC/GND as per the module's specifications. 3. Connect the lamp to the relay module's COM and NO pins. 4. Use attachInterrupt() to monitor the PIR sensor pin for changes. Specify the pin, ISR function, and INTERRUPT mode as FALLING or RISING. 5. In the ISR function, turn on the relay by setting the digital pin HIGH for a set duration to

Uploaded by

abhilash
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
100% found this document useful (4 votes)
318 views34 pages

Arduino Sensor Integration Guide

Here are the key steps to control a lamp with a relay module and PIR motion sensor using Arduino: 1. Connect the PIR sensor's output pin to an Arduino digital pin. 2. Connect the relay module's IN pin to an Arduino digital pin and VCC/GND as per the module's specifications. 3. Connect the lamp to the relay module's COM and NO pins. 4. Use attachInterrupt() to monitor the PIR sensor pin for changes. Specify the pin, ISR function, and INTERRUPT mode as FALLING or RISING. 5. In the ISR function, turn on the relay by setting the digital pin HIGH for a set duration to

Uploaded by

abhilash
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

BMP180 (Barometric Pressure Sensor)

Specifications

 Supply Voltage:1.8V to 3.6V


 Low power consumption:0.5uA at 1Hz
 I2C interface
 Max I2C Speed: 3.5Mhz
 Very low noise: up to 0.02hPa (17cm)
 Pressure Range: 300hPa to 1100hPa (+9000m to -500m)

 Before taking a pressure reading you must take a temperature reading.


This is done with startTemperature () and getTemperature ().
The result is in degrees C.

 Once you have a temperature reading, you can take a pressure reading.
This is done with startPressure() and getPressure().
The result is in millibar (mb) aka hectopascals (hPa).
EXTAR:

 If you'll be monitoring weather patterns, you will probably want to


remove the effects of altitude. This will produce readings that can
be compared to the published pressure readings from other locations.
To do this, use the sealevel() function. You will need to provide
the known altitude at which the pressure was measured.

 If you want to measure altitude, you will need to know the pressure
at a baseline altitude. This can be average sealevel pressure, or
a previous pressure reading at your altitude, in which case
subsequent altitude readings will be + or - the initial baseline.
This is done with the altitude() function.

 Hardware connections:
- (GND) to GND
+ (VDD) to 3.3V
(WARNING: do not connect + to 5V or the sensor will be damaged!)

 You will also need to connect the I2C pins (SCL and SDA) to your
Arduino. The pins are different on different Arduinos:
Any Arduino pins labelled: SDA SCL
Uno, Red board, Pro: A4 A5
Mega2560, Due: 20 21
Leonardo: 2 3

Leave the IO (VDDIO) pin unconnected. This pin is for connecting


the BMP180 to systems with lower logic levels such as 1.8V
 REQUIRD LIBRARY:
#include <SFE_BMP180.h>
#include <Wire.h>
ULTRASONIC SENSOR (HC – SR04)

In order to generate the ultrasound, you need to set the Trig on a High State for 10 µs. That
will send out an 8 cycle sonic burst which will travel at the speed sound and IN order to
generate the ultrasound you need to set the Trig on a High State for 10 µs. That will send
out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the
Echo pin. The Echo pin will output the time in microseconds the sound waves travelled. it
will be received in the Echo pin. The Echo pin will output the time in microseconds the
sound waves travelled.
TEMPERATURE AND HUMIDITY SENSOR(DHT11)

INCLUDE LIBRARY <DHT.h>


RAIN DROP DETECTION SENSOR

Raindrop sensor is basically a board on which nickel is coated in the form of lines. It works on the principal
of resistance.
Rain Sensor module allows to measure moisture via analog output pins and it provides a digital output
when a threshold of moisture exceeds.
The module is based on the LM393 op amp. It includes the electronics module and a printed circuit board
that “collects” the rain drops. As rain drops are collected on the circuit board, they create paths of parallel
resistance that are measured via the op amp.
The sensor is a resistive dipole that shows less resistance when wet and more resistance when dry. When
there is no rain drop on board it increases the Resistance so we get high voltage according to V=IR.
When rain drop present it reduces the resistance because water is a conductor of electricity and presence
of water connects nickel lines in parallel so reduces resistance and reduces voltage drop across it.
SOIL MOISTURE SENSOR

SAME AS RAIN SENSOR

16X2 LCD INTERFACING


8 data pins (7-14 or D0-D7)
3rd pin for contrast control (VEE-controls how thick the characters should be shown)
We just need to control ENABLE and RS pins to send characters and data accordingly.
The contrast bit and READ/WRITE are not often used so they can be shorted to ground.

The connections which are done for LCD are given below:
 PIN1 or VSS to ground.
 PIN2 or VDD or VCC to +5v power.
 PIN3 or VEE to ground (gives maximum contrast best for a beginner).
 PIN4 or RS (Register Selection) to PIN12 of ARDUINO UNO.
 PIN5 or RW (Read/Write) to ground (puts LCD in read mode eases the communication for
user).
 PIN6 or E (Enable) to PIN10 of ARDUINO UNO.
 PIN11 or D4 to PIN5 of ARDUINO UNO.
 PIN12 or D5 to PIN4 of ARDUINO UNO.
 PIN13 or D6 to PIN3 of ARDUINO UNO.
 PIN14 or D7 to PIN2 of ARDUINO UNO.
 PIN15 to +5V with 221-ohm resistor in series.
 And the last PIN16 to ground.
The ARDUINO IDE allows the user to use LCD in 4-bit mode. This type of communication enables the user
to decrease the pin usage on ARDUINO, unlike other the ARDUINO need not to be programmed separately
for using it in 4 it mode because by default the ARDUINO is set up to communicate in 4-bit mode. In the
circuit you can see we have used 4bit communication (D4-D7).
First we need to enable the header file (‘#include <LiquidCrystal.h>’), this header file has
instructions written in it, which enables the user to interface an LCD to UNO in 4-bit mode
without any fuzz. With this header file we need not have to send data to LCD bit by bit, this
will all be taken care of and we don’t have to write a program for sending data or a
command to LCD bit by bit.
Second we need to tell the board which type of LCD we are using here. Since we have so
many different types of LCD (like 20x4, 16x2, 16x1 etc.). Here we are going to interface a
16x2 LCD to the UNO so we get ‘lcd.begin(16, 2);’. For 16x1 we get ‘ lcd.begin(16, 1);’.
In this instruction we are going to tell the board where we connected the pins. The pins
which are connected need to be represented in order as “RS, En, D4, D5, D6, D7”. These
pins are to be represented correctly. Since we have connected RS to PIN0 and so on as show
in the circuit diagram, we represent the pin number to board as “LiquidCrystal lcd (13, 12,
5, 4, 3, 2);”. The data which needs to be displayed in LCD should be written as “lcd. print
("hello, world!");”. With this command the LCD displays ‘hello, world!’.
MQ2 Gas/Smoke Sensor

MQ2 is one of the commonly used gas sensors in MQ sensor series. It is a Metal
Oxide Semiconductor (MOS) type Gas Sensor also known as Chemiresistors as
the detection is based upon change of resistance of the sensing material when
the Gas comes in contact with the material. Using a simple voltage divider
network, concentrations of gas can be detected.

MQ2 Gas sensor works on 5V DC and draws around 800mW. It can


detect LPG, Smoke, Alcohol, Propane, Hydrogen, Methane and Carbon Monoxid
e concentrations anywhere from 200 to 10000ppm.

more details on MQ2


Servo Motor

First we need to set frequency of PWM signal and for that we should call “#include <Servo.h>” header
file, on including this header file in the program, the frequency gets set automatically and we get to use
some special conditions, which enables the user to enter needed position of servo directly without any
fuzz.

Now we need to define a name for the servo “Servo sg90sevo”, here ‘sg90servo’ is the name chosen,
so while writing for potion we are going to use this name, this feature comes in handy when we have
many servos to control, we can control as many as eight servo by this.

Now we tell the UNO where the signal pin of servo is connected or where it needs to generate the
PWM signal. To do this we have “Sg90.attach(3);”, here we are telling the UNO we connected the
signal pin of servo at PIN3.
All left is to set the position, we are going set the position of servo by using “Sg90.write(30);”, by this
command the servo hand moves 30 degrees, so that’s it. After that whenever we need to change the
position of servo we need to call the command ”Sg90.write(needed_position_ angle);”. In this circuit we
will have two buttons one button increases the position of servo and the other is for decreasing the
position of servo.

Ultrasonic Radar
ARDUINO
RADAR.docx

Passive Infrared Sensor(PIR)


Microphone /Sound Sensor
RFID Reader(MFRC522)
LCD DISPLAY 16X2 i2C
RFID BASED AUTHENTICATION
REALY
Controlling a Lamp with a Relay Module and PIR Motion Sensor

attachInterrupt():
attachInterrupt(digitalPinToInterrupt(pin), ISR, mode) (recommended)

The first parameter to attachInterrupt() is an interrupt number. Normally


you should use digitalPinToInterrupt(pin) to translate the actual digital pin
to the specific interrupt number. For example, if you connect to pin 3,
use digitalPinToInterrupt(3) as the first parameter to attachInterrupt() .

Parameters

interrupt : the number of the interrupt. Allowed data types: int .


pin : the Arduino pin number.
ISR : the ISR to call when the interrupt occurs; this function must take
no parameters and return nothing. This function is sometimes referred
to as an interrupt service routine.
mode : defines when the interrupt should be triggered. Four constants
are predefined as valid values:

 LOW to trigger the interrupt whenever the pin is low,


 CHANGE to trigger the interrupt whenever the pin changes value
 RISING to trigger when the pin goes from low to high,
 FALLING for when the pin goes from high to low.

The Due, Zero and MKR1000 boards allow also:

 HIGH to trigger the interrupt whenever the pin is high.

Returns

Nothing

More details
Note
Inside the attached function, delay() won’t work and the value returned
by millis() will not increment. Serial data received while in the function
may be lost. You should declare as volatile any variables that you modify
within the attached function. See the section on ISRs below for more
information.

Common questions

Powered by AI

Performing a temperature reading before a pressure reading with the BMP180 sensor is necessary because temperature can significantly affect atmospheric pressure readings. The sensor uses the temperature reading to compensate and correct the pressure measurement, ensuring it reflects the true atmospheric conditions. This sequence is essential for reliability, as it accounts for variations in pressure due to temperature changes, thereby providing more accurate and consistent data .

The sealevel() function in the BMP180 sensor is utilized to adjust the pressure readings for altitude. This adjustment is crucial when monitoring weather patterns because it normalizes the pressure readings to sea level. By doing so, it allows for the comparison of these readings with other locations' data that is typically reported at sea level, thus ensuring accuracy and consistency in meteorological analyses .

The HC-SR04 ultrasonic sensor measures distance by emitting an ultrasonic burst when the Trig pin is set to a high state for 10 µs. This burst travels at the speed of sound and is reflected back to the sensor. The Echo pin receives this reflected signal and outputs the time in microseconds that the sound waves took to travel to and from the object. The distance can then be calculated based on the time taken and the speed of sound, making the Echo pin essential for capturing the travel time of the sound wave .

The MQ2 gas sensor detects various gases based on the change in resistance of its sensing material. It operates as a Metal Oxide Semiconductor type sensor, known as a chemiresistor. When target gases make contact with the sensing material, the resistance changes, and through a simple voltage divider network, the concentration of gases like LPG, smoke, alcohol, propane, hydrogen, methane, and carbon monoxide can be determined .

The attachInterrupt() function enhances Arduino systems by allowing them to respond immediately to real-time events. By utilizing interrupt service routines (ISRs), the function enables the system to handle events like pin state changes without polling, providing more efficient and responsive operations. This is critical for applications requiring precise timing and immediate action, such as handling motion detection or user input events. Interrupts are crucial for multitasking and reducing CPU usage in embedded systems .

Using 4-bit mode for interfacing an LCD with an Arduino results in significant advantages, primarily in reducing the number of required pins. This mode limits the use of data pins to D4-D7, which minimizes pin usage on the Arduino, freeing up other pins for additional peripherals. Moreover, the communication efficiency is enhanced as the LiquidCrystal library handles the transmission of data and commands in 4-bits, thus simplifying the programming process and minimizing potential errors .

The MQ2 gas sensor uses a simple voltage divider network to convert changes in the resistance of the sensor's material into voltage changes that can be easily measured. This arrangement converts the sensor's resistance changes, caused by the presence of different gases, into a corresponding analog voltage output. This methodology allows the sensor to detect concentrations of gases like LPG and smoke over a wide range (200 to 10000 ppm), and the network's configuration significantly influences its sensitivity and range by affecting the resolution of gas concentration detection .

The LM393 operational amplifier in the rain drop sensor plays a crucial role in moisture detection. It measures the parallel resistance created by water droplets on the circuit board. When water is present, it decreases resistance, leading to a lower voltage drop across the sensor's output. The LM393 acts by detecting these voltage changes and generating a digital signal once a predetermined moisture threshold is crossed, thus allowing for the detection and quantification of rain .

The principle of resistance applies to both rain drop and soil moisture sensors in that they measure changes in resistance to infer moisture levels. The rain sensor's resistance decreases when wet due to water connecting nickel lines in parallel, functioning as a resistive dipole. Similarly, soil moisture sensors detect changes in resistance as moisture levels alter the electrical conductivity in the soil. This principle affects their readings by providing higher voltage (indicating dry conditions) when resistance is high and lower voltage (indicating wet conditions) when resistance is low .

The BMP180 sensor's altitude measurement can be calibrated by using the altitude() function, which requires knowledge of the baseline pressure. This baseline pressure can be either an average sea-level pressure or a previous pressure reading at the measurement location. Knowing the baseline pressure is imperative because subsequent altitude readings are calculated relative to it. This ensures that altitude measurements are accurate and reflect changes from the known baseline condition .

You might also like