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
- Is connection straight forward like the bmp180?
- Second question is how to wire mq9 to rpi with already connected bmp180?
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.
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.
How Can Rpi3B+ Detect MQ9 Gas Sensor’s Carbon Monoxide Leakage, Without Using ADC?
- 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.
- 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.
- 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.
- 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.
- 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