mlx90614

wayland/mlx90614/mlx90614

MLX90614 temperature sensor.
mlx90614
@/mlx90614
MLX90614 temperature sensor.
ADDRbyte
I²C address of MLX90614 device.
UPDpulse
Update. Trigger a reading.
mlx90614
ADDR
UPD
AmbC
ObjC
DONE
DONEpulse
Pulse on read.
ObjCnumber
Temperature of the object in degrees Celsius.
AmbCnumber
Ambient temperature in degrees Celsius.
To use the node in your project you should have the wayland/mlx90614 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

// Tell XOD where it could download the library:
#pragma XOD require "https://github.com/adafruit/Adafruit-MLX90614-Library"

//Include C++ libraries
#include <Wire.h>
#include <Adafruit_MLX90614.h>

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

    uint8_t mem[sizeof(Adafruit_MLX90614)];
    
    void evaluate(Context ctx) {

        if (isSettingUp()) {
           auto address = getValue<input_ADDR>(ctx);
           Type sensor = new (mem) Adafruit_MLX90614(address);
            if (!sensor->begin()) {
                raiseError(ctx);
                return;
            }
        }

        if (isInputDirty<input_UPD>(ctx)) {
            auto sensor = reinterpret_cast<Adafruit_MLX90614*>(mem);
            emitValue<output_AmbC>(ctx, sensor->readAmbientTempC());
            emitValue<output_ObjC>(ctx, sensor->readObjectTempC());
            emitValue<output_DONE>(ctx, 1);
        }
    }
}