ESP8266 Multi Sensor BME280 (battery powerd) - T, Humidity and hPa, incl. Code

I started my Home Assistant instalation a few day ago and now added these sensors to it (will make a window reed…
9
40
0
1284
updated February 19, 2022

Description

PDF

I started my Home Assistant instalation a few day ago and now added these sensors to it (will make a window reed contact next on the same base).

The ESP ist running on the ESPhome software (you can find a good guide in how to wire up the esp12 here - http://domoticx.com/esp8266-wifi-esp-12-module-aansluiten/). For the deep sleep mode you need to connect the GPIO16 pin to reset. Otherwise the ESP will not wake up.

I'm using the following code in ESPhome - for the first test you can delete the deep sleep lines at the end.

With one meassurement every 10min. it should run for at least 6 month on two AA Eneloops. The ESP cunsumes ~70mA when active and 0,017mA when in deep sleep.

Right now I'm waiting for the 5mm nickel stripes for proper battery contacts.

esphomeyaml:

name: bme280

platform: ESP8266

board: esp12e

wifi:

ssid: 'XXXXXXXXXXXXXXX'

password: 'XXXXXXXXXXXXXXX'

manual_ip:

static_ip: 192.168.0.23

gateway: 192.168.0.1

subnet: 255.255.255.0 logger:

api:

ota:

i2c:

sda: 4

scl: 5

scan: False

sensor:

  • platform: bme280

temperature:

name: "BME280 Temperature"

id: bme280_temperature

pressure:

name: "BME280 Pressure"

id: bme280_pressure

humidity:

name: "BME280 Realtive Humidity"

id: bme280_humidity

address: 0x76

iir_filter: 16x

update_interval: 1s

  • platform: template

name: "Altitude"

lambda: |-

const float STANDARD_SEA_LEVEL_PRESSURE = 1013.25; //in hPa, see note

return ((id(bme280_temperature).state + 273.15) / 0.0065)* (powf((STANDARD_SEA_LEVEL_PRESSURE / id(bme280_pressure).state), 0.190234) - 1); // in meter

update_interval: 1s

  • platform: template

name: "Absolute Humidity"

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.112powf(2.718281828, (17.67 id(bme280_temperature).state) / (id(bme280_temperature).state + 243.5))id(bme280_humidity).state mw) / ((273.15 + id(bme280_temperature).state)* r); // in grams/m^3

update_interval: 1s

  • platform: adc

pin: VCC

name: "ESP voltage"

update_interval: 1s

deep_sleep:

run_duration: 3s

sleep_duration: 600s

Category: Household

Tags



Model origin

The author marked this model as their own original creation. Imported from Thingiverse.

License