ESPHome yaml example for CM1106/CM1107 and AHT10/AHT20

I am running an ESP8266 in my living room to monitor carbon dioxide levels and temperature+humidity, using a CM1107 and AHT20.

Wemos D1 mini, CM1107, AHT20 mounted on a perfboard. I used pin headers so that you can easily swap out components. Also, CM1107 pin headers do not fit the 0.1 inch gaps, so you need to use pin headers and slightly bend it.
Wiring is done on the other side of the perfboard.

CM1107: https://s.click.aliexpress.com/e/_A3DxcY
AHT20: https://s.click.aliexpress.com/e/_Anb8GU

As of September 2021, CM1106/CM1107 is not supported yet. So you have to use the following custom component. Many thanks to LeoDJ!

https://github.com/LeoDJ/ESPHome_Nodes/tree/main/CM1106_CO2_Sensor

Also, the temperature+humidity sensor AHT10/AHT20 is very buggy when connected to ESPHome. Some discussion was made on the issue page: https://github.com/esphome/issues/issues/1635

I had to make some adjustments to make it work properly. Please refer to the following youtube video.

Finally, the working ESPHome yaml example.

esphome:
  name: livingroom-air
  platform: ESP8266
  board: d1_mini
  includes:
  - "cm1106.h"

external_components:
  - source:
      type: git
      url: https://github.com/mahlernim/esphome
      ref: dev
    components: [ aht10 ]

wifi:
  ssid: !secret ssid
  password: !secret password
  manual_ip:
    static_ip: !secret ip_livingroom
    gateway: !secret ip_gateway
    subnet: 255.255.255.0
  ap:
    ssid: "livingroom"
    password: !secret ap_password

captive_portal:

logger:
  baud_rate: 0

api:

ota:

i2c:
  sda: D7
  scl: D6
  frequency: 200kHz

uart:
  rx_pin: RX
  tx_pin: TX
  baud_rate: 9600
  id: cm1107_uart

sensor:
- platform: custom
  lambda: |-
    auto cm1106Sensor = new CM1106Sensor(id(cm1107_uart), 20000);
    App.register_component(cm1106Sensor);
    return {cm1106Sensor};
  sensors:
  - name: "CM1107 CO2"
    accuracy_decimals: 0
    unit_of_measurement: "ppm"
    device_class: "carbon_dioxide"
    filters:
    - median:
        window_size: 5
        send_every: 5
        send_first_at: 3
- platform: aht10
  temperature:
    name: "Livingroom AHT Temperature"
    accuracy_decimals: 1
    filters:
    - filter_out: 0.0
    - median:
        window_size: 3
        send_every: 3
        send_first_at: 1
  humidity:
    name: "Livingroom AHT Humidity"
    accuracy_decimals: 1
    filters:
    - filter_out: 0.0
    - median:
        window_size: 3
        send_every: 3
        send_first_at: 1
  update_interval: 15s

switch:
- platform: custom
  lambda: |-
    auto cm1106Calib = new CM1106CalibrateSwitch(id(cm1107_uart));
    App.register_component(cm1106Calib);
    return {cm1106Calib};
  switches:
  - name: "CM1107 400ppm Calibration"

CC BY-NC-SA 4.0 This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Leave a Comment

Time limit is exhausted. Please reload CAPTCHA.