Maker Pro
Maker Pro

Connect MQ135 Gas Sensor to Raspberry Pi 3B+

Hello experts!

I am totally new to electronics and I need help with connecting the MQ135 Gas sensor with my raspberry pi 3B+ and with interpreting the data that the sensor provides. My main problem is that the sensor provides analog signals and the RPi 3B+ does not have a pin for analog signals.

Therefore I bought an ADC (ADS1115) with 16bit precision. I followed the following guide to read the data from the ADS1115 via python libraries on the RPi:

https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/ads1015-slash-ads1115

This way I can monitor the provided values from the analog inputs (AIN0 - AIN4). I do not understand what I am actually reading. The values fluctuate and with the GAIN parameter in the python script set to1 I get values in the range of 3000-5000 (but nothing is connected to the analog inputs of the ADC - so why do I see values at all?).

When I connect the AOUT pin of the MQ135 with AIN0 of the ADC the values from every analog input (AIN0 - AIN4) change - shouldn't only the value from AIN0 change?

The breadboard looks like this:

breadboard.jpg

In the scheme it says that it is the MQ9 - but I am using MQ135. The brown cable connects the analog out pin of the MQ135 with the AIN0 of the ADS1115.
The yellow calbe of the MQ135 is VCC and the orange cable is GND.

My questions:

1. Should I change something on the breadboard?
2. How should I interpret the data that the ADS1115 is providing?
3. Why is the ADS1115 reading signals when nothing is connected to AIN0 - AIN4?

I would also be very thankful if someone could maybe show me some sources which would help me to make further research.

Thank you!
 

Harald Kapp

Moderator
Moderator
When I connect the AOUT pin of the MQ135 with AIN0 of the ADC the values from every analog input (AIN0 - AIN4) change - shouldn't only the value from AIN0 change?
If you leave the unused inputs open, they will "collect" stray signals aka noise and show random values. Tie unused inputs to e.g. GND to ensure they are stable.

Should I change something on the breadboard?
Yes. see above.

How should I interpret the data that the ADS1115 is providing?
According to the description of the data structure in the datasheet of teh ADC.

Why is the ADS1115 reading signals when nothing is connected to AIN0 - AIN4?
See above.
 
Thank you for your response!
I connected the other analog inputs to GND. This made the values stable. Does this mean that I have to substract the noise value from the value thet I get when I connect the MQ135?
 

Harald Kapp

Moderator
Moderator
Does this mean that I have to substract the noise value from the value thet I get when I connect the MQ135?
Which noise would you subtract? As you noticed, noise is an unstable signal...
No, if ythe sensor is connected correctly, noise external noise should not be an issue.
However, there may be (usually is) an issue with internal noise from the sensor on top of the signal. Some signal conditioning may be required to generate a smooth output for further processing/display. For a slow-acting sensor as yours a simple method for noise reduction is e.g. averaging over a few samples (w.g. 10 samples).
 
Top