4.3 Ultrasonic and gas sensor

What is Ultrasonic sensor?

An ultrasonic sensor is an electronic device that measures the distance of a target object by emitting ultrasonic sound waves, and converts the reflected sound into an electrical signal.

HC-SR04 Ultrasonic Sensor Pin Configuration

Pin Number

Pin Name

Description

1

Vcc

This Vcc pin powers the sensor, with +5V

2

Trigger

This pin is an Input pin. Trigger pin must be kept high for 10us to initialize measurement by sending US wave.

3

Echo

This pin is an Output pin. Echo pin goes high for a period of time which will be equal to the time taken for the Ultrasonic wave to return back to the sensor.

4

Ground

Ground pin is connected to the Ground with -V.

Working of Ultrasonic sensor

Ultrasonic sensors work by sending out a sound wave at a frequency above the range of human hearing.  The transducer of the sensor acts as a microphone to receive and send the ultrasonic sound. Our ultrasonic sensors, like many others, use a single transducer to send a pulse and to receive the echo.  The sensor determines the distance to a target by measuring time lapses between the sending and receiving of the ultrasonic pulse.

Distance = Speed × Time

The working principle of this module is simple.  It sends an ultrasonic pulse out at 40 kHz which travels through the air and if there is an obstacle or object, it will bounce back to the sensor.  By calculating the travel time and the speed of sound, the distance can be calculated.

What is Gas sensor?

A gas sensor is a device that detects the presence or concentration of gases in the atmosphere. Based on the gas concentration, the sensor produces a corresponding potential difference by changing the resistance of the material inside the sensor, which can be measured as output voltage. Based on this voltage value the type and concentration of the gas can be estimated. Many types of MQ Sensors are available to detect different gasses, but the basic gas sensor to detect Smoke, LPG gas, Methane, Butane is MQ-2 Sensor.

MQ-2 Sensor

  • The MQ-2 Gas sensor can detect or measure gasses like LPG, Alcohol, Propane, Hydrogen, CO, and even methane. The module version of this sensor comes with a Digital Pin which makes this sensor operate even without a microcontroller and that comes in handy when you are only trying to detect one particular gas. 

  • MQ-2 Sensor is sensitive to sense Smoke & some Flammable gasses like Methane, Butane, and LPG gas.

Gas Sensor Pin Configuration

Pin No

Pin Name

Description

1

Vcc

This pin powers the module, typically the operating voltage is +5V

2

Ground

Used to connect the module to system ground

3

Digital Out

You can also use this sensor to get digital output from this pin, by setting a threshold value using the potentiometer

4

Analog Out

This pin outputs 0-5V analog voltage based on the intensity of the gas

Working of Gas sensor

The MQ-2 sensor Module Detect the percentage of the Smoke or concentration of the Gases around the Sensor. In clean air the oxygen is absorbed on the surface of the sensing material so the Output voltage is Low, In the case of Fire or Leakage of LPG gas, the smoke of the Fire or the concentration of LPG gas touch athe Sensing material then the sensing plate start heating it reduce the resistivity and flow maximum amount of voltage at its output pin.