get-temperature

bradzilla84/x2125/get-temperature

Returns floating point number of the temperature in Celsius as reported by the MX2125 chip. The formula used is calculated for use with the ADC bit width of an Arduino UNO and will need to be changed if your model is different. Note that this seems to fluctuate quite a bit, but should give an idea as to the approximate operating temperature...
get-temperature
@/get-temperature
Returns floating point number of the temperature in Celsius as reported by the MX2125 chip. The formula used is calculated for use with the ADC bit width of an Arduino UNO and will need to be changed if your model is different. Note that this seems to fluctuate quite a bit, but should give an idea as to the approximate operating temperature...
IN@/device-mx2125
Input from Device Block.
INITpulse
Get Value
get-temperature
IN
TempC
TempF
OK
INIT
OKpulse
Update Completed OK
TempFnumber
Temperature Sensor Value in F
TempCnumber
Temperature Sensor Value in C
To use the node in your project you should have the bradzilla84/x2125 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

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    // The node responds only if there is an input pulse
    if (!isInputDirty<input_INIT>(ctx)){
        return;}

    // Get a pointer to the class instance
    auto Accelerometer = getValue<input_IN>(ctx);

    auto tempc = Accelerometer->mx_temperature();
    auto tempf = (Accelerometer->mx_temperature()* 9/5 + 32);

    emitValue<output_TempC>(ctx, tempc);
    emitValue<output_TempF>(ctx, tempf);

    emitValue<output_OK>(ctx, 1);
}