pdf-icon

Unit MQ Home Assistant Integration

Unit MQ is a combustible gas detection unit based on the semiconductor gas sensor (MQ-5), integrated with an MCU (STM32G030F6P6). It is mainly used for detecting combustible gases (such as propane, methane, etc.) in the environment. This unit communicates with various host devices via the I2C interface and can obtain internal reference voltage, sensor voltage, 12-bit and 8-bit ADC raw values, firmware version, thermistor temperature, and other information.

Note
Since Unit MQ is only a sensor platform, additional micro controllers are required (like Atom Lite, Core2, CoreS3 etc) to integrate the device into Home Assistant.

Setup Sensor

I²C component is required for device setup:

yaml
1 2 3 4 5
# Example configuration entry for ESP32
i2c:
  sda: GPIOXX
  scl: GPIOXX
  scan: true

These GPIO pins may varies depend on the device you are using. For an example, Atom Lite:

yaml
1 2 3 4
# I2C Bus on Grove Port (HY2.0-4P)
i2c:
  sda: GPIO26
  scl: GPIO32

Example configurations for Unit MQ

yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
external_components:
  - source: github://m5stack/esphome-yaml/components@main
    components: m5stack_unit_mq
    refresh: 0s

sensor:
  - platform: m5stack_unit_mq
    heat_mode: SWITCH
    temperature:
      id: mq_temp
      name: "Unit MQ Temperature"
    mq_adc:
      id: mq_adc_val
      name: "MQ ADC"
    ntc_adc:
      id: ntc_adc_val
      name: "NTC ADC"
    ntc_resistance:
      id: ntc_resistance_val
      name: "NTC Resistance"
    reference_voltage:
      id: in_ref_volt
      name: "Internal Reference Voltage"
    mq_voltage:
      id: mq_volt
      name: "MQ Voltage"
    ntc_voltage:
      id: ntc_volt
      name: "NTC Voltage"
    led:
      id: mq_led
      name: "MQ LED Status"
    update_interval: 20s

Configurable variables:

  • heat_mode (Required): Unit MQ heat mode, only CONTINUOUR, SWITCH and OFF is accepted.
  • temperature (Optional): Temperature converted from NTC
  • mq_adc (Optional): 12 Bit MQ ADC readings
  • ntc_adc (Optional): 12 Bit NTC ADC readings
  • ntc_resistance (Optional): NTC resistance
  • reference_voltage (Optional): Internal reference voltage
  • mq_voltage (Optional): MQ Voltage reading
  • led (Optional): LED valid reding, when sensor readings are valid, it will light up.
Warning
The sensor require heating before pushing valid readings ( usually MQ readings are given at around 29 degree celsius ). When setting heat_mode: CONTINUOUS, device will heat up continuously, be careful when touching the sensor probe.

Dashboard example

On This Page