Skip to content
Get started

DFRobot SEN0465 to SEN0476 Gas Sensors

The dfrobot_sen0465_i2c and dfrobot_sen0465_uart sensor platforms allow you to use the DFRobot “Factory Calibrated Electrochemical Gas Sensor” series (product page) with ESPHome. All boards of the series use the same protocol. They only differ in the gas probe that is fitted.

DFRobot SEN0466 signal conversion board next to the CO probe
SEN0466 (CO): signal conversion board and probe

The sensor reports the gas concentration and the temperature of its on-board temperature sensor.

ModelGasUnitModelGasUnit
SEN0465Oxygen (O2)%SEN0471Nitrogen dioxide (NO2)ppm
SEN0466Carbon monoxide (CO)ppmSEN0472Ozone (O3)ppm
SEN0467Hydrogen sulfide (H2S)ppmSEN0473Hydrogen (H2)ppm
SEN0468Chlorine (Cl2)ppmSEN0474Hydrogen chloride (HCl)ppm
SEN0469Ammonia (NH3)ppmSEN0475Hydrogen fluoride (HF)ppm
SEN0470Sulfur dioxide (SO2)ppmSEN0476Phosphine (PH3)ppm

The sensor can be connected over I²C or UART. The SEL DIP switch on the board selects the bus: 0 for I²C and 1 for UART.

# Example configuration entry for I²C
sensor:
- platform: dfrobot_sen0465_i2c
model: SEN0466
concentration:
name: "CO Concentration"
temperature:
name: "CO Sensor Temperature"
# Example configuration entry for UART
uart:
tx_pin: GPIOXX
rx_pin: GPIOXX
baud_rate: 9600
sensor:
- platform: dfrobot_sen0465_uart
model: SEN0466
concentration:
name: "CO Concentration"
temperature:
name: "CO Sensor Temperature"
  • model (Required, string): The model of the sensor board, from SEN0465 to SEN0476. See the table above. The model sets the unit, the number of decimal places and the device class of the concentration sensor.

  • concentration (Optional): The gas concentration. The unit is % for oxygen (SEN0465) and ppm for all other gases.

  • temperature (Optional): The temperature measured on the sensor board, in °C.

  • temperature_compensation (Optional, boolean): Correct the concentration for the board temperature. See Temperature Compensation. Not available for SEN0465 (O2) and SEN0473 (H2). Defaults to false.

  • alarm (Optional): Set up the alarm output (ALA pin) of the board. See Alarm Output.

    • threshold (Required, float): The concentration at which the alarm is triggered, in the unit of the concentration sensor.
    • type (Optional, string): high triggers the alarm when the concentration rises above the threshold, low triggers it when the concentration falls below the threshold. Defaults to high.
  • update_interval (Optional, Time): The interval to read the sensor. Defaults to 60s.

  • address (Optional, int): I²C only. The I²C address of the sensor. Defaults to 0x77. See the I²C address table below.

  • i2c_id (Optional, ID): I²C only. The ID of the I²C bus to use.

  • uart_id (Optional, ID): UART only. The ID of the UART bus to use.

The baud rate of the sensor is fixed. The UART bus must use 9600 baud, 8 data bits, no parity and 1 stop bit, and needs both a tx_pin and an rx_pin. ESPHome checks this when it validates the configuration.

The A0 and A1 DIP switches on the board select the I²C address:

A0A1Address
000x74
010x75
100x76
110x77 (default)

The sensor also supports other address groups between 0x60 and 0x7F. ESPHome cannot change the address group. It can only be changed with the DFRobot Arduino library.

At startup, ESPHome switches the sensor to passive mode, in which the sensor only answers requests. It then waits 1 second, sets or switches off the alarm and takes the first reading.

Setting the passive mode and setting the alarm are each tried up to 3 times, when the sensor does not answer or sends a wrong answer. If a step still fails, ESPHome continues with the next step but keeps a warning set until the device restarts, because the sensor may be running with the wrong mode or alarm. A reading that gets no answer, a wrong answer or a bad checksum publishes unknown on the sensors and sets a warning that the next good reading clears. A failed reading is not repeated; the sensor is asked again at the next update_interval.

If the very first request cannot be sent at all, for example because no device answers at the I²C address, the component is marked as failed and does not try again.

The readings of electrochemical gas probes change with temperature. When temperature_compensation is true, ESPHome corrects the concentration with the formulas from the DFRobot library and the board temperature.

The formulas only cover a limited temperature range, which depends on the gas. Outside this range the concentration is published as NaN and the component shows a warning.

NOTE

The DFRobot library has no correct compensation formula for hydrogen (SEN0473), and none at all for oxygen (SEN0465). The option is therefore not available for these models.

The board has an alarm output pin (ALA). The sensor sets this pin when the concentration crosses the threshold. If alarm is not set, ESPHome switches the alarm off at startup.

The state of the alarm cannot be read over I²C or UART. To use it in ESPHome, connect the ALA pin to a GPIO and add a GPIO Binary Sensor:

sensor:
- platform: dfrobot_sen0465_i2c
model: SEN0466
alarm:
threshold: 35
concentration:
name: "CO Concentration"
binary_sensor:
- platform: gpio
pin: GPIOXX
name: "CO Alarm"
device_class: carbon_monoxide

According to DFRobot, the pin goes high when the alarm is triggered. If your board behaves the other way round, add inverted: true to the pin.

NOTE

The sensor compares the threshold with its own reading, without temperature compensation. The alarm can therefore trigger at a slightly different value than the one shown by the concentration sensor.