-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BME280 environment cookbook entry #107
Conversation
new cookbook entery fixing this issue: #89
update_interval: 15s | ||
- platform: template | ||
name: "Altitude" | ||
lambda: >- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use lambda: |-
(it's safer for C++; I know the docs recommended >-
, but that has been fixed in the edge version)
- id: standard_sea_level_pressure_hpa | ||
type: float | ||
restore_state: no | ||
initial_value: '1013.25' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use a global here? Globals have quite a overhead (well not too big, but certainly more than local variables). I think it would be simpler just to do something like this:
- platform: template
# ...
lambda: |-
float STANDARD_SEA_LEVEL_PRESSURE = 1013.25; // in hPa
return ((id(bme280_temperature).state + 273.15) / 0.0065) * ((powf(id(standard_sea_level_pressure) / id(bme280_pressure).state), 0.190234) - 1);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was that this can be replaced by an Mqtt entry fetching the standard sea level pressure real time from either a stationary sensor in your network, or the web (via HA or something). I did not yet wrote that part as it involves a lot more (Mqtt, ha, etc).
The first block of code (``globals``) contains the variable standard sea level pressure in hPa, which you should fill in for your location. | ||
|
||
The second block ``sensor`` starts with the normal bme280 sensor components ``temperature``, ``pressure``, and ``humidity`` with each their own id. | ||
After the bme280 sensor, a :doc:`</esphomeyaml/components/sensor/template>` is defined to calculate the altitude in a lambda. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:doc:
/esphomeyaml/components/sensor/template- remove the
<>`, otherwise the link text is empty.
------------------- | ||
|
||
- `Relative humidity calculations <https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/>` | ||
- `Altitude calculation <https://en.wikipedia.org/wiki/Atmospheric_pressure#Altitude_variation>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `Altitude calculation <https://en.wikipedia.org/wiki/Atmospheric_pressure#Altitude_variation>` | |
- `Altitude calculation <https://en.wikipedia.org/wiki/Atmospheric_pressure#Altitude_variation>`__ |
Formula explanation | ||
------------------- | ||
|
||
- `Relative humidity calculations <https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `Relative humidity calculations <https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/>` | |
- `Relative humidity calculations <https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/>`__ |
Fixed formatting, removed global variables as requested by OttoWinter
Yalm expamples were tested by Mihalski
Description:
New cookbook entry explaining how to get absolute humidity and altitude or sea level pressure from a BME280 sensor (or similar).
Related issue (if applicable): fixes this
Pull request in esphomeyaml with YAML changes (if applicable): none
Pull request in esphomelib with C++ framework changes (if applicable): none
Checklist:
next
is for changes and new documentation that will go public with the next esphomelib release. Fixes, changes and adjustments for the current release should be created againstcurrent
.