The MiCS-VZ-89TE is an integrated sensor board for Indoor Air Quality monitoring
MICS_VZ_89TE.h@1:59ae0741684a, 2021-05-27 (annotated)
- Committer:
- mcm
- Date:
- Thu May 27 19:18:07 2021 +0000
- Revision:
- 1:59ae0741684a
- Parent:
- 0:d7e38382ef7d
- Child:
- 2:df66ad9420a1
The header file is ready to be tested.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mcm | 1:59ae0741684a | 1 | /** |
mcm | 1:59ae0741684a | 2 | * @brief MICS_VZ_89TE.h |
mcm | 1:59ae0741684a | 3 | * @details Integrated VOC Sensor Module with CO2 equivalent. |
mcm | 1:59ae0741684a | 4 | * Header file. |
mcm | 1:59ae0741684a | 5 | * |
mcm | 1:59ae0741684a | 6 | * |
mcm | 1:59ae0741684a | 7 | * @return N/A |
mcm | 1:59ae0741684a | 8 | * |
mcm | 1:59ae0741684a | 9 | * @author Manuel Caballero |
mcm | 1:59ae0741684a | 10 | * @date 27/May/2021 |
mcm | 1:59ae0741684a | 11 | * @version 27/May/2021 The ORIGIN |
mcm | 1:59ae0741684a | 12 | * @pre N/A |
mcm | 1:59ae0741684a | 13 | * @warning N/A |
mcm | 1:59ae0741684a | 14 | * @pre This code belongs to Nimbus Centre ( http://www.nimbus.cit.ie ). |
mcm | 1:59ae0741684a | 15 | */ |
mcm | 1:59ae0741684a | 16 | #ifndef MICS_VZ_89TE_H_ |
mcm | 1:59ae0741684a | 17 | #define MICS_VZ_89TE_H_ |
mcm | 1:59ae0741684a | 18 | |
mcm | 1:59ae0741684a | 19 | #include "mbed.h" |
mcm | 1:59ae0741684a | 20 | |
mcm | 1:59ae0741684a | 21 | |
mcm | 1:59ae0741684a | 22 | /** |
mcm | 1:59ae0741684a | 23 | Example: |
mcm | 1:59ae0741684a | 24 | |
mcm | 1:59ae0741684a | 25 | @code |
mcm | 1:59ae0741684a | 26 | |
mcm | 1:59ae0741684a | 27 | @endcode |
mcm | 1:59ae0741684a | 28 | */ |
mcm | 1:59ae0741684a | 29 | |
mcm | 1:59ae0741684a | 30 | |
mcm | 1:59ae0741684a | 31 | /*! |
mcm | 1:59ae0741684a | 32 | Library for the MICS_VZ_89TE Integrated VOC Sensor Module with CO2 equivalent. |
mcm | 1:59ae0741684a | 33 | */ |
mcm | 1:59ae0741684a | 34 | class MICS_VZ_89TE |
mcm | 1:59ae0741684a | 35 | { |
mcm | 1:59ae0741684a | 36 | public: |
mcm | 1:59ae0741684a | 37 | /** |
mcm | 1:59ae0741684a | 38 | * @brief DEFAULT ADDRESS |
mcm | 1:59ae0741684a | 39 | */ |
mcm | 1:59ae0741684a | 40 | typedef enum { |
mcm | 1:59ae0741684a | 41 | MICS_VZ_89TE_ADDRESS = ( 0x70 << 1U ) /*!< I2C slave address byte, Default */ |
mcm | 1:59ae0741684a | 42 | } MICS_VZ_89TE_address_t; |
mcm | 1:59ae0741684a | 43 | |
mcm | 1:59ae0741684a | 44 | |
mcm | 1:59ae0741684a | 45 | |
mcm | 1:59ae0741684a | 46 | /** |
mcm | 1:59ae0741684a | 47 | * @brief COMMAND LIST |
mcm | 1:59ae0741684a | 48 | */ |
mcm | 1:59ae0741684a | 49 | typedef enum { |
mcm | 1:59ae0741684a | 50 | MICS_VZ_89TE_SET_PPM_CO2 = 0b00001000, /*!< To send the ppmCO2 value given by an external analyser to the VZ89TE in order to recalibrate its outputs */ |
mcm | 1:59ae0741684a | 51 | MICS_VZ_89TE_GET_STATUS = 0b00001100, /*!< This command is used to read the VZ89TE status coded on 6x bytes + 1 CRC byte */ |
mcm | 1:59ae0741684a | 52 | MICS_VZ_89TE_GET_REVISION = 0b00001101, /*!< This command will return the revision code of the module */ |
mcm | 1:59ae0741684a | 53 | MICS_VZ_89TE_GET_R0 = 0b00010000 /*!< This command is used to read the R0 (calibration) value in [kOhms] */ |
mcm | 1:59ae0741684a | 54 | } MICS_VZ_89TE_command_list_t; |
mcm | 1:59ae0741684a | 55 | |
mcm | 1:59ae0741684a | 56 | |
mcm | 1:59ae0741684a | 57 | |
mcm | 1:59ae0741684a | 58 | |
mcm | 1:59ae0741684a | 59 | |
mcm | 1:59ae0741684a | 60 | #ifndef MICS_VZ_89TE_VECTOR_STRUCT_H |
mcm | 1:59ae0741684a | 61 | #define MICS_VZ_89TE_VECTOR_STRUCT_H |
mcm | 1:59ae0741684a | 62 | /* Status command */ |
mcm | 1:59ae0741684a | 63 | typedef struct { |
mcm | 1:59ae0741684a | 64 | uint8_t d1; /*!< Raw tVOC */ |
mcm | 1:59ae0741684a | 65 | uint8_t d2; /*!< Raw CO2_equ */ |
mcm | 1:59ae0741684a | 66 | uint8_t d3; /*!< RS first byte(MSB) */ |
mcm | 1:59ae0741684a | 67 | uint8_t d4; /*!< RS second byte */ |
mcm | 1:59ae0741684a | 68 | uint8_t d5; /*!< RS third byte(LSB) */ |
mcm | 1:59ae0741684a | 69 | uint8_t d6; /*!< Status */ |
mcm | 1:59ae0741684a | 70 | uint8_t d7; /*!< CRC */ |
mcm | 1:59ae0741684a | 71 | } MICS_VZ_89TE_get_status_t; |
mcm | 1:59ae0741684a | 72 | |
mcm | 1:59ae0741684a | 73 | |
mcm | 1:59ae0741684a | 74 | /* Output values */ |
mcm | 1:59ae0741684a | 75 | typedef struct { |
mcm | 1:59ae0741684a | 76 | float tvoc; /*!< tVOC [13...242] in ppb */ |
mcm | 1:59ae0741684a | 77 | float co2_equ; /*!< CO2 equivalent [13...242] in ppm */ |
mcm | 1:59ae0741684a | 78 | uint32_t resistor; /*!< Resistor value in Ohms */ |
mcm | 1:59ae0741684a | 79 | } MICS_VZ_89TE_output_values_t; |
mcm | 1:59ae0741684a | 80 | |
mcm | 1:59ae0741684a | 81 | |
mcm | 1:59ae0741684a | 82 | /* Revision */ |
mcm | 1:59ae0741684a | 83 | typedef struct { |
mcm | 1:59ae0741684a | 84 | uint8_t year; /*!< Year */ |
mcm | 1:59ae0741684a | 85 | uint8_t month; /*!< Month */ |
mcm | 1:59ae0741684a | 86 | uint8_t day; /*!< Day */ |
mcm | 1:59ae0741684a | 87 | uint8_t ascii_code; /*!< ASCII code for a charter */ |
mcm | 1:59ae0741684a | 88 | uint8_t crc; /*!< CRC */ |
mcm | 1:59ae0741684a | 89 | } MICS_VZ_89TE_revision_t; |
mcm | 1:59ae0741684a | 90 | |
mcm | 1:59ae0741684a | 91 | |
mcm | 1:59ae0741684a | 92 | /* R0: Raw data */ |
mcm | 1:59ae0741684a | 93 | typedef struct { |
mcm | 1:59ae0741684a | 94 | uint8_t r0_lsb; /*!< R0 LSB */ |
mcm | 1:59ae0741684a | 95 | uint8_t r0_msb; /*!< R0 MSB */ |
mcm | 1:59ae0741684a | 96 | uint8_t crc; /*!< CRC */ |
mcm | 1:59ae0741684a | 97 | } MICS_VZ_89TE_r0_t; |
mcm | 1:59ae0741684a | 98 | |
mcm | 1:59ae0741684a | 99 | |
mcm | 1:59ae0741684a | 100 | |
mcm | 1:59ae0741684a | 101 | /* USER: User's global variables */ |
mcm | 1:59ae0741684a | 102 | typedef struct { |
mcm | 1:59ae0741684a | 103 | /* Output */ |
mcm | 1:59ae0741684a | 104 | MICS_VZ_89TE_get_status_t status; /*!< Raw values: tVOC, CO2_equ and Resistor */ |
mcm | 1:59ae0741684a | 105 | MICS_VZ_89TE_output_values_t values; /*!< Output values: tVOC, CO2_equ and Resistor */ |
mcm | 1:59ae0741684a | 106 | |
mcm | 1:59ae0741684a | 107 | |
mcm | 1:59ae0741684a | 108 | /* Calibration */ |
mcm | 1:59ae0741684a | 109 | MICS_VZ_89TE_r0_t r0_raw; /*!< R0 calibration raw value */ |
mcm | 1:59ae0741684a | 110 | uint16_t r0; /*!< R0 calibration value in kOhms */ |
mcm | 1:59ae0741684a | 111 | |
mcm | 1:59ae0741684a | 112 | |
mcm | 1:59ae0741684a | 113 | /* Device identification */ |
mcm | 1:59ae0741684a | 114 | MICS_VZ_89TE_revision_t device; /*!< Device. The revision code of the module */ |
mcm | 1:59ae0741684a | 115 | } MICS_VZ_89TE_data_t; |
mcm | 1:59ae0741684a | 116 | #endif |
mcm | 1:59ae0741684a | 117 | |
mcm | 1:59ae0741684a | 118 | |
mcm | 1:59ae0741684a | 119 | |
mcm | 1:59ae0741684a | 120 | |
mcm | 1:59ae0741684a | 121 | /** |
mcm | 1:59ae0741684a | 122 | * @brief INTERNAL CONSTANTS |
mcm | 1:59ae0741684a | 123 | */ |
mcm | 1:59ae0741684a | 124 | typedef enum { |
mcm | 1:59ae0741684a | 125 | MICS_VZ_89TE_SUCCESS = 0, |
mcm | 1:59ae0741684a | 126 | MICS_VZ_89TE_FAILURE = 1, |
mcm | 1:59ae0741684a | 127 | MICS_VZ_89TE_DATA_CORRUPTED = 2, |
mcm | 1:59ae0741684a | 128 | I2C_SUCCESS = 0 |
mcm | 1:59ae0741684a | 129 | } MICS_VZ_89TE_status_t; |
mcm | 1:59ae0741684a | 130 | |
mcm | 1:59ae0741684a | 131 | |
mcm | 1:59ae0741684a | 132 | |
mcm | 1:59ae0741684a | 133 | /** |
mcm | 1:59ae0741684a | 134 | * @brief FUNCTION PROTOTYPES |
mcm | 1:59ae0741684a | 135 | */ |
mcm | 1:59ae0741684a | 136 | /** Create an MICS_VZ_89TE object connected to the specified I2C pins. |
mcm | 1:59ae0741684a | 137 | * |
mcm | 1:59ae0741684a | 138 | * @param sda I2C data pin |
mcm | 1:59ae0741684a | 139 | * @param scl I2C clock pin |
mcm | 1:59ae0741684a | 140 | * @param addr I2C slave address |
mcm | 1:59ae0741684a | 141 | * @param freq I2C frequency in Hz. |
mcm | 1:59ae0741684a | 142 | */ |
mcm | 1:59ae0741684a | 143 | MICS_VZ_89TE ( PinName sda, PinName scl, uint32_t addr, uint32_t freq ); |
mcm | 1:59ae0741684a | 144 | |
mcm | 1:59ae0741684a | 145 | /** Delete MICS_VZ_89TE object. |
mcm | 1:59ae0741684a | 146 | */ |
mcm | 1:59ae0741684a | 147 | ~MICS_VZ_89TE(); |
mcm | 1:59ae0741684a | 148 | |
mcm | 1:59ae0741684a | 149 | /** It triggers the STATUS command. |
mcm | 1:59ae0741684a | 150 | */ |
mcm | 1:59ae0741684a | 151 | MICS_VZ_89TE_status_t MICS_VZ_89TE_TriggersStatus ( void ); |
mcm | 1:59ae0741684a | 152 | |
mcm | 1:59ae0741684a | 153 | /** It gets all the raw values. |
mcm | 1:59ae0741684a | 154 | */ |
mcm | 1:59ae0741684a | 155 | MICS_VZ_89TE_status_t MICS_VZ_89TE_GetStatus ( MICS_VZ_89TE_get_status_t* status ); |
mcm | 1:59ae0741684a | 156 | |
mcm | 1:59ae0741684a | 157 | /** It gets all the values: tVOC, CO2_equ and Resistor. |
mcm | 1:59ae0741684a | 158 | */ |
mcm | 1:59ae0741684a | 159 | MICS_VZ_89TE_status_t MICS_VZ_89TE_GetUpdateValues ( MICS_VZ_89TE_get_status_t* status, MICS_VZ_89TE_output_values_t* values ); |
mcm | 1:59ae0741684a | 160 | |
mcm | 1:59ae0741684a | 161 | /** It triggers the Revsion command. |
mcm | 1:59ae0741684a | 162 | */ |
mcm | 1:59ae0741684a | 163 | MICS_VZ_89TE_status_t MICS_VZ_89TE_TriggersRevision ( void ); |
mcm | 1:59ae0741684a | 164 | |
mcm | 1:59ae0741684a | 165 | /** It gets Revision values. |
mcm | 1:59ae0741684a | 166 | */ |
mcm | 1:59ae0741684a | 167 | MICS_VZ_89TE_status_t MICS_VZ_89TE_GetRevision ( MICS_VZ_89TE_revision_t* revision ); |
mcm | 1:59ae0741684a | 168 | |
mcm | 1:59ae0741684a | 169 | /** It triggers the R0 command. |
mcm | 1:59ae0741684a | 170 | */ |
mcm | 1:59ae0741684a | 171 | MICS_VZ_89TE_status_t MICS_VZ_89TE_TriggersR0 ( void ); |
mcm | 1:59ae0741684a | 172 | |
mcm | 1:59ae0741684a | 173 | /** It gets R0 value. |
mcm | 1:59ae0741684a | 174 | */ |
mcm | 1:59ae0741684a | 175 | MICS_VZ_89TE_status_t MICS_VZ_89TE_GetRawR0 ( MICS_VZ_89TE_r0_t* rawR0 ); |
mcm | 1:59ae0741684a | 176 | |
mcm | 1:59ae0741684a | 177 | /** It gets R0 value (in kOhms). |
mcm | 1:59ae0741684a | 178 | */ |
mcm | 1:59ae0741684a | 179 | MICS_VZ_89TE_status_t MICS_VZ_89TE_GetR0 ( MICS_VZ_89TE_r0_t* rawR0, uint16_t* r0 ); |
mcm | 1:59ae0741684a | 180 | |
mcm | 1:59ae0741684a | 181 | |
mcm | 1:59ae0741684a | 182 | |
mcm | 1:59ae0741684a | 183 | private: |
mcm | 1:59ae0741684a | 184 | /** It gets the CRC byte. |
mcm | 1:59ae0741684a | 185 | */ |
mcm | 1:59ae0741684a | 186 | uint8_t MICS_VZ_89TE_GetCRC ( uint8_t* buffer, uint8_t size ); |
mcm | 1:59ae0741684a | 187 | |
mcm | 1:59ae0741684a | 188 | I2C _i2c; |
mcm | 1:59ae0741684a | 189 | uint32_t _MICS_VZ_89TE_Addr; |
mcm | 1:59ae0741684a | 190 | }; |
mcm | 1:59ae0741684a | 191 | |
mcm | 1:59ae0741684a | 192 | #endif /* MICS_VZ_89TE_H */ |