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, there are many sensors being used to monitor and control home applications, robotics, industrial automation, and so on. There are different sensors for different purposes. As like human has different sensing capability for a different purpose. In this article, we are focusing on the MQ-135 gas sensor to monitor the environment. MQ-135 gas sensor mainly used to measure the volume of 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 are going to learn more about the MQ-135 gas sensor, how to interface the MQ-135 Gas Sensor with Arduino Board? 

In this tutorial, we will cover the following sections:

  • How MQ-135 Gas Sensor Works?
  • 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 MQ-135 gas sensor works?

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 known as 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 much 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
  •     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
  •     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 how to connect the MQ-135 Gas Sensor with Arduino. The story is simple. We are going to 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 value 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 D11 and D12 pin of Arduino. 

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

Now it's time to test the project. To test the circuit, we have to upload Arduino code using Arduino IDE. 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 of MQ-135 gas sensor with Arduino.

0/Post a Comment/Comments