English
English
简体中文
日本語

Unit MQ Sensor Home Assistant Integration

This chapter introduces the configuration methods and practical steps for integrating the Unit MQ combustible gas detection unit into Home Assistant.

1. Preparation

Environment Setup

  1. Install Home Assistant by following the official Home Assistant documentation.
  2. Install the ESPHome Device Builder add-on by following the official ESPHome documentation.
  3. Refer to the following resources:
  1. Confirm the I2C pin definitions of the controller device (pins vary by controller).

Hardware Products

  • Unit MQ
  • A compatible controller (such as an Atom, Stamp, Stick, Core, or Basic series device)
Note
Unit MQ requires a compatible controller to integrate with Home Assistant. Select the controller model and interface pins according to your project.

2. Modify Configuration

  1. You need to enable the I²C component in the ESPHome configuration:
yaml
1 2 3 4 5
# Example configuration entry for ESP32
i2c:
  sda: GPIOXX
  scl: GPIOXX
  scan: true

The GPIO pins here will differ depending on the host device used. For example, using Atom Lite as the host:

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

Example configuration 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 options:

  • heat_mode (Required): Unit MQ heating mode. Options: CONTINUOUS, SWITCH, and OFF.
  • temperature (Optional): Temperature data derived from the thermistor reading.
  • mq_adc (Optional): 12-bit MQ ADC reading.
  • ntc_adc (Optional): 12-bit NTC ADC reading.
  • ntc_resistance (Optional): NTC resistance value.
  • reference_voltage (Optional): Internal reference voltage.
  • mq_voltage (Optional): MQ voltage reading.
  • led (Optional): LED status reading. The LED lights up when the reading is valid.

Warning | The device needs to be heated for a period of time before it can output normally (ADC readings generally appear only after heating to around 29 degrees Celsius). When the heating mode heat_mode: CONTINUOUS is configured, the device will heat continuously. Be careful of burns when touching the probe.

3. Getting Started

Example display after configuration and integration into Home Assistant:

Page Tools
PDF
On This Page