Manual [PDF] (5 pages)
- Updated: 26.06.2026
Document Preview & Text Transcription
www.joy-it.net
Pascalstr. 8 47506 Neukirchen-Vluyn
ANALOG NATURAL GAS AND METHANE
SENSOR
SEN-MQ4
1. GENERAL INFORMATION
Dear costumer,
thank you very much for choosing our product.
In following, we will introduce you to what to observe while starting up
and using this product.
Should you encounter any unexpected problems during use, please do
not hesitate to contact us.
Please note that the sensor requires a warm-up phase to pro-
vide accurate readings.
www.joy-it.net
Pascalstr. 8 47506 Neukirchen-Vluyn
2. COMMISSIONING WITH THE RASPBERRY PI
Raspberry Pi
ADC
MQ4
V. Translator
GND (Pin 6, 14, 9...)
GND
GND (Pin 1)
GND
5V (Pin 2, 4)
VDD
VCC (Pin2)
VCCb
3V (Pin 1, 17)
VCCa
-
-
BCM17 (Pin 11)
-
-
A3
-
B3
-
D0 (Pin 3)
-
A0
Signal (Pin 4)
SCL (Pin 5)
-
-
A2
SDA (Pin 3)
-
-
A1
-
B2
SCL
-
-
B1
SDA
-
Wiring:
This natural gas and me-
thane sensor is an analog
sensor.
Since the Raspberry Pi has
no analog inputs, you
have to use an analog-to-
digital converter. You will
also need a 3V to 5V volt-
age translator.
In this example the ADC
COM-KY053 and the Com-
KY051 voltage translator
from Joy-it is used.
www.joy-it.net
Pascalstr. 8 47506 Neukirchen-Vluyn
2. COMMISSIONING WITH THE RASPBERRY PI
Code example:
The higher the analog input voltage, the higher the measured natural gas or methane va-
lue.
The value range is from 0 to 5.
The D0 pin of the sensor is automatically set to LOW when the limit value is reached.
With the blue potentiometer on the board, you can set the limit value.
In the following code example, the analog value of the sensor is read out every 5 seconds
and displayed in the console.
from time import sleep
import board
import busio
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)
# Create the I2C bus
i2c = busio.I2C(board.SCL, board.SDA)
# Create the ADC object using the I2C bus
ads = ADS.ADS1115(i2c)
ads.gain = 2/3
# Create single-ended input on channels
chan0 = AnalogIn(ads, ADS.P0)
chan1 = AnalogIn(ads, ADS.P1)
chan2 = AnalogIn(ads, ADS.P2)
chan3 = AnalogIn(ads, ADS.P3)
try:
while True:
if GPIO.input(17) == GPIO.LOW:
print("Warning: Limit exceeded!!!")
print("{:>5.3f}".format(chan0.voltage))
sleep(2.5)
except KeyboardInterrupt:
GPIO.cleanup()
Installation:
To be able to use the ADC, you must first enable I2C.
Enter the following command:
Navigate to Interfacing Options -> I2C and enable the I2C interface.
You must also install the Python library of the ADC.
Enter the following commands:
sudo raspi-config
sudo apt-get update
sudo apt-get install python3-pip
sudo pip3 install adafruit-circuitpython-ads1x15
Pages Preview: