MQ-135 is a gas sensor designed to sense or detect gaseous substance and generate a corresponding positive output voltage.
In this post we will learn how to connect or wire the pinouts of an MQ-135 module with a relay driver stage correctly.
The MQ-135 module is an enhanced or upgraded package of the basic MQ-6 gas sensor module. In this module the analogue output from the MQ-6 is converted into a digital output, with an adjustable sensitivity feature.


The conversion of the analogue to digital is done through a comparator IC, usually an LM393.
How The MQ-135 Module Works
As described above the MQ-135 works by converting the analogue signals from the sensor unit into digital output through a comparator.
The module basically features 4 pinouts.
- Vcc
- Ground
- Digital Out
- Analogue Out
Sensor side View

Component Side View

The analogue out is directly taken from the MQ-6 sensor pin.
The Vcc works with a +5V DC supply, ground is the negative or the 0V terminal of the module.
The digital output is derived from the output of a differential comparator using the IC LM393.
How to Configure MQ-135 Correctly
Recently I purchased the MQ-135 module and while testing it I was surprised to see my external relay driver not responding at all. However, since the module's in-built LED was illuminating, I knew the module was OK.
I assumed and expected the output to produce a positive digital signal for every input detection. However, I simply couldn't get this working.
Then I realized that the IC LM393 has an open collector output, meaning its output pin was associated with an open collector of an internal NPN BJT.
And since my external relay driver NPN BJT was unresponsive meant that the module did not have a pull up resistor with the LM393 output.
I quickly configured a pull-up resistor with the comparator output pin and tried again. The relay now responded but with an opposite effect.
Meaning, now the relay remained switched ON when powered, and switched OFF as soon as the sensor detected gas. This was very undesirable, and was due a wrongly configured module.
It seemed the manufacturer missed the fact that the LM393 is not an op amp, and its input pins needs to be wired in a way opposite to an op amp input wiring. In other words (+) input pin should have been wired with the reference preset and the (-) input with the sensor analogue input.
Anyway, since it was not possible to modify the module PCB and the ICs input configuration, I ultimately decided to change the NPN relay driver with a PNP transistor driver. And this solved the issue.
Wiring Diagram
Here's the complete wiring diagram of MQ-135 for all the new hobbyists, who may otherwise find it impossible to drive a relay using NPN transistor, for a positive detection. May be, for the future productions this issue will be addressed by the manufacturer and corrected.

Have Questions? Please Comment below to Solve your Queries! Comments must be Related to the above Topic!!