To use the node in your project you should have the antoniorrg/scd4x 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 {
// Internal state variables defined at this level persists across evaluations
Number foo;
uint8_t bar = 5;
void evaluate(Context ctx) {
bar += 42;
if (isSettingUp()) {
// This run once
foo = (Number)(bar + 1);
}
if (!isInputDirty<input_UPD>(ctx))
return;
auto mySensor = getValue<input_IN>(ctx);
if (mySensor->readMeasurement()) // readMeasurement will return true when fresh data is available
{
emitValue<output_CO2>(ctx, mySensor->getCO2());
emitValue<output_Temperature>(ctx, mySensor->getTemperature());
emitValue<output_Humidity>(ctx, mySensor->getHumidity());
emitValue<output_DONE>(ctx, 1);
}
}
}