Uncategorized

MQ9 Notes

Asked 
Active today
Viewed 60 times
1

I already have bmp180 sensor connected to raspberry pi 3b+, now I want to add MQ9 sensor like this https://e-radionica.com/en/mq9-gas-sensor.html

  1. Is connection straight forward like the bmp180?
  2. Second question is how to wire mq9 to rpi with already connected bmp180?
  • “Precision” won’t matter much since you will be using the binary HIGH/LOW output as the Pi has no analog input — but in any case discussions about the precision of specific sensors is more appropriate to our larger sibling site, Electrical Engineering (so I have edited that out). – goldilocks Oct 30 at 20:54
  • Do you maybe know how high/low outputs are differentiated? – PostarLakogSna Oct 30 at 20:56
  • I believe the screw dial (gray circle w/ philips head “X”) controls this, but I could be wrong. – goldilocks Oct 30 at 20:59
  • @PostarLakogSna, Ah, let me see. Here is my quick and dirty MQ9 Rpi interface summary: (1) MQ9 is a digital guy, can be adjusted by the heating/timing and loading/sensitivity pots/resistors to trigger High logical alarm signal when gas (CO or flammable) leaking, (2) It is not connected to SPI or I2C bus like BMP180 or other sensors, so, no conflict between BMP and MQ work same time, (3) It is easy to connect MQ9 output pin (directly or after logical level shifting, or adding a chip Schmitt trigger chip to prevent false alarm) to Rpi GPIO pin in input mode. In short, – No worries at all! 🙂 – tlfong01 Oct 31 at 2:09
  • @PostarLakogSna, Please let me know if your MQ9 module is similar to mine: imgur.com/gallery/MqXE3CH. or give me the link of yours (same as in your question?). Perhaps I can try to do some engineering experimentation for. MQ9 is a life critical thing, and I am just a friendly home automation hobbyist, so do ask for a professional opinion! 🙂 – tlfong01 Oct 31 at 2:33
  • @PostarLakogSna, You might also like to let me know if you wish to measure (1) Digital, (2) Analog, (3) PPM, (4) All above three together. To do analog or ppm, you need an ADC。 For, analog measurement, you can do early warning risk analysis before the red alarm alert trigger level is reached. For ppm, you can also recognize which type of gas is present, and send messages to you android smart phone, indicating level of risk etc. Below is my engineering experimentation log entry: penzu.com/p/93aaa16e This linked engineering experimentation report keeps updating, so stay “tuned” 🙂 – tlfong01 Oct 31 at 3:27
  • @PostarLakogSna, PPM measurement is interesting. The circuit is not that complicated. You can use the very popular Rpi friendly MCP3008 10 bit SPI ADC (Google AdaFruit or SparkFun for newbie friendly tutorials): Connect MQ9 Load resistor analog output to MCP3008, which in turn is connected to Rpi SPI. You can use colourful LEDs connected Rpi GPIO pins to indicate which type of gas is detected, or LED bars to indicate gas intensity etc . The ppm measurement tutorial: “How to Choose GAS sensor?” – theorycircuit.com. theorycircuit.com/choose-gas-sensor, Happy reading. Cheers! 🙂 – tlfong01 Oct 31 at 4:51
  • @PostarLakogSna, Now I have skimmed a Gas Detector Hnadbook and got a rough idea of all the detectors work. Now I am coming back the MQ9, a MOS detector. Next step is doing a Rp MQ9 PPM Circuit Analysis and Design. See update of my log book for more details. – tlfong01 Oct 31 at 7:25
  • @tlfong01 sensor is identical to one in the link. What I want to measure is the limit above which I want to trigger some signal. How can I configure this? I mean, having exact value would be nice but I am looking for minimum effort here with minimum additional components needed. I have already connected my temp/press/hum sensor to 5V pin, so there will be some double use. Generally, I would be grateful if you could answer me what I need in order to trigger signal when CO exceeds limit, and what if I measure exact values – PostarLakogSna Oct 31 at 8:37
  • @PostarLakogSna, This tutorial might help: “MQ2 for Rpi” tutorials-raspberrypi.com/…. I have updated my development notes to V0.3 with this tutorial reference. You can read the tutorial and let me know anything you are confused, and I can explain it as an appendix in my develop notes. Tutorial + comments has example code for MCP3008 and ADS1115, also level shifting to 5V. If you are not familiar with them, you might search “MCP3008”, in this forum. I could not find updated refs for Rpi + MQ9. Let me know if you find any. – tlfong01 Oct 31 at 8:54
  • @PostarLakogSna, Yes, if what you want is a High or Low signal, then you don’t need any ADC. You only need to calibrate the sensor, using the adj pot so that it trigger alarm HIgh level signal when the gas. CO, say, reaches a certain level. MQ9 is for CO, Coal, and Liquefied Gas. I don’t feel like to experiment with coal or liquid gas. What I can try is CO. Let me see, I can place the MQ9 in a gas jar, and light a candle to see if O2 decreases, CO increases, MQ9 shows anything. I know plenty of physics, but too little chemistry to do such experiments. Perhaps you can suggest anything. – tlfong01 Oct 31 at 9:08
  • @tlfong01 thanks, what do you mean by adj pot? so in this case I don’t need any resistors? My intention is to monitor CO only, so no problem about it. I will check all this later and let you know what bothers me – PostarLakogSna Oct 31 at 10:04
  • @PostarLakogSna, Ah, “adj pot” means “adjusting potentiometer” (the blue square pot which you can adjust with a small screw driver). For MQ9, it the the variable resistor Rp to adjust the reference voltage of the operational amplifier (OP AMP) comparator producing the digital output. The sensor resistor Rl is another thing. You need to read this tutorial to clarify things: “MQ137 Ammonia Gas Sensor Measuring PPM using Arduino – Aswinth Raj 2018feb09” circuitdigest.com/microcontroller-projects/…. – tlfong01 Oct 31 at 14:08
  • MQ9 schematic: imgur.com/gallery/YLEo8tq. For digital output, what you need to do are: (1) Set the gas (CO) density level to trigger alarm, (2) Turn 10k trim pot CW and CCW to find the trig point. Blue square trim pot sets the reference voltage for the comparator. But you don’t need to understand the details, if you are like me, a huge fan of Oliver Heavyside who says: “Should I refuse a good dinner simply because I do not understand the process of digestion?” (Criticized for using formal mathematical manipulations, without understanding how they worked). Bed time. See you tomorrow. – tlfong01 Oct 31 at 15:03
  • One additional question, we are talking here about pure electrical sensor, don’t we? Do you know some (electrochemical) sensors suitable for rpi? – PostarLakogSna Oct 31 at 15:40
  • Well, Rpi only talks electrical, though you can use “transducers” to convert electrical to optical, audio, mechanical, etc. But I don’t know nothing much about chemical, … 🙂 – tlfong01 Nov 1 at 2:31

