Skip to content
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

Merged
merged 6 commits into from
Jan 6, 2019
Merged

BME280 environment cookbook entry #107

merged 6 commits into from
Jan 6, 2019

Conversation

Mynasru
Copy link
Contributor

@Mynasru Mynasru commented Dec 18, 2018

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:

  • The documentation change has been tested and compiles correctly.
  • Branch: 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 against current.
  • Check this box if you have read, understand, comply, and agree with the Code of Conduct.

new cookbook entery fixing this issue:  #89
update_interval: 15s
- platform: template
name: "Altitude"
lambda: >-
Copy link
Member

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'
Copy link
Member

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);

Copy link
Contributor Author

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.
Copy link
Member

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>`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `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/>`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `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/>`__

esphomeyaml/cookbook/bme280_environment.rst Show resolved Hide resolved
OttoWinter and others added 5 commits December 19, 2018 11:33
Fixed formatting, removed global variables as requested by OttoWinter
Yalm expamples were tested by Mihalski
@OttoWinter OttoWinter merged commit afb30ad into esphome:next Jan 6, 2019
@Mynasru Mynasru deleted the next branch January 7, 2019 00:40
@esphome esphome locked and limited conversation to collaborators Jun 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants