Mbed library for SPS30 i2c communication (Configured to be interfaced with TresidderOS) Inherits members and methods from SensorDriver class
Diff: sps30.h
- Revision:
- 2:549bee9a4cd0
- Parent:
- 1:0078efb8903a
- Child:
- 3:adeb61dd9ceb
diff -r 0078efb8903a -r 549bee9a4cd0 sps30.h --- a/sps30.h Tue Mar 05 03:05:33 2019 +0000 +++ b/sps30.h Tue Mar 05 07:01:55 2019 +0000 @@ -1,7 +1,7 @@ #ifndef SPS30_H #define SPS30_H -#define SPS30_I2C_ADDR 0xd2 +#define SPS30_I2C_ADDR 0xd2 // left shifted by 1 bit from 0x69 #define SPS30_CMMD_STRT_MEAS 0x0010 #define SPS30_CMMD_STOP_MEAS 0x0104 @@ -16,17 +16,17 @@ #define SPS30_CMMD_READ_SERIALNBR 0xD033 #define SPS30_CMMD_READ_ARTICLECODE 0xD025 -#define SPS30_POLYNOMIAL 0x31 // P(x) = x^8 + x^5 + x^4 + 1 = 100110p01 +#define SPS30_POLYNOMIAL 0x31 // P(x) = x^8 + x^5 + x^4 + 1 = 100110p01 #define SPS30_CRC_INIT 0xff -#define SPS30_SN_SIZE 33 //size of the s/n ascii string + CRC values -#define SPS30_ACODE_SIZE 33 //size of the article code ascii string + CRC values +#define SPS30_SN_SIZE 33 // size of the s/n ascii string + CRC values +#define SPS30_ACODE_SIZE 33 // size of the article code ascii string + CRC values - /** Create SPS30 controller class - * - * @param sps30 class - * - */ +/** Create SPS30 controller class + * + * @param sps30 class + * + */ class sps30 { public: @@ -36,31 +36,26 @@ SPSnoAckERROR, //no I2C ACK error SPStimeoutERROR, //I2C timeout error SPScrcERROR, //CRC error, any - // SPScrcERRORv1, //CRC error on value 1 - // SPScrcERRORv2, //CRC error on value 2 - // SPScrcERRORv3, //CRC error on value 3 - // SPScrcERRORv4, //CRC error on value 4 - // SPScrcERRORv5, //CRC error on value 5 - // SPScrcERRORv6, //CRC error on value 6 }; - uint16_t ready; /**< 1 = ready, 0 = busy */ + uint16_t ready; /**< 1 = ready, 0 = busy */ + uint32_t clean_interval_i; /** 32 unsigned bit in seconds */ - float mass_1p0_f; /**< float of Mass Conc of PM1.0 */ - float mass_2p5_f; /**< float of Mass Conc of PM2.5 */ - float mass_4p0_f; /**< float of Mass Conc of PM4.0 */ - float mass_10p0_f; /**< float of Mass Conc of PM10 */ + float mass_1p0_f; /**< float of Mass Conc of PM1.0 */ + float mass_2p5_f; /**< float of Mass Conc of PM2.5 */ + float mass_4p0_f; /**< float of Mass Conc of PM4.0 */ + float mass_10p0_f; /**< float of Mass Conc of PM10 */ - float num_0p5_f; /**< float of Number Conc of PM0.5 */ - float num_1p0_f; /**< float of Number Conc of PM1.0 */ - float num_2p5_f; /**< float of Number Conc of PM2.5 */ - float num_4p0_f; /**< float of Number Conc of PM4.0 */ - float num_10p0_f; /**< float of Number Conc of PM10 */ + float num_0p5_f; /**< float of Number Conc of PM0.5 */ + float num_1p0_f; /**< float of Number Conc of PM1.0 */ + float num_2p5_f; /**< float of Number Conc of PM2.5 */ + float num_4p0_f; /**< float of Number Conc of PM4.0 */ + float num_10p0_f; /**< float of Number Conc of PM10 */ - float typ_pm_size_f; /**< float of Typical Particle Size */ + float typ_pm_size_f; /**< float of Typical Particle Size */ - uint8_t acode[24]; /**< Article code number?? */ - uint8_t sn[24]; /**< ASCII Serial Number */ + uint8_t acode[33]; /**< Article code number */ + uint8_t sn[33]; /**< ASCII Serial Number */ @@ -135,7 +130,7 @@ /** Get Article Code * * @param --none-- - * + * @see ASCII Article Code as acode[33] (returns all 0) * * @return enum SPSerror */ @@ -144,11 +139,38 @@ /** Get Serial Number * * @param --none-- - * @see ASCII Serial Number in scdSTR structure + * @see ASCII Serial Number as sn[33] * * @return enum SPSerror */ uint8_t getSerialNumber(); + + /** Read Auto Cleaning Interval on the SPS30 + * + * @param --none-- + * + * @return enum SPSerror + */ + uint8_t readAutoCleanInterval(); + + /** Set Auto Cleaning Interval on the SPS30 + * + * @param Auto Cleaning Interval in seconds + * default is 604800s = 1 week, 0 to disable auto clean + * + * @return enum SPSerror + */ + uint8_t setAutoCleanInterval(uint32_t set_interval = 604800); + + + /** Perform manual Fan Cleaning + * + * @param --none-- + * + * @return enum SPSerror + */ + uint8_t startFanClean(); + /** Perform a soft reset * @@ -160,6 +182,9 @@ private: char i2cBuff[60]; + + uint16_t clean_interval_m; /**< High order 16 bit word of Auto Clean Interval */ + uint16_t clean_interval_l; /**< High order 16 bit word of Auto Clean Interval */ uint16_t mass_1p0_m; /**< High order 16 bit word of Mass Conc of PM1.0 */ uint16_t mass_1p0_l; /**< Low order 16 bit word of Mass Conc of PM1.0 */ @@ -167,35 +192,35 @@ uint16_t mass_2p5_l; /**< Low order 16 bit word of Mass Conc of PM2.5 */ uint16_t mass_4p0_m; /**< High order 16 bit word of Mass Conc of PM4.0 */ uint16_t mass_4p0_l; /**< Low order 16 bit word of Mass Conc of PM4.0 */ - uint16_t mass_10p0_m; /**< High order 16 bit word of Mass Conc of PM10 */ - uint16_t mass_10p0_l; /**< Low order 16 bit word of Mass Conc of PM10 */ + uint16_t mass_10p0_m; /**< High order 16 bit word of Mass Conc of PM10 */ + uint16_t mass_10p0_l; /**< Low order 16 bit word of Mass Conc of PM10 */ - uint16_t num_0p5_m; /**< High order 16 bit word of Number Conc of PM0.5 */ - uint16_t num_0p5_l; /**< Low order 16 bit word of Number Conc of PM0.5 */ - uint16_t num_1p0_m; /**< High order 16 bit word of Number Conc of PM1.0 */ - uint16_t num_1p0_l; /**< Low order 16 bit word of Number Conc of PM1.0 */ - uint16_t num_2p5_m; /**< High order 16 bit word of Number Conc of PM2.5 */ - uint16_t num_2p5_l; /**< Low order 16 bit word of Number Conc of PM2.5 */ - uint16_t num_4p0_m; /**< High order 16 bit word of Number Conc of PM4.0 */ - uint16_t num_4p0_l; /**< Low order 16 bit word of Number Conc of PM4.0 */ + uint16_t num_0p5_m; /**< High order 16 bit word of Number Conc of PM0.5 */ + uint16_t num_0p5_l; /**< Low order 16 bit word of Number Conc of PM0.5 */ + uint16_t num_1p0_m; /**< High order 16 bit word of Number Conc of PM1.0 */ + uint16_t num_1p0_l; /**< Low order 16 bit word of Number Conc of PM1.0 */ + uint16_t num_2p5_m; /**< High order 16 bit word of Number Conc of PM2.5 */ + uint16_t num_2p5_l; /**< Low order 16 bit word of Number Conc of PM2.5 */ + uint16_t num_4p0_m; /**< High order 16 bit word of Number Conc of PM4.0 */ + uint16_t num_4p0_l; /**< Low order 16 bit word of Number Conc of PM4.0 */ uint16_t num_10p0_m; /**< High order 16 bit word of Number Conc of PM10 */ uint16_t num_10p0_l; /**< Low order 16 bit word of Number Conc of PM10 */ - uint16_t typ_pm_size_m; /**< High order 16 bit word of Typical Particle Size */ - uint16_t typ_pm_size_l; /**< Low order 16 bit word of Typical Particle Size */ + uint16_t typ_pm_size_m; /**< High order 16 bit word of Typical Particle Size */ + uint16_t typ_pm_size_l; /**< Low order 16 bit word of Typical Particle Size */ uint32_t mass_1p0_i; /**< 32 bit int of Mass Conc of PM1.0 */ uint32_t mass_2p5_i; /**< 32 bit int of Mass Conc of PM2.5 */ uint32_t mass_4p0_i; /**< 32 bit int of Mass Conc of PM4.0 */ - uint32_t mass_10p0_i; /**< 32 bit int of Mass Conc of PM10 */ + uint32_t mass_10p0_i; /**< 32 bit int of Mass Conc of PM10 */ - uint32_t num_0p5_i; /**< 32 bit int of Number Conc of PM0.5 */ - uint32_t num_1p0_i; /**< 32 bit int of Number Conc of PM1.0 */ - uint32_t num_2p5_i; /**< 32 bit int of Number Conc of PM2.5 */ - uint32_t num_4p0_i; /**< 32 bit int of Number Conc of PM4.0 */ + uint32_t num_0p5_i; /**< 32 bit int of Number Conc of PM0.5 */ + uint32_t num_1p0_i; /**< 32 bit int of Number Conc of PM1.0 */ + uint32_t num_2p5_i; /**< 32 bit int of Number Conc of PM2.5 */ + uint32_t num_4p0_i; /**< 32 bit int of Number Conc of PM4.0 */ uint32_t num_10p0_i; /**< 32 bit int of Number Conc of PM10 */ - uint32_t typ_pm_size_i; /**< 32 bit int of Typical Particle Size */ + uint32_t typ_pm_size_i; /**< 32 bit int of Typical Particle Size */ protected: I2C _i2c;