3 Answers

1

The BMP180 is a digital device and connects via the I2C bus.

The MQ9 is an analogue device and produces a variable voltage. It can not be directly connected to the Pi.

You need to connect the MQ9 to an ADC (Analogue to Digital Converter) and connect the ADC to the Pi.

ADCs tend to have an I2C or a SPI interface. The choice is yours.

1

You can use a Arduino NANO for taking the MQ9 reading. Raspberry pi has no ADC inside so you have to get the value like this. Or use some sort of voltage detector(detects voltage and give us a certain value) that can digitise the values.

  • Ah, I know ADC, but never heard of “volateg detector”. What is that? – tlfong01 Oct 31 at 6:41
  • @tlfong01 sorry my mistake. Read again – Sohan Arafat Oct 31 at 10:08
  • I see. So your are talking about the “voltage tester”, like this: How to Use a Non-Contact Voltage Tester 151,527 views 2015may20 youtube.com/watch?v=IsXu6ukQbZI – tlfong01 Nov 1 at 2:25
  • 1
    Ah yes, Nano’s six 10 bit ADC pins is good a idea to replace ADC MCP3008 or ADS1115. Those Arduino guys should welcome this approach, because no new things need to learn,while MCP3008 is hard to learn. For hobbyist projects, 10 bit resolution, about 1% accuracy should be enough. Other advantages: (1) Arduino shares Rpi’s processing and storage loading, (2) Arduino, if using UART TTL serial, can be placed more than 20 metres from Rpi. Moreover, Rpi4B has 5 onboard UARTs and with a USB hub, can setup more USB to serial UART ports, so more flexible and scalable than MCP3008. – tlfong01 2 days ago
0

Question

How Can Rpi3B+ Detect MQ9 Gas Sensor’s Carbon Monoxide Leakage, Without Using ADC?


Answer

  1. Understanding MQ9’s Digital and Analog signals

MQ9 has both a Digital and an Analog output signal, as summarized below:

(a) Digital – To detect gas leakage or no leakage, outputting High level 4.8V, or Low, 0.2V, respectively.

(b) Analog – To show gas intensity, outputting voltage in a range of 1.5V to 0.5V.

MQ9 1


  1. Rpi reading MQ9’s Digital and Analog Output

(a) Digital – Rpi can use a GPIO pin to read the MQ9 digital output, after converting logical level from 5V to 3V.

(b) Analog – Rpi must first use an ADC (Analog to Digital Converter) to convert MQ9 analog signal to digital, and then read the digital values.

MQ9 2


  1. Calibrating MQ9 to detect Carbon Monoxide CO leakage

Only two simple steps. What you need is only a screw driver. No Rpi or even a multi-meter is needed to calibrate MQ9.

(a) Connect MQ9 to 5V.

(b) Adjust the 10k trim pot (trimming potentiometer), by trial and error, turning screw clockwise and counter clockwise, to locate the threshold triggering point when the alarm red LED turning on and off. Then turn screw a little bit anticlockwise to turn LED off. Now MQ9 is set to clean air.


  1. Testing MQ9’s gas leaking alarm function

(a) Place MQ9 and a candle in a glass jar, and light the candle.

(b) After less then 2 minutes, the candle will burn out all the oxygen into carbon monoxide in the jar, and will extinguish, and red status LED will turn on.

MQ3


  1. Writing a simple python program to read Rpi GPIO connected to MQ9

(a) Use a voltage divider to step down MQ9 5V logical level to 3V

(b) Connect MQ9 3V logical level output pin to any Rpi GPIO pin

(c) Write a simple python read GPIO program to finish off the project.


End of answer

====================================================
1

Q: How to connect Rpi to MQ9 Gas Sensor?

PostarLakogSnaI already have bmp180 sensor connected to raspberry pi 3b+, now I want to add MQ9 sensor like this e-radionica.com/en/… Is connection straight forward like the bmp180? Second question is how to wire mq9 to rpi with already connected bmp180?

PostarLakogSna
PostarLakogSna
Do you maybe know how high/low outputs are differentiated?
tlfong01

tlfong01
2249
@PostarLakogSna, Ah, let me see. Here is my quick and dirty MQ9 Rpi interface summary: (1) MQ9 is a digital guy, can be adjusted by the heating/timing and loading/sensitivity pots/resistors to trigger High logical alarm signal when gas (CO or flammable) leaking, (2) It is not connected to SPI or I2C bus like BMP180 or other sensors, so, no conflict between BMP and MQ work same time, (3) It is easy to connect MQ9 output pin (directly or after logical level shifting, or adding a chip Schmitt trigger chip to prevent false alarm) to Rpi GPIO pin in input mode. In short, – No worries at all! 🙂
@PostarLakogSna, Please let me know if your MQ9 module is similar to mine: imgur.com/gallery/MqXE3CH. or give me the link of yours (same as in your question?). Perhaps I can try to do some engineering experimentation for. MQ9 is a life critical thing, and I am just a friendly home automation hobbyist, so do ask for a professional opinion! 🙂
@PostarLakogSna, You might also like to let me know if you wish to measure (1) Digital, (2) Analog, (3) PPM, (4) All above three together. To do analog or ppm, you need an ADC。 For, analog measurement, you can do early warning risk analysis before the red alarm alert trigger level is reached. For ppm, you can also recognize which type of gas is present, and send messages to you android smart phone, indicating level of risk etc. Below is my engineering experimentation log entry: penzu.com/p/93aaa16e This linked engineering experimentation report keeps updating, so stay “tuned” 🙂
@PostarLakogSna, PPM measurement is interesting. The circuit is not that complicated. You can use the very popular Rpi friendly MCP3008 10 bit SPI ADC (Google AdaFruit or SparkFun for newbie friendly tutorials): Connect MQ9 Load resistor analog output to MCP3008, which in turn is connected to Rpi SPI. You can use colourful LEDs connected Rpi GPIO pins to indicate which type of gas is detected, or LED bars to indicate gas intensity etc . The ppm measurement tutorial: “How to Choose GAS sensor?” – theorycircuit.com. theorycircuit.com/choose-gas-sensor, Happy reading. Cheers! 🙂
@PostarLakogSna, Now I have skimmed a Gas Detector Hnadbook and got a rough idea of all the detectors work. Now I am coming back the MQ9, a MOS detector. Next step is doing a Rp MQ9 PPM Circuit Analysis and Design. See update of my log book for more details.
PostarLakogSna

