To detect the presence of LPG gas using the MQ6 gas sensor and display the gas concentration status on a 16×2 I2C LCD connected to a Raspberry Pi Pico.
Buy Basic Raspberry Pi Pico Kit
Items Required:
- Raspberry Pi Pico board
- MQ6 LPG gas sensor module
- 16×2 I2C LCD display
- Breadboard
- Jumper wires
- USB cable for power and programming
- Resistors (optional, for voltage level protection)
Connections:
- MQ6 Sensor (Analog Output used)
- VCC → Pico 3.3V
- GND → Pico GND
- AOUT → Pico ADC0 (GPIO26, Physical pin 31)
- 16×2 I2C LCD
- VCC → Pico 3.3V or 5V (based on your LCD module)
- GND → Pico GND
- SDA → Pico GP0 (Physical pin 1)
- SCL → Pico GP1 (Physical pin 2)


Code: (main.py)
from machine import ADC, Pin, SoftI2C
from pico_i2c_lcd import I2cLcd
from time import sleep
# Setup I2C LCD
i2c = SoftI2C(sda=Pin(0), scl=Pin(1), freq=400000)
lcd = I2cLcd(i2c, 0x3f, 2, 16)
# Setup MQ6 gas sensor on ADC0
mq6 = ADC(Pin(26)) # GPIO26 / ADC0
# Function to determine gas level description
def get_gas_level(voltage):
if voltage < 0.5:
return "No Gas"
elif voltage < 1.0:
return "Low"
elif voltage < 1.5:
return "Moderate"
elif voltage < 2.0:
return "High"
else:
return "Dangerous"
lcd.clear()
lcd.putstr("LPG Gas Monitor")
sleep(2)
lcd.clear()
# Main loop
while True:
raw = mq6.read_u16()
voltage = (raw / 65535) * 3.3
level = get_gas_level(voltage)
lcd.move_to(0, 0)
lcd.putstr("Voltage: {:.2f}V ".format(voltage))
lcd.move_to(0, 1)
lcd.putstr("Level: {:<11}".format(level))
sleep(1)
Result:
The LCD displays the real-time analog voltage output from the MQ6 sensor.
The voltage is interpreted to determine gas concentration levels: No Gas, Low, Moderate, High, or Dangerous.
Updates occur every second for live monitoring of LPG gas levels.