scd4x: add support for SCD41 single-shot measurements

I have a SCD41, and would like to use it for single shot measurements
instead of "low power periodic" measurements to achieve much lower
average current consumption.
This commit is contained in:
Ayke van Laethem
2025-11-28 10:32:46 +01:00
committed by Ron Evans
parent fab688a701
commit 9ed648f4a5
2 changed files with 8 additions and 0 deletions
+1
View File
@@ -22,4 +22,5 @@ const (
CmdStartLowPowerPeriodicMeasurement = 0x21AC
CmdStartPeriodicMeasurement = 0x21B1
CmdStopPeriodicMeasurement = 0x3F86
CmdMeasureSingleShot = 0x219D
)
+7
View File
@@ -82,6 +82,13 @@ func (d *Device) StartLowPowerPeriodicMeasurement() error {
return d.sendCommand(CmdStartLowPowerPeriodicMeasurement)
}
// MeasureSingleShot starts a single measurement cycle (SCD41 only). After this
// command is complete, the caller should wait for 5000ms before trying to read
// the result.
func (d *Device) MeasureSingleShot() error {
return d.sendCommand(CmdMeasureSingleShot)
}
// ReadData reads the data from the sensor and caches it.
func (d *Device) ReadData() error {
if err := d.sendCommandWithResult(CmdReadMeasurement, d.rx[0:9]); err != nil {