MQ-135 Gas Sensor with Arduino Code and Circuit Diagram

The connections of the MQ-135 gas sensor with Arduino:

In the world of technology, many sensors are being used to monitor and control home applications, robotics, industrial automation, etc. There are different sensors for different purposes. Like humans have different sensing capabilities for different purposes. In this article, we focus on the MQ-135 gas sensor to monitor the environment. MQ-135 gas sensor is mainly used to measure NH3, NOx, Alcohol, Benzene, Smoke, CO2. 

There are some other members of gas sensors in the MQ family. MQ-135 gas sensor is popular for Air Quality monitoring. 

MQ-135 gas sensor
MQ-135 gas sensor

In this tutorial, we will learn more about the MQ-135 gas sensor and how to interface the MQ-135 Gas Sensor with Arduino Board. 

In this tutorial, we will cover the following sections:

  • How does MQ-135 Gas Sensor Work?
  • MQ-135 Gas Sensor pinout and datasheet.
  • MQ-135 Gas Sensor Features
  • How to connect the MQ-135 Gas Sensor with Arduino?
  • The MQ-135 Gas Sensor Arduino Code.

How does the MQ-135 gas sensor work?

The gas sensor module consists of a steel exoskeleton under which a sensor component is placed. This sensitive element is subject to the current through the sensor wire. This current is called the heating current, through which the gases ionize the sensitive material and are absorbed by the sensitive material. It changes the resistance of the sensing element, which changes the value of the current carried from it. 

MQ-135 gas sensor pinout and datasheet:

The pin configuration of the MQ-135 gas sensor is pretty straightforward. The pinout is given below.

MQ-135 gas sensor pinout

MQ-135 gas sensor pinout

There are 4 pins in the MQ-135 gas sensor. The sensor can output both digital and analog signals. The operating Voltage of the MQ-135 gas sensor is 5 volts. The pins are:

  1. VCC (+5 volt)
  2. GND (-)
  3. Digital Out
  4. Analog Out

MQ-135 Gas Sensor Features:

  •     Fast response and High Sensitivity
  •     Wide detecting scope
  •     The operating Voltage is +5V
  •     Detect/Measure the volume of NH3, NOx, alcohol, Benzene, smoke, CO2, etc.
  •     Analog output voltage: 0V to 5V
  •     Digital output voltage: 0V or 5V (TTL Logic)
  •     Preheat duration 20 seconds
  •     It can be used as a digital or analog sensor
  •     The Sensitivity of the Digital pin can be varied using the potentiometer

How to connect the MQ-135 Gas Sensor with Arduino?

Let's discuss the project plan and connect the MQ-135 Gas Sensor with Arduino. The story is simple. We will connect the MQ-135 gas sensor with Arduino to detect Gas. If the sensor picks unusual Gas in the environment, we will start a buzzer as an alarm. We can also send SMS using the GSM module. But, in this project, we will only play a buzzer. We will also include one red and one green LED.

Circuit Diagram for MQ-135 gas sensor
Circuit Diagram for MQ-135 gas sensor

We are going to receive analog values from the sensor. We used the Arduino A5 pin. So, we connected the A5 pin with the 4th pin in the sensor. The sensor GND and VCC goes to Arduino GND and 5volt. 

We have connected the buzzer with Arduino digital D10 pin. The Green and Red LED connected with the D11 and D12 pins of Arduino. 

Testing the connection of the MQ-135 Gas Sensor with Arduino:

Now it's time to try the project. We have to upload Arduino code using Arduino IDE to test the circuit. I will attach an Arduino scratch. Upload the program open serial monitor. You will get the results in the serial monitor. 

The MQ-135 Gas Sensor Arduino Code:

Here is the Arduino code for interfacing MQ-135 gas sensor with Arduino.

0/Post a Comment/Comments