Ikea Sensor ESPHome Code

Yaml code for the Ikea Sensor, copy (and edit) here:


esphome:
  name: multisensor
  platform: ESP8266
  board: esp_wroom_02

wifi:
  networks:
  - ssid: "WlanGoesHere"
    password: "YouWish123"
  - ssid: "AnotherWLAN"
    password: "topsecret"    

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Sensor Fallback Hotspot"
    password: "Nope, not for you"
captive_portal:

# Enable logging
logger:

mqtt:
  broker: broker-hostname-goes-here
  discovery: True
  
ota:
  password: "topsecret42"

# for bme
i2c:
  sda: 14
  scl: 12
  scan: true
  frequency: 400kHz

bme680_bsec:
    address: 0x77
    temperature_offset: 3
    iaq_mode: static
    sample_rate: lp
    state_save_interval: 6h
    
# for PM2.5
uart:
  rx_pin: 4
  baud_rate: 9600

sensor:
  - platform: pm1006
    pm_2_5:
      name: "Ikea PM 2.5"
      filters:
      - median:
          window_size: 9
          send_every: 9
          send_first_at: 9

  - platform: bme680_bsec
    temperature:
      # Temperature in °C
      name: "BME680 Temperature"
      sample_rate: lp
      filters:
        - median
    pressure:
      # Pressure in hPa
      name: "BME680 Pressure"
      sample_rate: lp
      filters:
        - median
    humidity:
      # Relative humidity %
      name: "BME680 Humidity"
      sample_rate: lp
      filters:
        - median
    iaq:
      # Indoor air quality value
      name: "BME680 IAQ"
      filters:
        - median
      # this controls the second led
      on_value_range:
        - below: 50
          then:
            - output.turn_on: green_led
            - output.turn_off: red_led
        - above: 50
          below: 125
          then:
            - output.turn_on: green_led
            - output.turn_on: red_led
        - above: 125
          then:
            - output.turn_on: red_led
            - output.turn_off: green_led

    iaq_accuracy:
      # IAQ accuracy as a numeric value of 0, 1, 2, 3
      name: "BME680 Numeric IAQ Accuracy"
    co2_equivalent:
      # CO2 equivalent estimate in ppm
      name: "BME680 CO2 Equivalent"
      filters:
        - median
    breath_voc_equivalent:
      # Volatile organic compounds equivalent estimate in ppm
      name: "BME680 Breath VOC Equivalent"
      filters:
        - median

# pin config for the second led
output:
  - id: red_led
    platform: gpio
    pin: GPIO16
  - id: green_led
    platform: gpio
    pin: GPIO5