mlx90614

bradzilla84/mlx90614-ir-temp-sensor/mlx90614

This is a library example for the MLX90614 i2c Temp Sensor.
mlx90614
@/mlx90614
This is a library example for the MLX90614 i2c Temp Sensor.
INITpulse
Get Reading
mlx90614
AmbientTempC
ObjectTempC
INIT
ObjectTempCnumber
AmbientTempCnumber
To use the node in your project you should have the bradzilla84/mlx90614-ir-temp-sensor 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 require "https://github.com/adafruit/Adafruit-MLX90614-Library"
{{#global}}
#include <Adafruit_MLX90614.h>
{{/global}}


struct State {
    uint8_t mem[sizeof(Adafruit_MLX90614)];
};

// Define our custom type as a pointer on the class instance.
using Type = Adafruit_MLX90614*;

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    // It should be evaluated only once on the first (setup) transaction
    if (isSettingUp()){
    auto state = getState(ctx);
    Type MLX90614 = new (state->mem) Adafruit_MLX90614();
    MLX90614->begin();
    delay(100);
    }

    if (isInputDirty<input_INIT>(ctx)){
    auto state = getState(ctx);
    auto MLX90614 = reinterpret_cast<Adafruit_MLX90614*>(state->mem);
    emitValue<output_AmbientTempC>(ctx, MLX90614->readAmbientTempC());
    emitValue<output_ObjectTempC>(ctx, MLX90614->readObjectTempC());
    }
}