vd Brink Home Automations

Home automations: Home Assistant, ESPHome, Node-RED and more.

Follow me on GitHub

ESPHome SenseAir S8 Co2 sensor

Introduction

There are not much out-of-the-box Co2 sensors available, but it’s easy to create one yourself.

Co2 stands for Carbon dioxide and is measured in Parts per million (ppm). If your in a space with a too high ppm level you can feel tired, your start yawn and can get a headache.

The average value outside is around 400 ppm.

ppm condition action
400 - 800 good no action is required
800 - 1200 medium open a window
1200+ bad limit has reached, open all windows

My solution

A small box with a tail.
Inside a Co2 sensor and an ESP mini.

final box


Table of Contents


Required hardware

These hardware components do I use for this project:

SenseAir S8 Co2 sensor
  • ESP 12S Wemos D1 mini (no pro or V3) link 1
ESP D1 mini
  • 5 plastic DIY Cases 70 x 45 x 30 mm (One is ofcourse enough for this project.)
DIY cases
  • Micro USB cable to power the ESP link 1

Micro USB cable

5V USB power adapter

Also affiliate links are used here.

Found a dead link? Please inform me


Required software


Connect the hardware

I’ve made a scheme how to connect the SenseAir S8 to the ESP.

Connect the SenseAir S8 to the ESP

Use control + click to see the full photos of the connected wires.

Connected pins ESP8266 Wemos
D1 mini pins
SenseAir S8 pins
Connect schema ESPHome SenseAir S8 Pins on a ESP8266 Wemos di mini Pins on a SenseAir S8
180 degrees rotated compared with the first image.

This table show how the ESP is connected with the SenseAir.

Wemos pin GPIO Wemos pin* SenseAir pin
D7 GPIO13 UART_TxD
D8 GPIO15 UART_RxD
G GND G0
5V 5 V G+

* The GPIO Wemos pin is the port which is used in the ESPHome yaml.

If you place the sensor on top of the ESP mini it fits perfect in the DIY box.

perfect fit in case

I drilled some holes in the DIY case. Now the air can reach the Co2 sensor inside the box.

holes in case


ESPHome

ESPHome

ESPHome SenseAir page

Flash the ESP

Connect the ESP via USB with the computer.

Install ESPHome and compile the configuration code after you configured your own wi-fi. And configure (or remove) the MQTT section.

For more information about installing and flashing your ESP with ESPHome see the ESPHome website or Peyanski ESPHome Installation Guide.

The script:

# Sourcecode by vdbrink.github.io
esphome:
  name: esp_co2
  comment: Room Co2 sensor
  platform: ESP8266
  board: d1_mini
  arduino_version: latest

wi-fi:
  ssid: "xxx"
  password: "xxx"
  fast_connect: true # only needed for hidden SSID
  
mqtt:
  broker: xxx.xxx.xxx.xxx
  port: 1883
  username: "xxx"
  password: "xxx"
  
uart:
  rx_pin: GPIO13
  tx_pin: GPIO15
  baud_rate: 9600
  
sensor:
  - platform: senseair
    co2:
      id: senseair_co2
      name: "SenseAir Co2 Value"
    update_interval: 30s

Home Assistant

Ones the sensor push the data, you can use and present the data on your dashboards or create notifications when the status is not good.

Dashboard Gauge

In a gauge you can direct see if the current co2 value is correct. I used different colors to indicate how bad the condition is. I used the values from the table mentioned in the Introduction.

Home Assistant Gauge
# Sourcecode by vdbrink.github.io
# Dashboard card code
type: gauge
severity:
  green: 400
  yellow: 800
  red: 1200
entity: sensor.senseair_co2_value
min: 350
max: 1500
name: Room Co2 sensor

Dashboard Graphic

To show the history of the last x hours you can use the card.

Home Assistant Graph
# Sourcecode by vdbrink.github.io
# Dashboard card code
type: sensor
graph: line
entity: sensor.senseair_co2_value
name: Room Co2 sensor
hours_to_show: 6

Dashboard condition text

This creates a new sensor which show a textual presentation of the current condition.


# Sourcecode by vdbrink.github.io
# configuration.yaml
- platform: template
  sensors:
    senseair_co2_value_text:
        icon_template: "mdi:molecule-co2"
        friendly_name: "Room Co2"
        value_template: >-
          {% set state = states('sensor.senseair_co2_value') | int %}
          {% if state < 800 %}good
          {% elif state > 800 and state <= 1200 %}average
          {% elif state > 1200 and state <= 1500 %}bad
          {% elif state > 1500%}very bad
          {% else %}unknown{% endif %}

Dashboard bad condition text

In my dashboard I have a section with important messages. Only when there is an action required you see that here. There is also a message when the Co2 value is not good. This section can be achieved by using conditional entities.


# Sourcecode by vdbrink.github.io
# Dashboard card code
type: entities
entities:
- type: conditional
  conditions:
    - entity: sensor.senseair_co2_value_text
      state_not: good
      row:
        entity: sensor.senseair_co2_value_text




Consider supporting my blog and make a small donation if you find this content useful. Scroll up and check the right column how you can support me.

Remarks or suggestions?

Do you have any remarks or suggestions please let me know via github issues.

Create an issue

Or via a private message on the Tweakers.net forum.


Top | Homepage | Donate