Read sensor output. The measurement data can only be read out once per signal update interval as the buffer is emptied upon read-out. This command is only available in measurement mode.
read-measurement
@/read-measurement
Read sensor output. The measurement data can only be read out once per signal update interval as the buffer is emptied upon read-out. This command is only available in measurement mode.
DEV@/scd4x-device
An SCD4X device.
UPDpulse
Update.
OKpulse
Pulse on successfully reading measurement data.
RHnumber
Relative humidity (%).
Tempnumber
Temperature in °C
CO2number
CO₂ concentration in ppm.
To use the node in your project you should have the wayland/scd4x-co2-rh-temp 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 evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD
node {
void evaluate(Context ctx) {
// The node responds only if there is an input pulse
if (!isInputDirty<input_UPD>(ctx))
return;
auto sensor = getValue<input_DEV>(ctx);
uint16_t co2 = 0;
float temperature = 0.0f;
float humidity = 0.0f;
auto sensorError = sensor->readMeasurement(co2, temperature, humidity);
if (sensorError) {
raiseError(ctx);
return;
}
emitValue<output_CO2>(ctx, co2);
emitValue<output_Temp>(ctx, temperature);
emitValue<output_RH>(ctx, humidity);
emitValue<output_OK>(ctx, 1);
}
}