Skip to content

Commit 9ed648f

Browse files
aykevldeadprogram
authored andcommitted
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.
1 parent fab688a commit 9ed648f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

scd4x/registers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ const (
2222
CmdStartLowPowerPeriodicMeasurement = 0x21AC
2323
CmdStartPeriodicMeasurement = 0x21B1
2424
CmdStopPeriodicMeasurement = 0x3F86
25+
CmdMeasureSingleShot = 0x219D
2526
)

scd4x/scd4x.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ func (d *Device) StartLowPowerPeriodicMeasurement() error {
8282
return d.sendCommand(CmdStartLowPowerPeriodicMeasurement)
8383
}
8484

85+
// MeasureSingleShot starts a single measurement cycle (SCD41 only). After this
86+
// command is complete, the caller should wait for 5000ms before trying to read
87+
// the result.
88+
func (d *Device) MeasureSingleShot() error {
89+
return d.sendCommand(CmdMeasureSingleShot)
90+
}
91+
8592
// ReadData reads the data from the sensor and caches it.
8693
func (d *Device) ReadData() error {
8794
if err := d.sendCommandWithResult(CmdReadMeasurement, d.rx[0:9]); err != nil {

0 commit comments

Comments
 (0)