scdx

antoniorrg/scd4x/scdx

No description
scdx
@/scdx
IN@/scd4x-device
Connect to scd4x-device
UPDpulse
Updates the node.
scdx
IN
UPD
CO2
Temperature
Humidity
DONE
DONEpulse
Outputs 1 when the node has been executed
Humiditynumber
Outputs environmental humidity (%RH).
Temperaturenumber
Outputs environmental temperature (in oC).
CO2number
Outputs CO2 gas concentration (in ppm).
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);
  }

        
    }
}