PostarLakogSna
40
@tlfong01 sensor is identical to one in the link. What I want to measure is the limit above which I want to trigger some signal. How can I configure this? I mean, having exact value would be nice but I am looking for minimum effort here with minimum additional components needed. I have already connected my temp/press/hum sensor to 5V pin, so there will be some double use. Generally, I would be grateful if you could answer me what I need in order to trigger signal when CO exceeds limit, and what if I measure exact values
tlfong01

tlfong01
2249
@PostarLakogSna, This tutorial might help: “MQ2 for Rpi” tutorials-raspberrypi.com/…. I have updated my development notes to V0.3 with this tutorial reference. You can read the tutorial and let me know anything you are confused, and I can explain it as an appendix in my develop notes. Tutorial + comments has example code for MCP3008 and ADS1115, also level shifting to 5V. If you are not familiar with them, you might search “MCP3008”, in this forum. I could not find updated refs for Rpi + MQ9. Let me know if you find any.
@PostarLakogSna, Yes, if what you want is a High or Low signal, then you don’t need any ADC. You only need to calibrate the sensor, using the adj pot so that it trigger alarm HIgh level signal when the gas. CO, say, reaches a certain level. MQ9 is for CO, Coal, and Liquefied Gas. I don’t feel like to experiment with coal or liquid gas. What I can try is CO. Let me see, I can place the MQ9 in a gas jar, and light a candle to see if O2 decreases, CO increases, MQ9 shows anything. I know plenty of physics, but too little chemistry to do such experiments. Perhaps you can suggest anything.
PostarLakogSna
PostarLakogSna
@tlfong01 thanks, what do you mean by adj pot? so in this case I don’t need any resistors? My intention is to monitor CO only, so no problem about it. I will check all this later and let you know what bothers me
tlfong01

tlfong01
2249
Fri 15:16
@PostarLakogSna, Ah, “adj pot” means “adjusting potentiometer” (the blue square pot which you can adjust with a small screw driver). For MQ9, it the the variable resistor Rp to adjust the reference voltage of the operational amplifier (OP AMP) comparator producing the digital output. The sensor resistor Rl is another thing. You need to read this tutorial to clarify things: “MQ137 Ammonia Gas Sensor Measuring PPM using Arduino – Aswinth Raj 2018feb09” circuitdigest.com/microcontroller-projects/….
MQ9 schematic: imgur.com/gallery/YLEo8tq. For digital output, what you need to do are: (1) Set the gas (CO) density level to trigger alarm, (2) Turn 10k trim pot CW and CCW to find the trig point. Blue square trim pot sets the reference voltage for the comparator. But you don’t need to understand the details, if you are like me, a huge fan of Oliver Heavyside who says: “Should I refuse a good dinner simply because I do not understand the process of digestion?” (Criticized for using formal mathematical manipulations, without understanding how they worked). Bed time. See you tomorrow.
PostarLakogSna
PostarLakogSna
One additional question, we are talking here about pure electrical sensor, don’t we? Do you know some (electrochemical) sensors suitable for rpi?
tlfong01

tlfong01
2249
Well, Rpi only talks electrical, though you can use “transducers” to convert electrical to optical, audio, mechanical, etc. But I don’t know nothing much about chemical, … 🙂
@PostarLakogSna I googled but could not find any other cheap hobbyist grade CO gas sensor for Rpi. So I will carry on my experiments on MQ9. I looked at the sensor spec penzu.com/p/93aaa16e Appendix E, and found two potential problems (1) the sensor resistance (Rs/R0) vs ppm is log scale rather than linear. This means that slight variation in concentration might mean big variation is resistance.
(2) sensor resistance varies with temperature. So now I am going to calibrate and see if it is a serious problem.
5 hours later…
tlfong01

tlfong01
2249
Fri 20:31
I have more or less finished learning the MQ9 gas sensor. It is more complicated than I thought. I have compiled a learning notes: V0.9 penzu.com/p/93aaa16e
Next step is calibration and testing. The first step is to find R0, the initial sensor resistance in clean air. The second step is to measure the CO gas concentration. Both steps are complicated. Therefore I do not recommend you to spend much time to try to understand my learning notes, because they are now unstructured. I need to tidy up before submitting it to the forum as part of my answer to your question.
Now I am going to do the calibration and measurement. Again do not try to understand everything I am doing. It is enough just to get a rough picture. Again, I will tidy up my calibration and measurement procedure before submitting to the forum. This part might take me a couple of days. Cheers.
The last message was posted 3 days ago.
.END

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: