IoT Material UNIT-3
IoT Material UNIT-3
TEMPERATURE SENSOR
A temperature sensor is a device that is designed to measure the degree of hotness or coolness in an
object. The working of a temperature meter depends upon the voltage across the diode. The
temperature change is directly proportional to the diode’s resistance. The cooler the temperature, the
lesser will be the resistance, and vice-versa. The resistance across the diode is measured and
converted into readable units of temperature (Fahrenheit, Celsius, Centigrade, etc.) and, displayed in
numeric form over readout units. In the geotechnical monitoring field, these temperature sensors are
used to measure the internal temperature of structures like bridges, dams, buildings, power plants,
etc.
Well, there are many types of temperature sensors, but, the most common way to categorize them is
based on the mode of connection which includes, contact and non-contact temperature
sensors.Contact sensors include thermocouples and thermistors because they are in direct contact with
the object they are to measure. Whereas, the non-contact temperature sensors measure the thermal
radiation released by the heat source. Such temperature meters are often used in hazardous
environments like nuclear power plants or thermal power plants.In geotechnical monitoring,
temperature sensors measure the heat of hydration in mass concrete structures. They can also be used
to monitor the migration of groundwater or seepage. One of the most common areas where they are
used is while curing the concrete because it has to be relatively warm in order to set and cure
properly. The seasonal variations cause structural expansion or contraction thereby, changing its
overall volume.
The basic principle of working the temperature sensors is the voltage across the diode terminals. If
the voltage increases, the temperature also rises, followed by a voltage drop between the transistor
terminals of the base and emitter in a diode.Besides this, Encardio Rite has a vibrating wire
temperature sensor that works on the principle of stress change due to temperature change.The
vibrating wire temperature meter is designed on the principle that dissimilar metals have a different
linear coefficient of expansion with temperature variation.It primarily consists of a magnetic, high
tensile strength stretched wire, the two ends of which are fixed to any dissimilar metal in a manner
that any change in temperature directly affects the tension in the wire and, thus, its natural frequency
of vibration.The dissimilar metal, in the case of the Encardio Rite temperature meter, is aluminum
(Aluminum has a larger coefficient of thermal expansion than steel.) As the temperature signal is
converted into frequency, the same read-out unit which is used for other vibrating wire sensors can
also be used for monitoring temperature also.
The change in temperature is sensed by the specially built Encardio Rite vibrating wire sensor and is
converted to an electrical signal which is transmitted as a frequency to the read-out unit.The
frequency, which is proportional to the temperature and in turn to the tension ‘σ’ in the wire, can be
determined as follows:
f = 1/2 [σg/ρ] / 2l Hz
Where:
l = length of wire
Temperature sensors are available in various types, shapes, and sizes. The two main types of
temperature sensors are:
Contact Type Temperature Sensors: There are a few temperature meters that measure the degree of
hotness or coolness in an object by being in direct contact with it. Such temperature sensors fall under
the category of contact type. They can be used to detect solids, liquids, or gases over a wide range of
temperatures.
Non-Contact Type Temperature Sensors: These types of temperature meters are not in direct contact
with the object rather, they measure the degree of hotness or coolness through the radiation emitted
by the heat source.
Reference-circuit digest
VCC is the power supply pin of the LM35 temperature sensor IC that can be connected to 4V or
32V of the supply.
GND is the ground pin of the LM35 temperature sensor IC and it should be connected to the supply
ground.
OUT This is the temperature sensor analog output pin. This is the analog output pin of the
temperature sensor, the output voltage on this pin is directly proportional to the temperature.
The LM35 is a low-power, low-cost, high-precision temperature sensor designed and manufactured
by Texas instruments. This IC provides a voltage output that is linearly proportional to the change in
temperature.
Reference-circuit digest
The LM35 sensor is moderately precise and its robust construction makes it suitable for various
environmental conditions. Additionally, you don't need any external component to calibrate this
circuit and it has a typical accuracy of ±0.5°C at room temperature and ±1°C over a full −55°C to
+155°C temperature range. It has an operating voltage of 4V to 30V and consumes 60-uA current
while it's in working state, this also makes it perfect for battery-powered applications.
There are two disadvantages of this sensor. The first big disadvantage of this sensor is that it cannot
measure negative temperature, for that you have to bias it with a dual polarity supply. If your project
requires negative temperature measurements, you can opt for a LM36 sensor. The second
disadvantage of this sensor is that it's very sensitive to noise because it outputs data in analog format.
If you want to learn more about this sensor you can check out the Datasheet of LM35 Temperature
Sensor IC.
The LM35 temperature sensor uses the basic principle of a diode to measure known temperature
value. As we all know from semiconductor physics, as the temperature increases the voltage across a
diode increases at a known rate. By accurately amplifying the voltage change, we can easily generate
a voltage signal that is directly proportional to the surrounding temperature. The screenshot below
shows the internal schematic of LM35 temperature sensor IC according to the datasheet.
In practice, this diode that they are using to measure the temperature is not actually a PN Junction
diode but its a diode-connected transistor. That is why the relationship between the forward voltage
and the transistor is so linear. The temperature coefficient vs collector current graph below gives you
a better understanding of the process.
The working of the LM35 Temperature Sensor is very simple and easy to understand. We just
have to connect 5V and Ground to the sensor and we need to measure the output voltage from the
output pin.
According to the datasheet of the device, the sensor should give us 10mv/°C. So, if the temperature of
the room is 18°C then the sensor should give us 180mV at the output pin.
Now that we have understood how the LM35 Temperature Sensor works we can connect all the
required wires to Arduino UNO. The arduino lm35 connection diagram is shown below-
Connecting the LM35 sensor to the Arduino is really simple. You just need to connect 5V power to
the sensor and you need to connect the output of the sensor to the A0 pin of the Arduino. Once the
connection is done you need to write the code to convert the output voltage of the sensor to
temperature data. For that, first, you need to convert the ADC values to voltage and multiply that
voltage to 10 and you will get the output in temperature. With that, you’re now ready to upload the
code to Arduino. An image showing the actual Arduino LM35 hardware setup is shown below.
The Arduino Code for Interfacing the LM35 Temperature Sensor is very simple and easy to
understand. We just need to read the analog data out of the sensor and convert it to temperature data.
We Initialize our code by defining the pin in which the LM35 Temperature sensor is connected.
Next, we have our setup() function, in the setup, we just need to initialize the serial monitor for
debugging.
void setup() {
Serial.begin(9600);
Next we have our loop function, in the loop function we read the pin and store the ADC data in
adcData variable. Next, we convert the ADC data to the voltage value and store it in a local variable
named voltage, and finally, we convert the voltage value to temperature and store it in a variable
named temperature and print that in the serial monitor window. At last, we added 800ms and finished
the code.
void loop() {
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println("*C");
Humidity Sensor is one of the most important devices that has been widely in consumer, industrial,
biomedical, and environmental etc. applications for measuring and monitoring Humidity.Humidity is
defined as the amount of water present in the surrounding air. This water content in the air is a key
factor in the wellness of mankind. For example, we will feel comfortable even if the temperature is
00C with less humidity i.e. the air is dry.But if the temperature is 100C and the humidity is high i.e.
the water content of air is high, then we will feel quite uncomfortable. Humidity is also a major factor
for operating sensitive equipment like electronics, industrial equipment, electrostatic sensitive devices
and high voltage devices etc. Such sensitive equipment must be operated in a humidity environment
that is suitable for the device.
Moisture: Generally, the term Moisture means water content of any material or substance. But
practically, the term Moisture refers to the water content in solids and liquids. The term Humidity
refers to the water content in gases (air).Absolute Humidity: Absolute Humidity (AH) is the ratio of
mass of the water vapour to the volume of the air. If m is the mass of the water vapour and V is the
total volume i.e. volume of air and water vapour mixture, then Absolute Humidity AH is given by
AH = m/V
Absolute Humidity doesn’t take temperature in to account but it changes with temperature and
pressure.
Relative Humidity: Whenever we talk about measuring Humidity, it usually Relative Humidity that
we are talking about (unless otherwise specified).Relative Humidity or RH is the ratio of the actual
water vapour pressure present in the air at a temperature to the maximum water vapour pressure
present in the air at the same temperature.In weather reports and forecasts, the probability of
precipitation or dew or fog is indicated using Relative Humidity and hence, it is considered an
important metric.
Relative Humidity takes both temperature and pressure in to consideration. Hence, the Humidity
Sensors which measure Relative Humidity, measure both the moisture content as well as the air
temperature.
Specific Humidity: Specific Humidity (SH) is the ratio of mass of the water vapor to the total mass of
the air.
Mixing Ratio or Humidity Ratio: Mixing Ratio is the ratio of mass of the water vapor to mass of the
dry air.
Dew Point Temperature: Dew Point Temperature is the temperature at with the water vapor content is
saturated in the air. At Dew Point temperature, the Relative Humidity RH is 100%. In other words,
for the air to hold maximum amount of water vapor (or moisture), it has to reach Dew Point
Temperature.
Humidity Sensors are very important devices that help in measuring the environmental humidity.
Technically, the device used to measure the humidity of the atmosphere is called Hygrometer.
Humidity Sensors or Hygrometers can be classified based on the type of humidity it is used for
measuring i.e.
Absolute Humidity (AH) sensors or Relative Humidity (RH) sensors. Humidity Sensors can also be
classified based on the parameter used for measuring Humidity i.e. Capacitive Humidity Sensors,
Electrical Conductivity (or Resistive) Humidity Sensors and Thermal Conductivity Humidity
Sensors.
There are other types of Humidity Sensors or Hygrometers like Optical Hygrometer, Oscillating
Hygrometer and Gravimetric Hygrometer.
Let us see about different types of Humidity Sensors or Hygrometers along with their working
principles.
Humidity Sensors based on capacitive effect or simply Capacitive Humidity Sensors are one of the
basic types of Humidity Sensors available.
They are often used in applications where factors like cost, rigidity and size are s of concern. In
Capacitive Relative Humidity (RH) Sensors, the electrical permittivity of the dielectric material
changes with change in humidity.
A simple Capacitive RH Sensor can be made from an air filled capacitor as the moisture in the
atmosphere changes its permittivity. But for practical applications, air as a dielectric is not feasible.
Hence, the space between the capacitor plates is usually filled with an appropriate dielectric material
(isolator), whose dielectric constant varies when it is subjected to change in humidity.
The common method of constructing a capacitive RH sensor is to use a hygroscopic polymer film as
dielectric and depositing two layers of electrodes on the either side.
Another way to use the capacitive RH sensors is to observe the changes in the frequency of the
oscillator constructed using a capacitor with RH sensitive test subject as dielectric. This setup is often
employed in pharmaceutical products.
The test samples like medical tablets are placed between two plates (which form the capacitor
electrodes) to form a capacitor in the LC Oscillator circuit. The frequency of the oscillator changes
with humidity surrounding the test sample.
Let us see the construction of a thin thermostat polymer film based capacitive RH Sensor. It is
fabricated on a silicon substrate. On this substrate, two metal electrodes made of either aluminium,
platinum or chromium are deposited. The shape of these electrodes is carved out such that, the
electrodes form an interdigitized pattern.
On top of this layer, a dielectric layer is deposited. The following image shows a top and cross
section view of the capacitive humidity sensor. Note that two temperature sensitive resistors are
deposited on the same substrate to provide temperature compensation.
The distance from the sensor and signalling circuit is very limited.
Capacitive Humidity Sensors are used in a wide range of applications including but not limited to:
HVAC Systems
Weather Stations
Automobiles
Food Processing
Resistive Humidity Sensors are another important type of Humidity Sensors that measure the
resistance (impedance) or electrical conductivity. The principle behind resistive humidity sensors is
the fact that the conductivity in non – metallic conductors is dependent on their water content.
The Resistive Humidity Sensor is usually made up of materials with relatively low resistivity and this
resistivity changes significantly with changes in humidity. The relationship between resistance and
humidity is inverse exponential. The low resistivity material is deposited on top of two electrodes.
The electrodes are placed in interdigitized pattern to increase the contact area. The resistivity between
the electrodes changes when the top layer absorbs water and this change can be measured with the
help of a simple electric circuit.
Some of the commonly used materials are salt, specially treated substrates, solid polyelectrolytes and
conductive polymers. Modern Resistive Humidity Sensors are coated with ceramic substance to
provide extra protection. The electrodes in the sensor are usually made of noble metals like gold,
silver or platinum.
Low cost
Small Size
The distance between the sensor and signal circuit can be large (suitable for remote operations).
Resistive Humidity Sensors are sensitive to chemical vapors and other contaminants
The output readings may shift if used with water soluble products.
Resistive or Electrical Conductive Humidity sensors are low cost sensors with relatively small size.
They are often used in several industrial, domestic or residential and commercial applications.
Thermal Conductivity Humidity Sensors are also known as Absolute Humidity (AH) Sensors as they
measure the Absolute Humidity. Thermal Conductivity Humidity Sensors measure the thermal
conductivity of both dry air as well as air with water vapor. The difference between the individual
thermal conductivities can be related to absolute humidity.
The best component to accomplish thermal conductivity based humidity sensor is thermistor. Hence,
two tiny thermistors with negative temperature coefficient are used to for a bridge circuit.
In that, one thermistor is hermetically sealed in a chamber filled with dry Nitrogen while the other is
exposed to open environment through small venting holes. When the circuit is powered on, the
resistance of the two thermistors are calculated and the difference between those two values is
directly proportional to Absolute Humidity (AH).
Very durable
Exposure to any gas with thermal properties different than Nitrogen might affect reading
measurement.
Drying kilns
Pharmaceutical plants
Owens
Food dehydration
The following are some of the factor that must be taken into consideration when selecting a Humidity
Sensor.
Output repeatability
Circuit complexity
Resistance to contamination
The water level sensor is a device that measures the liquid level in a fixed container that is too high or
too low. According to the method of measuring the liquid level, it can be divided into two types:
contact type and non-contact type. The input type water level transmitter we call is a contact
measurement, which converts the height of the liquid level into an electrical signal for output. It is
currently a widely used water level transmitter.
The working principle of the water level sensor is that when it is put into a certain depth in the liquid
to be measured, the pressure on the sensor’s front surface is converted into the liquid level height.
The calculation formula is Ρ=ρ.g.H+Po, in the formula P is the pressure on the liquid surface of the
sensor, ρ is the density of the liquid to be measured, g is the local acceleration of gravity, Po is the
atmospheric pressure on the liquid surface, and H is the depth at which the sensor drops into the
liquid.
The level sensor is a device designed to monitor and measure liquid (and sometimes solid) levels.
When the liquid level is detected, the sensor converts the sensed data into an electrical signal. Level
sensors are mainly used for monitoring reservoirs, oil tanks or rivers
1. Simple structure: There are no movable or elastic elements, so the reliability is extremely high,
and there is no need for regular maintenance during use. The operation is simple and convenient.
2. Convenient installation: When using, first connect one end of the wire correctly, and then put the
other end of the water level probe into the solution to be measured.
3. Ranges are optional: you can measure the water level in the range of 1-200 meters, and other
measurement ranges can also be customized.
4. Wide range of applications: suitable for liquid level measurement of high temperature and high
pressure, strong corrosion, high pollution, and other media. Building an electronic water level
gauge on the river bank can be used for tide monitoring.
5. Wide range of measuring medium: High-precision measurement can be carried out from the
water, oil to paste with high viscosity, and wide-range temperature compensation is not affected by
The optical sensor is solid-state. They use infrared LEDs and phototransistors, and when the sensor is
in the air, they are optically coupled. When the sensor head is immersed in the liquid, the infrared
light will escape, causing the output to change. These sensors can detect the presence or absence of
almost any liquid. They are not sensitive to ambient light, are not affected by foam when in air, and
are not affected by small bubbles when in liquid. This makes them useful in situations where state
changes must be recorded quickly and reliably, and in situations where they can operate reliably for
long periods without maintenance.
Capacitance level switches use 2 conductive electrodes (usually made of metal) in the circuit, and the
distance between them is very short. When the electrode is immersed in the liquid, it completes the
circuit.
Advantages: can be used to determine the rise or fall of the liquid in the container. By making the
electrode and the container the same height, the capacitance between the electrodes can be measured.
No capacitance means no liquid. A full capacitance represents a complete container. The measured
values of “empty” and “full” must be recorded, and then 0% and 100% calibrated meters are used to
display the liquid level.
Disadvantages: The corrosion of the electrode will change the capacitance of the electrode, and it
needs to be cleaned or recalibrated.
The tuning fork level gauge is a liquid point level switch tool designed by the tuning fork principle.
The working principle of the switch is to cause its vibration through the resonance of the piezoelectric
crystal.
Every object has its resonant frequency. The resonant frequency of the object is related to the size,
mass, shape, force… of the object. A typical example of the resonant frequency of the object is: the
same glass cup in a row Filling with water of different heights, you can perform instrumental music
performance by tapping.
Advantages: It can be truly unaffected by flow, bubbles, liquid types, etc., and no calibration is
required.
Disadvantages: Cannot be used in viscous media.
The diaphragm or pneumatic level switch relies on air pressure to push the diaphragm, which engages
with a micro switch inside the main body of the device. As the liquid level increases, the internal
pressure in the detection tube will increase until the microswitch is activated. As the liquid level
drops, the air pressure also drops, and the switch opens.
Advantages: There is no need for power in the tank, it can be used with many types of liquids, and
the switch will not come into contact with liquids.
Disadvantages: Since it is a mechanical device, it will need maintenance over time.
The float switch is the original level sensor. They are mechanical equipment. The hollow float is
connected to the arm. As the float rises and falls in the liquid, the arm will be pushed up and down.
The arm can be connected to a magnetic or mechanical switch to determine on/off, or it can be
connected to a level gauge that changes from full to empty when the liquid level drops.
The use of float switches for pumps is an economical and effective method to measure the water level
in the pumping pit of the basement.
Advantages: The float switch can measure any type of liquid and can be designed to operate without
any power supply.
Disadvantages: They are larger than other types of switches, and because they are mechanical, they
must be used more frequently than other level switches.
The ultrasonic level gauge is a digital level gauge controlled by a microprocessor. In the
measurement, the ultrasonic pulse is emitted by the sensor (transducer). The sound wave is reflected
by the liquid surface and received by the same sensor. It is converted into an electrical signal by a
piezoelectric crystal. The time between the transmission and reception of the sound wave is used to
calculate the Measure of the distance to the surface of the liquid.
The working principle of the ultrasonic water level sensor is that the ultrasonic transducer (probe)
sends out a high-frequency pulse sound wave when it encounters the surface of the measured level
(material), is reflected, and the reflected echo is received by the transducer and converted into an
electrical signal. The propagation time of the sound wave. It is proportional to the distance from the
sound wave to the surface of the object. The relationship between the sound wave transmission
distance S and the sound speed C and the sound transmission time T can be expressed by the formula:
S=C×T/2.
Advantages: non-contact measurement, the measured medium is almost unlimited, and it can be
widely used for measuring the height of various liquids and solid materials.
Disadvantages: The measurement accuracy is greatly affected by the temperature and dust of the
current environment.
A radar liquid level is a liquid level measuring instrument based on the principle of time travel. The
radar wave runs at the speed of light, and the running time can be converted into a level signal by
electronic components. The probe sends out high-frequency pulses that travel at the speed of light in
space, and when the pulses meet the surface of the material, they are reflected and received by the
receiver in the meter, and the distance signal is converted into a level signal.
Hardware Overview
The sensor has ten exposed copper traces, five of which are power traces and the remaining five are
sense traces. These traces are interlaced so that there is one sense trace between every two power
traces.Normally, power and sense traces are not connected, but when immersed in water, they are
bridged.
There is a Power LED on the board, which will light up when the board is powered.
Working Principle:
The power and sense traces form a variable resistor (much like a potentiometer) whose resistance
varies based on how much they are exposed to water.
This resistance varies inversely with the depth of immersion of the sensor in water:
The more water the sensor is immersed in, the better the conductivity and the lower the resistance.
The less water the sensor is immersed in, the poorer the conductivity and the higher the resistance.
The sensor generates an output voltage proportional to the resistance; by measuring this voltage, the
water level can be determined.
Taken from-lastminuteengineer.com
S (Signal) is an analog output pin that will be connected to one of your Arduino’s analog inputs.
+ (VCC) pin provides power to the sensor. It is recommended that the sensor be powered from 3.3V
to 5V. Please keep in mind that the analog output will vary depending on the voltage supplied to the
sensor.
#define ledPin 6
#define sensorPin A0
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
void loop() {
Serial.println(outputValue);
For our next example, we’ll build a simple water level indicator that will light up LEDs based on the
level of the water.
Wiring
We’ll reuse the previous example’s circuit. We only need to add some LEDs this time.
Connect three LEDs to digital pins #2, #3, and #4 using 220 ohm resistors.
Taken from-lastminuteengineer.com
// Sensor pins
#define sensorPower 7
#define sensorPin A0
int val = 0;
int redLED = 2;
int yellowLED = 3;
int greenLED = 4;
void setup() {
Serial.begin(9600);
pinMode(sensorPower, OUTPUT);
digitalWrite(sensorPower, LOW);
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(greenLED, OUTPUT);
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
void loop() {
if (level == 0) {
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
digitalWrite(redLED, HIGH);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, HIGH);
digitalWrite(greenLED, LOW);
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, HIGH);
delay(1000);
int readSensor() {
digitalWrite(sensorPower, HIGH);
delay(10);
val = analogRead(sensorPin);
digitalWrite(sensorPower, LOW);
return val;
The MQ2 sensor is one of the most widely used in the MQ sensor series. It is a MOS (Metal Oxide
Semiconductor) sensor. Metal oxide sensors are also known as Chemiresistors because sensing is
based on the change in resistance of the sensing material when exposed to gasses.
The MQ2 gas sensor operates on 5V DC and consumes approximately 800mW. It can
detect LPG, Smoke, Alcohol, Propane, Hydrogen, Methane and Carbon Monoxide concentrations
ranging from 200 to 10000 ppm.
Working Principle
The MQ-2 sensor works on the principle of resistance changes in the presence of different gases.
When the target gas comes in contact with the heated MOS(Metal Oxide Semiconductor) material, it
undergoes oxidation or reduction reactions that change the resistance of the MOS material. It is
noteworthy that the MQ2 gas sensor is capable of detecting multiple gases, but lacks the ability to
differentiate between them. This is a common characteristic of most gas sensors.
The sensor has a built-in potentiometer that allows you to adjust the sensor digital output (D0)
threshold. When the concentration of gas in the air exceeds a certain threshold value, the resistance of
the sensor changes. This change in resistance is then converted into an electrical signal that can be
read by an Arduino board.
void setup() {
void loop() {
Serial.println(analogRead(sensorPin)); // Read the analog value of the gas sensor and print it to the
//serial monitor
A passive infrared sensor is an electronic sensor that measures infrared light radiating
from objects. PIR sensors mostly used in PIR-based motion detectors. Also, it used in security alarms
and automatic lighting applications. The below image shows a typical pin configuration of the PIR
sensor, which is quite simple to understand the pinouts. The PIR sensor consist of 3 pins,
Pin1 corresponds to the drain terminal of the device, which connected to the positive supply
5V DC.
Pin2 corresponds to the source terminal of the device, which connects to the ground terminal
via a 100K or 47K resistor. The Pin2 is the output pin of the sensor. The pin 2 of the sensor
carries the detected IR signal to an amplifier from the
Pin3 of the sensor connected to the ground.
Generally, PIR sensor can detect animal/human movement in a requirement range. PIR is made of a
pyroelectric sensor, which is able to detect different levels of infrared radiation. The detector itself
does not emit any energy but passively receives it.
It detects infrared radiation from the environment. Once there is infrared radiation from the human
body particle with temperature, focusing on the optical system causes the pyroelectric device to
generate a sudden electrical signal.
Simply, when a human body or any animal passes by, then it intercepts the first slot of the PIR
sensor. This causes a positive differential change between the two bisects. When a human body
leaves the sensing area,the sensor generates a negative differential change between the two bisects.
The passive infrared sensor does not radiate energy to space. It receives the infrared radiation from
the human body to make an alarm. Any object with temperature is constantly radiating infrared rays
to the outside world. The surface temperature of the human body is between 36° C - 27 ° C and most
of its radiant energy concentrated in the wavelength range of 8 um-12 um.
Passive infrared alarms classified into infrared detectors (infrared probes) and alarm control
sections. The most widely used infrared detector is a pyroelectric detector. It uses as a sensor for
converting human infrared radiation into electricity. If the human infrared radiation is directly
irradiated on the detector, it will, of course, cause a temperature change to output a signal. But in
doing all this, the detection distance will not be more. In order to lengthen the detection distance of
the detector, an optical system must be added to collect the infrared radiation. Usually, plastic optical
reflection system or plastic Fresnel lens used as a focusing system for infrared radiation.
In the detection area, the lens of the detector receives the infrared radiation energy of the human body
through the clothing and focused on the pyroelectric sensor. When the human body moves in this
surveillance mode, it enters a certain field of view in sequence and then walks out of the field of
view. The pyroelectric sensor sees the moving human body for a while and then does not see it, so the
infrared radiation of human body constantly changes the temperature of the pyroelectric material. So
that it outputs a corresponding signal, which is the alarm signal.
}
else
{
Serial.print("Object detected\n\n");
warm_up = 1;
delay(1000);
}
}
With Interupt
const int PIR_SENSOR_OUTPUT_PIN = 2; /* PIR sensor O/P pin */
void setup() {
pinMode(PIR_SENSOR_OUTPUT_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2), pir, FALLING); /* Interrupt on rising edge on pin 2 */
Serial.begin(9600); /* Define baud rate for serial communication */
delay(20000); /* Power On Warm Up Delay */
}
void loop() {
}
void pir(){
Serial.println("Object Detected");
}
Ultrasonic Sensor
Ultrasonic sensors work by emitting sound waves at a frequency which is too high for humans to hear.
An above image shows the HC-SR-04 ultrasonic sensor which has a transmitter, receiver. The pin
configuration is,
VCC - +5 V supply
TRIG – Trigger input of the sensor. Microcontroller applies 10 us trigger pulse to the HC-SR04
ultrasonic module.
ECHO–Echo output of the sensor. Microcontroller reads/monitors this pin to detect the obstacle
or to find the distance.
GND – Ground
Sound is a mechanical wave travelling through the mediums, which may be a solid, or liquid or gas.
Sound waves can travel through the mediums with specific velocity depends on the medium of
propagation. The sound waves which are having high frequency reflect from boundaries and produce
distinctive echo patterns.
Ultrasonic sensors emit short, high-frequency sound pulses at regular intervals. These propagate in the
air at the velocity of sound. If they strike an object, then they reflected back as an echo signal to the
sensor, which itself computes the distance to the target based on the time-span between emitting the
signal and receiving the echo.
Ultrasonic sensors are excellent at suppressing background interference. Virtually all materials which
reflect sound can be detected, regardless of their colour. Even transparent materials or thin foils
represent no problem for an ultrasonic sensor.
microsonic ultrasonic sensors are suitable for target distances from 20 mm to 10 m and as they measure
the time of flight they can ascertain a measurement with pinpoint accuracy. Some of our sensors can
even resolve the signal to an accuracy of 0.025 mm. Ultrasonic sensors can see through dust-laden air
and ink mists. Even thin deposits on the sensor membrane do not impair its function.
digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time //in microseconds
duration = pulseIn(echoPin, HIGH); // Calculating the distance
distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)