sensor_scd30/
device.rs

1//! Scd30 device definitions
2//!
3//! Copyright 2019 Ryan Kurte
4
5/// Scd30 default I2C address
6/// (note this is shifted left 1 bit on the wire)
7pub const DEFAULT_ADDRESS: u8 = 0x61;
8
9pub const I2C_WRITE_FLAG: u8 = 0x00;
10pub const I2C_READ_FLAG: u8 = 0x01;
11
12pub const CRC_POLY: u8 = 0x31;
13pub const CRC_INIT: u8 = 0xff;
14pub const CRC_XOR: u8 = 0x00;
15
16/// Scd30 I2C Command
17/// Command and data are big endian 16-bit unsigned integers, all Command with data are followed by a CRC-8 checksum
18#[derive(PartialEq, Clone, Debug)]
19pub enum Command {
20    /// Start continuous mode
21    /// Data is a u16 representing pressure in mBar for compensation
22    /// or zero for no pressure compensation
23    StartContinuousMode = 0x0010,
24
25    /// Stop continuous mode
26    /// No associated data or CRC
27    StopContinuousMode = 0x0104,
28
29    /// Set interval for continuous measurement mode
30    /// Data is a u16 in seconds between 2 and 1800
31    SetMeasurementInterval = 0x4600,
32
33    /// Fetch data ready status
34    /// This returns 1 if data is available in the buffer, 0 otherwise
35    GetDataReady = 0x0202,
36
37    /// Read a measurement from the buffer
38    ReadMeasurement = 0x0300,
39
40    /// Enable or Disable Automatic Self Calibration (ASC)
41    /// Data is a u16, 1 enables ASC and 0 disables ASC
42    SetAfc = 0x5306,
43
44    /// Set Forced Recalibration Value (FRC)
45    /// This is used to compensate for sensor drift when a CO2 reference value is available
46    /// Data is a u16 CO2 concentration in ppm
47    SetFrc = 0x5204,
48
49    /// Set temperature offset
50    /// Data is a uint16 in degrees celsius * 100, ie. 43 degrees -> 430u16
51    SetTempOffset = 0x5403,
52
53    /// Set altitude compensation
54    /// This allows NDIR CO2 sensing to be calibrated by altitude
55    /// Data is uint16 in meters above sea level
56    SetAltComp = 0x5102,
57
58    /// Soft Reset the device
59    /// No associated data or CRC
60    SoftReset = 0xd304,
61
62    GetFirmwareVersion = 0xD100,
63}