tc74

hussainfawzi/tc74-temp-sensor/tc74

No description
tc74
@/tc74
ADDRbyte
Device address on I2C bus
UPDATEpulse
Feed a pulse signal to get temperature reading.
tc74
TEMP
ERROR
DONE
ADDR
UPDATE
DONEpulse
Spits a pulse when done.
ERRORboolean
Spits logic high when failed communicating with the sensor through I2C bus.
TEMPnumber
Spits the temperature in degrees C
To use the node in your project you should have the hussainfawzi/tc74-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/Mario-H/TC74_I2C"

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPDATE
#pragma XOD error_raise enable

{{#global}}
#include <Wire.h>
#include <TC74_I2C.h>
{{/global}}

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    if (!isInputDirty<input_UPDATE>(ctx))
        return;
    emitValue<output_ERROR>(ctx, 0);
    Number address = getValue<input_ADDR>(ctx);
    TC74_I2C TC74(address);
    TC74.Init();
    TC74.NoPowersave();
    int temperature;
    temperature = TC74.ReadTemp();
    TC74.Powersave();
    if(temperature==128){temperature=0; emitValue<output_ERROR>(ctx, 1);}
    emitValue<output_TEMP>(ctx, temperature);
    emitValue<output_DONE>(ctx, 1);
};