Skip to content

Instantly share code, notes, and snippets.

@nuvious
Last active December 25, 2022 01:32
Show Gist options
  • Save nuvious/578357303c7b530baec2f57c4d2902de to your computer and use it in GitHub Desktop.
Save nuvious/578357303c7b530baec2f57c4d2902de to your computer and use it in GitHub Desktop.
QTPY ESP32 C3 + SparkFun Environmental Combo Breakout - CCS811/BME280 (Qwiic) ESPHome Config

Simple Implementation of SparkFun Environmental Combo Breakout

Shoutouts

Some portions of this config are taken from Donovan Baarda aka dbaarda post on the Home Assistant forums. Check out dbaarda's github here as well.

Parts

Adafruit QTPY ESP32 C3 SparkFun Environmental Combo Breakout - CCS811/BME280 (Qwiic) QWIIC Cables/JST SH 4-Pin Cables

Instructions

  • Connect ESP32 to sensor with QWIIC cable
  • Connect ESP32 to computer with USB C
  • Open up ESP Home and create a configuration for a new sensor using qtpy_esp32_c3_ccs811_bme280_esphome.yaml NOTE: Be sure to change relevant fields or just omit them and use the fields generated by ESPHome
  • Click on 'Install' in ESPHome but hold short of clicking 'connect' after you select your COM port
  • HOLD the boot button on the esp32 (be gentle, I've broken one off before)
  • PRESS AND RELEASE the reset button on the esp32
  • Click the connect button, you should see an ESPHome dialogue.
  • When the dialogue goes to 'Preparing Installation' you can release the boot button
  • When install is complete check your router for the new ip address or navigate to outdoor-multi-sensor.local if your router supports mDNS
  • Add the sensor by it's IP to Home Assistant
  • Verify sensors are reporting values; the CCS811 sensor will not report back immediately
esphome:
name: outdoor-multi-sensor
esp32:
board: esp32-c3-devkitm-1
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "YOUR_SUPER_SECRET_ENCRYPTION_PASSWORD"
ota:
password: "ddf5cdcd1d61a88a793a8671a40c2fa1"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Outdoor-Multi-Sensor"
password: "YOUR_SECRET_HOTSPOT_PASSWORD"
i2c:
sda: 5
scl: 6
scan: true
id: bus_a
# We need to use globals to share sensor state without circular references.
globals:
- id: temperature
type: double
restore_value: no
initial_value: 'NAN'
- id: pressure
type: double
restore_value: no
initial_value: 'NAN'
- id: humidity
type: double
restore_value: no
initial_value: 'NAN'
# Example configuration entry
sensor:
- platform: ccs811
eco2:
name: "CCS811 eCO2 Value"
tvoc:
name: "CCS811 Total Volatile Organic Compound"
address: 0x5B
update_interval: 60s
- platform: template
name: "Dew Point Temperature"
id: dewpoint_temperature
filters:
- lambda: |-
return (243.5*(log(id(humidity)/100)+((17.67 * x)/
(243.5 + x)))/(17.67-log(id(humidity)/100)-
((17.67 * x)/(243.5 + x))));
icon: 'mdi:thermometer-alert'
unit_of_measurement: °C
update_interval: never
- platform: template
name: "Sea Level Pressure"
id: sealevel_pressure
filters:
- lambda: |-
const float STANDARD_ALTITUDE = 34.0; // in meters, see note
return x / powf(1 - ((0.0065 * STANDARD_ALTITUDE) /
(id(temperature) + (0.0065 * STANDARD_ALTITUDE) + 273.15)), 5.257); // in hPa
unit_of_measurement: 'hPa'
update_interval: never
- platform: template
name: "Absolute Humidity"
id: absolute_humidity
filters:
- lambda: |-
const float mw = 18.01534; // molar mass of water g/mol
const float r = 8.31447215; // Universal gas constant J/mol/K
return (6.112 * powf(2.718281828, (17.67 * id(temperature)) /
(id(temperature) + 243.5)) * x * mw) /
((273.15 + id(temperature)) * r); // in grams/m^3
accuracy_decimals: 2
icon: 'mdi:water'
unit_of_measurement: 'g/m³'
update_interval: never
- platform: bme280
temperature:
name: "Temperature"
id: bme280_temperature
oversampling: 4x
on_value:
then:
- lambda: |-
id(temperature) = x;
pressure:
name: "Pressure"
id: bme280_pressure
oversampling: 4x
on_value:
then:
- lambda: |-
id(pressure) = x;
humidity:
name: "Humidity"
id: bme280_humidity
oversampling: 4x
on_value:
then:
- lambda: |-
id(humidity) = x;
id(dewpoint_temperature).publish_state(id(temperature));
id(sealevel_pressure).publish_state(id(pressure));
id(absolute_humidity).publish_state(id(humidity));
address: 0x77
update_interval: 60s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment