Understanding Optical Sensors
Understanding Optical Sensors
An optical sensor converts light rays into an electronic signal. The purpose of
an optical sensor is to measure a physical quantity of light and, depending on
the type of sensor, then translates it into a form that is readable by an
integrated measuring device. Optical Sensors are used for contact-less
detection, counting or positioning of parts. Optical sensors can be either
internal or external. External sensors gather and transmit a required quantity
of light, while internal sensors are most often used to measure the bends and
other small changes in direction.
The measurands possible by different optical sensors are Temperature,
Velocity Liquid level, Pressure, Displacement (position), Vibrations, Chemical
species, Force radiation, pH- value, Strain, Acoustic field and Electric field
Types of Optical Sensors
There are different kinds of optical sensors, the most common types which we
have been using in our real world applications as given below.
Retro-Reflective Sensors
Transmitter and receiver are both in the same house, through a reflector the
emitted light beam is directed back to the receiver. An interruption of the light
beam initiates a switching operation. Where the interruption occurs is of no
importance.
Advantage: Retro-reflective sensors enable large operating distances with
switching points, which are exactly reproducible requiring little mounting effort.
All objects interrupting the light beam are accurately detected independently
of their surface structure or color
Diffuse Reflection Sensors
Both transmitter and receiver are in one housing. The transmitted light is
reflected by the object to be detected.
Advantage: The diffused light intensity at the receiver serves as the switching
condition. Regardless of the sensitivity setting the rear part always reflects
better than the front part. This leads to the consequence to erroneous
switching operations.
OPTICAL PYROMETER
Definition: A temperature measuring device that is used to measure the
temperature of molten metal’s, overheated material, furnaces otherwise
liquids. It is one kind of measuring device of temperature with a non-contact.
The working principle of this optical pyrometer is to match the object’s
brightness of the filament within the device. By using contact type instruments,
measuring the temperature of the highly heated body is not possible. So this
non-contact type device is used to measure the temperature.
The current within the lamp is regulated until the lamp’s brightness is
equivalent to the image brightness generated through the source of
temperature. When the light intensity of any wavelength depends on the
temperature of the radiating object, then the flow of current through the lamp
becomes a measure of the temperature source when adjusted.
Optical Pyrometer Working
The optical pyrometer diagram is shown below. It includes the lens to focus on
the generated energy from the heated object and aims at the filament of the
lamp. The filament in the lamp mainly depends on the flow of current through
it. Therefore the changeable current can be supplied throughout the lamp.
The magnitude of the flow of current can be changed until the filament’s
intensity is similar to the intensity of the object. As the intensity of both the
filament and object are the same, then the filament outline can vanish
completely.
The filament in the bulb seems intense as its temperature is higher compare
with the temperature of the source. Similarly, the filament seems dim if their
temperature is lower than that necessary for equivalent brightness
Magnetic sensors are the solid state devices used in detecting and sensing the distance, speed,
rotation, angle, and position by converting magnetic information into electrical signals. The
converted signals are processed by electrical circuits. These sensors became popular and used in
several applications because of their easy operation, and tolerance to high vibrations, water, and
dust.
Magnetic Sensor
These are used to detect the strength of the magnetic field and geo-magnetism generated due to
the current or magnet. The output of the magnetic sensors is used to monitor the direction,
location, revolution, angle, distance, speed, position, and the presence of electric current. The
magnetic sensors can detect the linear and rotatory motion of small iron objects without any
external power supply with high resolution. They can measure up to 6,00,000 rpm speed.
These are high-frequency sensors and the frequency usage can be limited by the impedance and
the external load. Magnetic field type sensors use an internal magnet or permanent magnet to
detect electromagnetic fields directly. The built-in magnetic sensor detects iron and generates an
analog or digital output signal. Reed switches, Hall switches, and other external magnetic sensors
detect the magnetic field of a magnet or electric coil. Also available in analog and digital
versions.
The magnetic sensor working principle is based on the type of sensor element used. Any type of
magnetic sensor works with the magnetic field of the Earth. A simple magnetic sensor can detect
the moving ferrous. When an iron object is moved close to the coil Or wire wound on a
permanent magnet, then the magnetic flux through the coil changes and generates the voltage at
the terminals of the coil.
Working Principle Magnetic Sensor
Consider the coiled magnetic sensor, where the coil is used as a simple sensor element to
understand the working of a magnetic sensor. However, the coil is used to provide limited
functionality. So, it is combined with other magnetic materials coils, to construct a highly
sensitive magnetic sensor. The coils used in magnetic sensors in a wide range of applications
include fluxgate sensors, search coils, resolvers, rotation, and angle sensors.
The coil itself can’t be used to measure magnetic fields directly, but it can detect changes or
vibrations in the magnetic field. When the magnet is brought closer to the coil, the coil’s
magnetic flux density will increase. This results in creating the opposite forces in the form of an
induced current and electromotive force (EMF). When the movement of the coil stops, the
change in the magnetic flux density also stops, and the induced EMF and current stop.
Observe the induced EMF and the induced current, to determine the ratio of the change in
density and direction of the magnetic flux.
Types of Magnetic Sensors
The magnetic sensors are divided into various types based on the technology or elements used
such as fluxgates, coils, hall elements, light pumping, magnetoresistive, nuclear precession,
SQUID, magnetic tunnel junctions, giant magnetic impedance, piezoelectric component, optical
fibers, small electro-mechanical elements, etc. The different types of magnetic sensors are given
below.
These sensors are used to measure electrical resistance as a function of the applied magnetic
field. It works on the principle of AMR (Anisotropic magneto-resistance) or MR (Magneto-
resistance) or GMR (giant magneto-resistive) or TMR (tunnel magneto-resistive) effect
developed by William Thomson in 1856, Albert Feet & Peter Grunberg in 1988 and Terunobu
Miyazaki professor in 1995.
These are used to convert the stored energy in a field of the magnet into an electrical signal with
the application of a voltage between the ends of a current-carrying wire whose sides are 90
degrees to the magnetic field. It works on the principle of the Hall effect developed by Edwin H
in 1879.
These sensors are used to measure the magnetic field difference at the vertical rod ends and then
display this data on a grid.
This sensor contains a coil surrounding a ferromagnetic core, the permeability of which varies
with the earth’s magnetic field of the Earth.
These sensors are also called nuclear precession type sensors that combine a liquid electron-rich
with hydrogen and expose the mixture to an RF signal.
These sensors utilize liquids such as methanol, and kerosene with hydrogen atoms having high
density.
SQUID Magnetic Sensors
In SQUID Magnetic Sensors, the term “SQUID” stands for Superconducting Quantum
Interference Devices which are used to measure magnetic fields in a very low femto Tesla range.
These are sensitive type sensors and are used in medical, and neuroscientific, applications with
several magnetic field devices.
An optically pumped magnetic sensor polarizes an alkaline gas with light with a particular
wavelength.
From the above information about magnetic sensors, now let’s know how to interface a magnetic
sensor with a microcontroller (ATMEGA328P) using Arduino UNO. Here the Hall effect
magnetic sensor in the form of A1104 IC is taken.
The hall effect magnetic sensor is the most widely used magnetic sensor in various applications
such as door open and close detection, docking detection, proximity sensing, pulse counting,
valve positioning, automotive systems, etc. The pin diagram of the hall effect magnetic sensor
module is shown below.
Pin 2: GND (-): This pin refers to the common ground connection.
Pin 3: AO: (Analog Out): This pin refers to the analog output, which is connected to the analog
pin of the microcontroller directly.
Pin 4: DO: (Digital Out): This pin refers to the digital output, which is connected to the digital
pin of the microcontroller directly.
Now let’s know briefly about A1004 Hall effect magnetic sensor IC.
Hall sensor ICs are magnetically activated non-contact trigger switches used in various
applications such as computers, security systems, automobiles, control systems, and many more.
The Hall effect IC A1104 is from Allegro MicroSystems, available in 3-pin SOT23 and SIP
packages. It is based on BiCMOS technology, which combines the advantages of the
technologies of bipolar and CMOS.
The main components of the A1104 Hall Effect magnetic sensor IC are a voltage regulator, a
Hall effect sensor, a low power signal amplifier, a Schmitt trigger, and an output NMOS
transistor. It is used to detect the moment, change, and position in the strength of the magnetic
field of either an electromagnetic or permanent magnet or ferromagnetic materials.
The Hall effect chip A1104 has 3 pins: VCC, GND, and OUT.
VCC: Provides a positive power supply to the chip from 3.8V to 24V.
GND: Ground connection
OUT: IC output pin.
The circuit diagram of interfacing the Hall effect magnetic sensor with the microcontroller using
Arduino UNO is shown below. The components required are,
Connections are made as per the above circuit diagram. The VCC and GND pins of A1104 are
connected to +5V and GND pins of Arduino UNO. The OUT pin or Hall pin of A1104 is pulled
to HIGH with a resistor of 10 Kilo Ohms and connected to digital pin 2 of Arduino. To represent
the output LED is connected to digital pin 10 of Arduino through a resistor of 1kiloOhms.
When a magnetic field is applied near to the Hall Effect A1104 IC, the output pin (OUT) of the
Hall effect magnetic sensor IC goes LOW. This change is recognized by the Arduino and
activates the corresponding LED.
Upload the Arduino code and observe the results on the monitor.
Arduino Code:
void setup()
pinMode(ledPin,OUTPUT);
pinMode(hallPin,INPUT);
attachInterrupt(digitalPinToInterrupt(hallPin), hall_ISR, CHANGE
FLOW SENSOR
A flow sensor definition is a sensor that is used to measure a fluid like liquid or gas.
These sensors mainly use both electrical and mechanical subsystems to gauge changes within the
physical attributes of fluid & measure its flow. So measuring these mainly depends on the
physical attributes of fluid. A flow sensor is an electronic device that measures the changes in
liquids flow rate & gasses in tubes & pipes.
The flow sensor working principle is based on Bernoulli’s principle. This principle states that
the drop of pressure across the meter is simply proportional to the square of the rate of flow. The
most common way to determine the measurement of a flow is by using the pressure drop across
the cross-section of the pipe.
Flow sensors are categorized into three types like the following.
These types of flow sensors are very unique as compared to other types because they measure the
fluid’s volume directly when passing through the device. Other types of flow sensors do not
measure the rate of flow directly instead of measuring pressure, it is used to derive the flow rate.
These flow sensors can work over a broad range of fluid viscosities; they have less maintenance
& provide an electronic & mechanical interface. These sensors are used in the measurement of
gasoline, oils, hydraulic liquid, and water and gas meters installed at home.
A mass flow sensor measures the flow rate of fluid or the amount of fluid or gas flowing
throughout a pipe by simply determining the mass for each unit of time. These sensors are
extensively used in automobiles, wherever they are utilized to measure the air inflowing the air
intake system of an inside combustion engine. They work by simply measuring the energy
transfer from a heated surface to a flowing liquid. These sensors are also available in two types
thermal & Coriolis flowmeter.
The advantages of this sensor are; liquid flow can be measured directly with high accuracy,
applicable for an extensive range of fluids like highly viscous fluids, and flow measurement can
be done bidirectionally.
Velocity flow sensors are used for detecting the liquid flow speed by simply determining the
fluid’s velocity flowing throughout the sensor. These kinds of sensors are available in different
types like mechanical, electromagnetic & ultrasonic which are discussed below.
Velocity Flow Sensor
Mechanical Velocity Flow Sensor
In a mechanical velocity flow sensor, a rotary mechanical device like a paddle wheel is arranged
on a bearing that extends from the flow sensor & directly sits within the flow path. When the
fluid moves, the paddle wheel rotates & its rotation is simply detected by a sensor like an
infrared sensor, magnetic coil, or Hall effect. The flow sensor electronics converts the
revolutions into an o/p signal like a rectangular wave signal that can be simply programmed to
signify a specified volume output for each unit time.
The advantages of these flow sensors are compact, expensive with a simple working principle &
also use very small energy to function. These sensors work with a broad range of fluids. The
main drawbacks are; this sensor uses moving parts that may build up contagion from liquids that
are not hygienic so that its operation can be obstructed & needs maintenance.
Sometimes, these flow sensors are also known as magnetic flow/ EMF flow sensors which
operate on Faraday’s law of induction principle. These sensors mainly include a coil that induces
a magnetic field within the liquid being measured and after that, it uses a set of electrodes to
determine the induced voltage that results from the conductive liquid flow throughout the
magnetic field.
Electromagnetic Type
The induced voltage is proportional to the fluid’s velocity within the pipe. The measurement of
velocity is changed into a volumetric flow rate if we know the velocity & dimensions of the
cross-section of the pipe.
These sensors mainly need that the liquid being measured to have the least conductivity and have
the benefit of not inducing a pressure drop within the pipe. Whenever they are appropriate for
fluids that contain some amount of contamination, then they do not work with non-conductive
fluids such as steam, gas, or oil. These types of flow sensors are not suitable to use within
vacuum conditions, the fluids which have abrasive characteristics & fluids that may contain
ferromagnetic particles.
These sensors use two different approaches to work. In the primary approach, an
ultrasonic transducer pair produces a signal that is simply directed into the fluid flow from two
locations. Every signal produced by a transmitter can be simply reflected back to the other
transducer’s receiver with a set of mirrors. The direction of the transducers & mirrors is; one
signal is transmitted through its path by the flow of fluid whereas the other is transmitted against
the flow of fluid.
Ultrasonic Type
The receiver electronics simply measure each signal’s transit time & measures the time variation
between the two. Once the fluid is not in movement, then transit times are similar for every
signal. When the fluid is in motion, then the signal moves with the fluid flow which will have
less transit time, so the variation between the two transit times of the signal reflects the fluid’s
velocity. Sometimes, these kinds of sensors are called transit time ultrasonic flow sensors.
In a second approach, ultrasonic force is simply transmitted into the liquid & is reproduced back
to a receiver. In the zero-flow state, the ultrasonic wave frequency is not changed. Once the fluid
is in motion, then there is a change in frequency that simply occurs as an outcome of the Doppler
Effect. This effect is linear with respect to the velocity of the fluid. So, detecting & reporting the
shift within ultrasonic frequency simply allows for the calculation of the flow rate of the fluid.
These sensors are applicable for both conductive & non-conductive liquids and they can handle
high pressures & temperatures.
The differences between the flow sensor and the pressure sensor include the following.
The flow sensor is used to detect the flow rate of The pressure sensor is used to detect the pressure
These sensors are available in three types These sensors are available in seven types strain
Positive displacement, mass flow & velocity gauge, piezoelectric, capacitive, manometer,
These are normally used in medical devices, automotive, consumer, building devices, and
chemical factories, HVAC systems, etc. industries that depend on stable & precise
The flow sensor interfacing with the microcontroller is discussed below. Here, the flow sensor
used is YF-S201 with any type of microcontrollers like Arduino, Pic microcontroller, STM32
Blue Pill, ESP32, 8051 microcontrollers, ESP8266, or Raspberry Pi for measuring water flow
rate.
Monitoring water flow is very significant in different applications such as a watering system for
plants within your home garden and food processing & complex pharmaceutical industries. So
water flow sensors help in measuring the liquid flow rate where the flow rate is the volume of
water supplies throughout a sensor for each unit of time.
There are different types of water flow sensors available and these sensors are nearly similar
except for the variation in the range of flow rate, length, operating range of voltage, material, and
size but their interfacing and working principle process will be the same.
YF-S201 water flow sensor is mainly designed for measuring the water flow rate & amount of
the required fluid throughout the pipes. This sensor is available at a low cost and includes a
copper body as well as a water rotor. Additionally, it also includes an internal Hall effect sensor
circuit that functions on the electromagnetism principle & provides signals at the o/p pin. This
sensor is compatible with MCU with 30 liters for each minute maximum flow rate.
The Pin configuration of the YF-S201 flow sensor is shown below. This sensor includes three
pins and each pin and its functionality is discussed below.
YF-S201 Flow Sensor Pinout
The features and specifications of the YF-S201 flow sensor include the following.
Generally, a water flow sensor includes a turbine wheel or water rotor and a hall effect sensor.
The water enters through one of the ends & leaves from another end of the sensor. Once water is
supplied through this sensor, then it hits the wheel of the turbine & rotates the turbine wheel. The
turbine’s speed has a direct relation to the rate of the water flow throughout the water flow
sensor. On every complete revolution of the wheel of the turbine, a hall-effect sensor generates a
pulse that emerges on the signal o/p pin. So, the number of appeared pulses on the signal o/p pin
is directly proportional to the turbine’s rotating speed.
YF-S201 is made with a plastic body that includes a rotor, valve & a Hall effect sensor. These
sensors work on the principle of the Hall effect & generate the flow rate & volume in the pulses
form on the signal pin.
The below section shows how to interface the YF-S201 Water Flow Sensor with an Arduino
Uno . It can be interface with the other microcontroller as well the same way but pins only need
to be changed.
Interfacing of the YF-S201 Water Flow Sensor with an Arduino Uno microcontroller
Connection Diagram
In this example, we will use digital I/O pin-2 of Arduino as an external interrupt capture pin to
count the number of pulses.
Connect the YF-S201 water sensor’s power supply pins to the GND & Arduino’s 5V pins.
The yellow color wire (o/p voltage wire) to the Arduino’s ‘D2’ digital pin to detect the electric
pulses.
This Arduino interfacing with the water flow sensor simply measures the flow rate of water in
units of a liter for each hour & displays the measured value on the Arduino IDE serial monitor.
Current_Time = millis();
Loop_Time = Current_Time;
}
void loop ()
{
Current_Time = millis();
if(Current_Time >= (Loop_Time + 1000))
{
Loop_Time = Current_Time;
Liter_per_hour = (Pulse_Count * 60 / 7.5);
Pulse_Count = 0;
[Link](Liter_per_hour, DEC);
[Link](” Liter/hour”);
}
}
void Detect_Rising_Edge ()
{
Pulse_Count++;
}
To test the above interfacing, copy the above Arduino code to Arduino IDE & upload it to your
Arduino board. Later, open the serial monitor & set the baud rate to 9600. So, we can notice the
measured values over the serial monitor:
The o/p of this project is to show the amount of water supplied throughout the sensor within
liters for each hour. To get this, there is a calculation. Since the sensor’s output is a pulse, so by
calculating the pulse frequency, we can simply measure the amount of water supplied throughout
the sensor. The frequency of pulse within Hz is 7.5 * Water Flow Rate in Litres for each minute.
Thus, the water quantity in Litres for each Hour is Pulse Frequency x 60 / 7.5.
Advantages
Disadvantages
Applications
The flow sensor is used to measure the amount of liquid flowing throughout it. So this can be
utilized in many industrial & commercial applications.
This sensor is mainly used for indicating the amount of fluid or gas moving throughout a pipe or
medium by measuring mass, linear, volumetric, and non-linear flow rates.
Generally, these types of sensors are commonly used in medical devices, HVAC systems, septic
systems & chemical factories. These sensors are capable of detecting blockages, leaks, pipe
bursts & changes within a concentration of liquid because of pollution or contamination.
These sensors are used in automobiles to gauge the air intake to the engine & regulate the
delivery to fuel injectors in order to attain the mixture of desired fuel to the engine.
These sensors are used in medical ventilators to establish the correct rate of delivery of air
otherwise oxygen to patients for support through respiration.
Displacement sensors, also known as position sensors, are a very common type of sensor. They
are used throughout many industries and can be found all around us.
Displacement sensors are available in different types, different shapes and different sizes to suit
different applications.
Automotive and Motorsport – in this industry, displacement sensors can be used for steering
systems on agricultural machinery, electric cart throttle control, the suspension on bikes and
many other applications.
Factory Automation – displacement sensors can be used for conveyor speed measurement,
labelling machines and control, printing processes and packaging.
Medical Applications – displacement sensors are used on medical pieces of machinery such as
MRI or oncology machines.
Security Applications - displacement sensors can be used in security applications, for example,
monitoring the angle of a CCTV camera.
Barriers and bridges – displacement sensors are used to position various types of barriers; these
could be for pedestrians or vehicles. Moving bridges and ramps also use displacement sensors to
control the positions they are fixated in.
Other applications – displacement sensors can also be used for; elevator position, special
effects in film and TV, for use on Segways and other transportation devices, various renewable
energy applications, baking machines, paper mills and many others.
Linear displacement sensors measure movements which occur along a single axis, this can be left
to right or up and down. They use a range of technologies and have different outputs depending
on the application requirements.
Rotary displacement sensors are used for measuring turning movements. They transform rotary
movements into output signals. Rotary displacement sensors can be used for either clockwise or
anti-clockwise movements and can be single turn for motion ranges under 360° or multiturn for
larger movements than this.
Contacting displacement sensors use a technology where the sensor encounters the given object
and the components inside also come into physical contact with each other to measure
displacement.
Potentiometer – also known as “pots” are a contacting technology using a slider and a resistive
track to monitor displacement. Potentiometers can be either linear and rotary and we have a
range of each on our website.
Cable extension transducers – cable extension transducers are a type of linear potentiometer,
but they use a flexible cable and a spool to measure long range linear position.
Non-contacting displacement sensors have no touching parts. This eliminates the friction as well
as the wear and tear giving the sensor longer – and sometimes infinite life.
Hall effect – Hall effect tends to be used for rotary sensors but can also be used in linear sensors,
we have our own range of Hall effect rotary sensors which are available as standard or micro
size.
Inductive sensors – this technology uses alternating currents and is used to measure linear
displacement.
Encoders – shafted or hollow shaft encoders are used for monitoring and controlling rotary
position, they can be absolute or incremental.
Positek PIPS – this technology comes from Positek, one of our sister companies; it is a non-
contacting technology for either linear or rotary displacement.
LVDT and RVDT – Linear or Rotary variable differential transformers which use an iron core
and copper coils to measure displacement.