compensate-temp

denis-nabatchikov/bme280/compensate-temp

No description
compensate-temp
@/compensate-temp
adc_Tnumber
dT1number
dT2number
dT3number
compensate-temp
adc_T
dT1
dT2
dT3
t_FINE
TEMP
DONE
DONEpulse
TEMPnumber
t_FINEnumber
To use the node in your project you should have the denis-nabatchikov/bme280 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

node {
    void evaluate(Context ctx) {
        int32_t adc_T = getValue<input_adc_T>(ctx);
        uint16_t dig_T1 = getValue<input_dT1>(ctx);
        int16_t dig_T2 = getValue<input_dT2>(ctx);
        int16_t dig_T3 = getValue<input_dT3>(ctx);
        int32_t var1, var2;
        int64_t t_fine;

        var1 = ((((adc_T >> 3) - ((int32_t)dig_T1 << 1))) * ((int32_t)dig_T2)) >> 11;

        var2 = (((((adc_T >> 4) - ((int32_t)dig_T1)) * ((adc_T >> 4) - ((int32_t)dig_T1))) >> 12) * ((int32_t)dig_T3)) >> 14;

        t_fine = var1 + var2;

        float T = ((t_fine * 5 + 128) >> 8) / 100.0;

        emitValue<output_t_FINE>(ctx, t_fine);
        emitValue<output_TEMP>(ctx, T);
        emitValue<output_DONE>(ctx, true);
    }
}