Connect with us

Connect MQ135 Gas Sensor to Raspberry Pi 3B+

Discussion in 'Sensors and Actuators' started by Coziac, Dec 5, 2019.

Scroll to continue with content
  1. Coziac

    Coziac

    2
    0
    Dec 5, 2019
    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:

    [​IMG] 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!
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    10,025
    2,138
    Nov 17, 2011
    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.

    Yes. see above.

    According to the description of the data structure in the datasheet of teh ADC.

    See above.
     
  3. Coziac

    Coziac

    2
    0
    Dec 5, 2019
    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?
     
  4. Harald Kapp

    Harald Kapp Moderator Moderator

    10,025
    2,138
    Nov 17, 2011
    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).
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-