calculate-altitude

wayland/bme280-barometer/calculate-altitude

Calculate altitude from atmospheric pressure.
calculate-altitude
@/calculate-altitude
Calculate altitude from atmospheric pressure.
PRESSnumber
Ambient atmospheric pressure in Pascal.
SeaLevnumber
Atmospheric pressure at sea level in Pascal.
calculate-altitude
ALT
PRESS
SeaLev
ALTnumber
Altitude in metres.
To use the node in your project you should have the wayland/bme280-barometer library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD dirtieness disable

node {
    void evaluate(Context ctx) {
        float altitude;
        float pressure = getValue<input_PRESS>(ctx);
        float seaLevelhPa = getValue<input_SeaLev>(ctx);
        //pressure /= 100;
        altitude = 44330 * (1.0 - pow(pressure / seaLevelhPa, 0.1903));
        emitValue<output_ALT>(ctx, altitude);
    }
}