BME680 is an integrated environmental sensor developed specifically for mobile applications and wearables where size and low power consumption are key requirements.

Dependents:   Example_DS3231_test

Committer:
yangcq88517
Date:
Wed Aug 03 15:07:42 2016 +0000
Revision:
1:85088a918342
Parent:
0:c70b7ececf93
add three different mod

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yangcq88517 0:c70b7ececf93 1 #ifndef UK_AC_HERTS_SMARTLAB_BME680
yangcq88517 0:c70b7ececf93 2 #define UK_AC_HERTS_SMARTLAB_BME680
yangcq88517 0:c70b7ececf93 3
yangcq88517 0:c70b7ececf93 4 #include "mbed.h"
yangcq88517 0:c70b7ececf93 5 #include "stdint.h"
yangcq88517 0:c70b7ececf93 6
yangcq88517 0:c70b7ececf93 7 /*
yangcq88517 0:c70b7ececf93 8 * Use below macro for fixed Point Calculation
yangcq88517 0:c70b7ececf93 9 * else Floating Point calculation will be used
yangcq88517 0:c70b7ececf93 10 */
yangcq88517 0:c70b7ececf93 11 #define FIXED_POINT_COMPENSATION
yangcq88517 0:c70b7ececf93 12
yangcq88517 0:c70b7ececf93 13 // no idea what it is for
yangcq88517 1:85088a918342 14 //#define HEATER_C1_ENABLE
yangcq88517 0:c70b7ececf93 15
yangcq88517 0:c70b7ececf93 16 // Sensor Specific constants */
yangcq88517 0:c70b7ececf93 17 #define BME680_SLEEP_MODE (0x00)
yangcq88517 0:c70b7ececf93 18 #define BME680_FORCED_MODE (0x01)
yangcq88517 0:c70b7ececf93 19 #define BME680_PARALLEL_MODE (0x02)
yangcq88517 0:c70b7ececf93 20 #define BME680_SEQUENTIAL_MODE (0x03)
yangcq88517 0:c70b7ececf93 21 #define BME680_GAS_PROFILE_TEMPERATURE_MIN (200)
yangcq88517 0:c70b7ececf93 22 #define BME680_GAS_PROFILE_TEMPERATURE_MAX (400)
yangcq88517 0:c70b7ececf93 23 #define BME680_GAS_RANGE_RL_LENGTH (16)
yangcq88517 0:c70b7ececf93 24 #define BME680_SIGN_BIT_MASK (0x08)
yangcq88517 0:c70b7ececf93 25
yangcq88517 0:c70b7ececf93 26 #ifdef FIXED_POINT_COMPENSATION
yangcq88517 0:c70b7ececf93 27 //< Multiply by 1000, In order to convert float value into fixed point
yangcq88517 0:c70b7ececf93 28 #define BME680_MAX_HUMIDITY_VALUE (102400)
yangcq88517 0:c70b7ececf93 29 #define BME680_MIN_HUMIDITY_VALUE (0)
yangcq88517 0:c70b7ececf93 30 #else
yangcq88517 0:c70b7ececf93 31 #define BME680_MAX_HUMIDITY_VALUE (double)(100.0)
yangcq88517 0:c70b7ececf93 32 #define BME680_MIN_HUMIDITY_VALUE (double)(0.0)
yangcq88517 0:c70b7ececf93 33 #endif
yangcq88517 0:c70b7ececf93 34
yangcq88517 1:85088a918342 35 /**
yangcq88517 1:85088a918342 36 * !! MUST CALL init() FIRST !!
yangcq88517 1:85088a918342 37 * read the chip id and calibration data of the BME680 sensor
yangcq88517 1:85088a918342 38 * BME680 integrated environmental sensor. This API supports FIXED and FLOATING compenstion.
yangcq88517 1:85088a918342 39 * By default it supports FIXED, to use FLOATING user need to disable "FIXED_POINT_COMPENSATION" in the BME680.h file.
yangcq88517 1:85088a918342 40 */
yangcq88517 0:c70b7ececf93 41 class BME680
yangcq88517 0:c70b7ececf93 42 {
yangcq88517 0:c70b7ececf93 43 private:
yangcq88517 0:c70b7ececf93 44 static const int FREQUENCY_STANDARD = 100000;
yangcq88517 0:c70b7ececf93 45 static const int FREQUENCY_FULL = 400000;
yangcq88517 0:c70b7ececf93 46 static const int FREQUENCY_FAST = 1000000;
yangcq88517 0:c70b7ececf93 47 static const int FREQUENCY_HIGH = 3200000;
yangcq88517 0:c70b7ececf93 48
yangcq88517 0:c70b7ececf93 49 I2C _i2c_bus;
yangcq88517 0:c70b7ececf93 50 int _addr;
yangcq88517 0:c70b7ececf93 51 uint8_t data[30];
yangcq88517 0:c70b7ececf93 52
yangcq88517 0:c70b7ececf93 53 //static const double const_array1[];
yangcq88517 0:c70b7ececf93 54 //static const double const_array2[];
yangcq88517 0:c70b7ececf93 55 static const uint64_t lookup_k1_range[];
yangcq88517 0:c70b7ececf93 56 static const uint64_t lookup_k2_range[];
yangcq88517 0:c70b7ececf93 57 static const double _lookup_k1_range[];
yangcq88517 0:c70b7ececf93 58 static const double _lookup_k2_range[];
yangcq88517 0:c70b7ececf93 59
yangcq88517 0:c70b7ececf93 60 /* For Calibration Data*/
yangcq88517 0:c70b7ececf93 61 static const int DIG_T2_LSB_REG = 1;
yangcq88517 0:c70b7ececf93 62 static const int DIG_T2_MSB_REG = 2;
yangcq88517 0:c70b7ececf93 63 static const int DIG_T3_REG = 3;
yangcq88517 0:c70b7ececf93 64 static const int DIG_P1_LSB_REG = 5;
yangcq88517 0:c70b7ececf93 65 static const int DIG_P1_MSB_REG = 6;
yangcq88517 0:c70b7ececf93 66 static const int DIG_P2_LSB_REG = 7;
yangcq88517 0:c70b7ececf93 67 static const int DIG_P2_MSB_REG = 8;
yangcq88517 0:c70b7ececf93 68 static const int DIG_P3_REG = 9;
yangcq88517 0:c70b7ececf93 69 static const int DIG_P4_LSB_REG = 11;
yangcq88517 0:c70b7ececf93 70 static const int DIG_P4_MSB_REG = 12;
yangcq88517 0:c70b7ececf93 71 static const int DIG_P5_LSB_REG = 13;
yangcq88517 0:c70b7ececf93 72 static const int DIG_P5_MSB_REG = 14;
yangcq88517 0:c70b7ececf93 73 static const int DIG_P7_REG = 15;
yangcq88517 0:c70b7ececf93 74 static const int DIG_P6_REG = 16;
yangcq88517 0:c70b7ececf93 75 static const int DIG_P8_LSB_REG = 19;
yangcq88517 0:c70b7ececf93 76 static const int DIG_P8_MSB_REG = 20;
yangcq88517 0:c70b7ececf93 77 static const int DIG_P9_LSB_REG = 21;
yangcq88517 0:c70b7ececf93 78 static const int DIG_P9_MSB_REG = 22;
yangcq88517 0:c70b7ececf93 79 static const int DIG_P10_REG = 23;
yangcq88517 0:c70b7ececf93 80 static const int DIG_H2_MSB_REG = 25;
yangcq88517 0:c70b7ececf93 81 static const int DIG_H2_LSB_REG = 26;
yangcq88517 0:c70b7ececf93 82 static const int DIG_H1_LSB_REG = 26;
yangcq88517 0:c70b7ececf93 83 static const int DIG_H1_MSB_REG = 27;
yangcq88517 0:c70b7ececf93 84 static const int DIG_H3_REG = 28;
yangcq88517 0:c70b7ececf93 85 static const int DIG_H4_REG = 29;
yangcq88517 0:c70b7ececf93 86 static const int DIG_H5_REG = 30;
yangcq88517 0:c70b7ececf93 87 static const int DIG_H6_REG = 31;
yangcq88517 0:c70b7ececf93 88 static const int DIG_H7_REG = 32;
yangcq88517 0:c70b7ececf93 89 static const int DIG_T1_LSB_REG = 33;
yangcq88517 0:c70b7ececf93 90 static const int DIG_T1_MSB_REG = 34;
yangcq88517 0:c70b7ececf93 91 static const int DIG_GH2_LSB_REG = 35;
yangcq88517 0:c70b7ececf93 92 static const int DIG_GH2_MSB_REG = 36;
yangcq88517 0:c70b7ececf93 93 static const int DIG_GH1_REG = 37;
yangcq88517 0:c70b7ececf93 94 static const int DIG_GH3_REG = 38;
yangcq88517 0:c70b7ececf93 95
yangcq88517 0:c70b7ececf93 96 static const int BME680_BIT_MASK_H1_DATA = 0x0F;
yangcq88517 0:c70b7ececf93 97
yangcq88517 0:c70b7ececf93 98 int8_t par_T3;/**<calibration T3 data*/
yangcq88517 0:c70b7ececf93 99 int8_t par_P3;/**<calibration P3 data*/
yangcq88517 0:c70b7ececf93 100 int8_t par_P6;/**<calibration P6 data*/
yangcq88517 0:c70b7ececf93 101 int8_t par_P7;/**<calibration P7 data*/
yangcq88517 0:c70b7ececf93 102 uint8_t par_P10;/**<calibration P10 data*/
yangcq88517 0:c70b7ececf93 103 int8_t par_H3;/**<calibration H3 data*/
yangcq88517 0:c70b7ececf93 104 int8_t par_H4;/**<calibration H4 data*/
yangcq88517 0:c70b7ececf93 105 int8_t par_H5;/**<calibration H5 data*/
yangcq88517 0:c70b7ececf93 106 uint8_t par_H6;/**<calibration H6 data*/
yangcq88517 0:c70b7ececf93 107 int8_t par_H7;/**<calibration H7 data*/
yangcq88517 0:c70b7ececf93 108 int8_t par_GH1;/**<calibration GH1 data*/
yangcq88517 0:c70b7ececf93 109 uint8_t res_heat_range;/**<resistance calculation*/
yangcq88517 0:c70b7ececf93 110 int8_t res_heat_val; /**<correction factor*/
yangcq88517 0:c70b7ececf93 111 int8_t range_switching_error;/**<range switching error*/
yangcq88517 0:c70b7ececf93 112 int16_t par_GH2;/**<calibration GH2 data*/
yangcq88517 0:c70b7ececf93 113 uint16_t par_T1;/**<calibration T1 data*/
yangcq88517 0:c70b7ececf93 114 int16_t par_T2;/**<calibration T2 data*/
yangcq88517 0:c70b7ececf93 115 uint16_t par_P1;/**<calibration P1 data*/
yangcq88517 0:c70b7ececf93 116 int16_t par_P2;/**<calibration P2 data*/
yangcq88517 0:c70b7ececf93 117 int16_t par_P4;/**<calibration P4 data*/
yangcq88517 0:c70b7ececf93 118 int16_t par_P5;/**<calibration P5 data*/
yangcq88517 0:c70b7ececf93 119 int16_t par_P8;/**<calibration P8 data*/
yangcq88517 0:c70b7ececf93 120 int16_t par_P9;/**<calibration P9 data*/
yangcq88517 0:c70b7ececf93 121 uint16_t par_H1;/**<calibration H1 data*/
yangcq88517 0:c70b7ececf93 122 uint16_t par_H2;/**<calibration H2 data*/
yangcq88517 0:c70b7ececf93 123 int32_t t_fine;/**<calibration T_FINE data*/
yangcq88517 0:c70b7ececf93 124 int8_t par_GH3;/**<calibration GH3 data*/
yangcq88517 0:c70b7ececf93 125
yangcq88517 0:c70b7ececf93 126 void readRegister(int reg, int size = 1);
yangcq88517 0:c70b7ececf93 127
yangcq88517 0:c70b7ececf93 128 void writeRegister(int reg, int value);
yangcq88517 0:c70b7ececf93 129
yangcq88517 0:c70b7ececf93 130 public:
yangcq88517 0:c70b7ececf93 131
yangcq88517 1:85088a918342 132 /**
yangcq88517 1:85088a918342 133 * TPHG measurements are performed.
yangcq88517 1:85088a918342 134 * continuously until mode change.
yangcq88517 1:85088a918342 135 * Between each cycle, the sensor enters stand-by for a period of time according to the odr<3:0> control register.
yangcq88517 1:85088a918342 136 * Gas sensor heater only operates during gas sub-measurement.
yangcq88517 1:85088a918342 137 * 100 ms gas wait time, T:X2, P:X16, H:X1
yangcq88517 1:85088a918342 138 */
yangcq88517 0:c70b7ececf93 139 void setSequentialMode();
yangcq88517 1:85088a918342 140
yangcq88517 1:85088a918342 141 /**
yangcq88517 1:85088a918342 142 * Single TPHG cycle is performed.
yangcq88517 1:85088a918342 143 * Sensor automatically returns to sleep mode afterwards.
yangcq88517 1:85088a918342 144 * Gas sensor heater only operates during gas sub-measureme.
yangcq88517 1:85088a918342 145 */
yangcq88517 0:c70b7ececf93 146 void setForcedMode();
yangcq88517 1:85088a918342 147
yangcq88517 1:85088a918342 148 /**
yangcq88517 1:85088a918342 149 * TPHG measurements are performed continuously until mode change.
yangcq88517 1:85088a918342 150 * No stand-by occurs between consecutive TPHG cycles.
yangcq88517 1:85088a918342 151 * Gas sensor heater operates in parallel with TPH measurements.
yangcq88517 1:85088a918342 152 */
yangcq88517 0:c70b7ececf93 153 void setParallelMode();
yangcq88517 0:c70b7ececf93 154
yangcq88517 0:c70b7ececf93 155 /*
yangcq88517 0:c70b7ececf93 156 * @param sda I2C sda signal
yangcq88517 0:c70b7ececf93 157 * @param scl I2C scl signal
yangcq88517 0:c70b7ececf93 158 * @param SDO Slave address LSB (High->true, Low->false)
yangcq88517 0:c70b7ececf93 159 */
yangcq88517 0:c70b7ececf93 160 BME680(PinName sda, PinName scl, bool SDO);
yangcq88517 0:c70b7ececf93 161
yangcq88517 0:c70b7ececf93 162 /**
yangcq88517 0:c70b7ececf93 163 * !! MUST CALL THIS FIRST !!
yangcq88517 0:c70b7ececf93 164 * read the chip id and calibration data of the BME680 sensor
yangcq88517 0:c70b7ececf93 165 */
yangcq88517 0:c70b7ececf93 166 bool init();
yangcq88517 0:c70b7ececf93 167 // DATA #########################################################################
yangcq88517 0:c70b7ececf93 168
yangcq88517 0:c70b7ececf93 169 #ifdef FIXED_POINT_COMPENSATION
yangcq88517 0:c70b7ececf93 170 /**
yangcq88517 0:c70b7ececf93 171 * This function is used to convert the uncompensated
yangcq88517 0:c70b7ececf93 172 * temperature data to compensated temperature data using
yangcq88517 0:c70b7ececf93 173 * compensation formula(integer version)
yangcq88517 0:c70b7ececf93 174 * @note Returns the value in 0.01 degree Centigrade
yangcq88517 0:c70b7ececf93 175 * Output value of "5123" equals 51.23 DegC.
yangcq88517 0:c70b7ececf93 176 *
yangcq88517 0:c70b7ececf93 177 * @param field 0-2
yangcq88517 0:c70b7ececf93 178 *
yangcq88517 0:c70b7ececf93 179 * @return Returns the compensated temperature data
yangcq88517 0:c70b7ececf93 180 *
yangcq88517 0:c70b7ececf93 181 */
yangcq88517 0:c70b7ececf93 182 int32_t getCompensatedTemperature(int field = 0);
yangcq88517 0:c70b7ececf93 183
yangcq88517 0:c70b7ececf93 184 /**
yangcq88517 0:c70b7ececf93 185 * Reads actual temperature from uncompensated temperature
yangcq88517 0:c70b7ececf93 186 * @note Returns the value with 500LSB/DegC centred around 24 DegC
yangcq88517 0:c70b7ececf93 187 * output value of "5123" equals(5123/500)+24 = 34.246DegC
yangcq88517 0:c70b7ececf93 188 *
yangcq88517 0:c70b7ececf93 189 *
yangcq88517 0:c70b7ececf93 190 * @param v_uncomp_temperature_u32: value of uncompensated temperature
yangcq88517 0:c70b7ececf93 191 * @param bme680: structure pointer.
yangcq88517 0:c70b7ececf93 192 *
yangcq88517 0:c70b7ececf93 193 *
yangcq88517 0:c70b7ececf93 194 * @return Return the actual temperature as s16 output
yangcq88517 0:c70b7ececf93 195 *
yangcq88517 0:c70b7ececf93 196 */
yangcq88517 0:c70b7ececf93 197 int16_t getTemperatureInt(int field = 0);
yangcq88517 0:c70b7ececf93 198
yangcq88517 0:c70b7ececf93 199 /**
yangcq88517 0:c70b7ececf93 200 * @brief This function is used to convert the uncompensated
yangcq88517 0:c70b7ececf93 201 * humidity data to compensated humidity data using
yangcq88517 0:c70b7ececf93 202 * compensation formula(integer version)
yangcq88517 0:c70b7ececf93 203 *
yangcq88517 0:c70b7ececf93 204 * @note Returns the value in %rH as unsigned 32bit integer
yangcq88517 0:c70b7ececf93 205 * in Q22.10 format(22 integer 10 fractional bits).
yangcq88517 0:c70b7ececf93 206 * @note An output value of 42313
yangcq88517 0:c70b7ececf93 207 * represents 42313 / 1024 = 41.321 %rH
yangcq88517 0:c70b7ececf93 208 *
yangcq88517 0:c70b7ececf93 209 *
yangcq88517 0:c70b7ececf93 210 *
yangcq88517 0:c70b7ececf93 211 * @param v_uncomp_humidity_u32: value of uncompensated humidity
yangcq88517 0:c70b7ececf93 212 * @param bme680: structure pointer.
yangcq88517 0:c70b7ececf93 213 *
yangcq88517 0:c70b7ececf93 214 * @return Return the compensated humidity data
yangcq88517 0:c70b7ececf93 215 *
yangcq88517 0:c70b7ececf93 216 */
yangcq88517 0:c70b7ececf93 217 int32_t getCompensateHumidity(int field = 0);
yangcq88517 0:c70b7ececf93 218
yangcq88517 0:c70b7ececf93 219 /**
yangcq88517 0:c70b7ececf93 220 * @brief Reads actual humidity from uncompensated humidity
yangcq88517 0:c70b7ececf93 221 * @note Returns the value in %rH as unsigned 16bit integer
yangcq88517 0:c70b7ececf93 222 * @note An output value of 42313
yangcq88517 0:c70b7ececf93 223 * represents 42313/512 = 82.643 %rH
yangcq88517 0:c70b7ececf93 224 *
yangcq88517 0:c70b7ececf93 225 *
yangcq88517 0:c70b7ececf93 226 *
yangcq88517 0:c70b7ececf93 227 * @param v_uncomp_humidity_u32: value of uncompensated humidity
yangcq88517 0:c70b7ececf93 228 * @param bme680: structure pointer.
yangcq88517 0:c70b7ececf93 229 *
yangcq88517 0:c70b7ececf93 230 * @return Return the actual relative humidity output as u16
yangcq88517 0:c70b7ececf93 231 *
yangcq88517 0:c70b7ececf93 232 */
yangcq88517 0:c70b7ececf93 233 uint16_t getHumidityInt(int field = 0);
yangcq88517 0:c70b7ececf93 234
yangcq88517 0:c70b7ececf93 235 /**
yangcq88517 0:c70b7ececf93 236 * @brief This function is used to convert the uncompensated
yangcq88517 0:c70b7ececf93 237 * pressure data to compensated pressure data data using
yangcq88517 0:c70b7ececf93 238 * compensation formula(integer version)
yangcq88517 0:c70b7ececf93 239 *
yangcq88517 0:c70b7ececf93 240 * @note Returns the value in Pascal(Pa)
yangcq88517 0:c70b7ececf93 241 * Output value of "96386" equals 96386 Pa =
yangcq88517 0:c70b7ececf93 242 * 963.86 hPa = 963.86 millibar
yangcq88517 0:c70b7ececf93 243 *
yangcq88517 0:c70b7ececf93 244 *
yangcq88517 0:c70b7ececf93 245 *
yangcq88517 0:c70b7ececf93 246 * @param v_uncomp_pressure_u32 : value of uncompensated pressure
yangcq88517 0:c70b7ececf93 247 * @param bme680: structure pointer.
yangcq88517 0:c70b7ececf93 248 *
yangcq88517 0:c70b7ececf93 249 * @return Return the compensated pressure data
yangcq88517 0:c70b7ececf93 250 *
yangcq88517 0:c70b7ececf93 251 */
yangcq88517 0:c70b7ececf93 252 int32_t getCompensatePressure(int field = 0);
yangcq88517 0:c70b7ececf93 253
yangcq88517 0:c70b7ececf93 254 /**
yangcq88517 0:c70b7ececf93 255 * @brief Reads actual pressure from uncompensated pressure
yangcq88517 0:c70b7ececf93 256 * @note Returns the value in Pa.
yangcq88517 0:c70b7ececf93 257 * @note Output value of "12337434"
yangcq88517 0:c70b7ececf93 258 * @note represents 12337434 / 128 = 96386.2 Pa = 963.862 hPa
yangcq88517 0:c70b7ececf93 259 *
yangcq88517 0:c70b7ececf93 260 *
yangcq88517 0:c70b7ececf93 261 *
yangcq88517 0:c70b7ececf93 262 * @param v_uncomp_pressure_u32 : value of uncompensated pressure
yangcq88517 0:c70b7ececf93 263 * @param bme680: structure pointer.
yangcq88517 0:c70b7ececf93 264 *
yangcq88517 0:c70b7ececf93 265 * @return the actual pressure in u32
yangcq88517 0:c70b7ececf93 266 *
yangcq88517 0:c70b7ececf93 267 */
yangcq88517 0:c70b7ececf93 268 uint32_t getPressureInt(int field = 0);
yangcq88517 0:c70b7ececf93 269
yangcq88517 0:c70b7ececf93 270 /**
yangcq88517 0:c70b7ececf93 271 * @brief This function is used to convert temperature to resistance
yangcq88517 0:c70b7ececf93 272 * using the integer compensation formula
yangcq88517 0:c70b7ececf93 273 *
yangcq88517 0:c70b7ececf93 274 * @param heater_temp_u16: The value of heater temperature
yangcq88517 0:c70b7ececf93 275 * @param ambient_temp_s16: The value of ambient temperature
yangcq88517 0:c70b7ececf93 276 * @param bme680: structure pointer.
yangcq88517 0:c70b7ececf93 277 *
yangcq88517 0:c70b7ececf93 278 * @return calculated resistance from temperature
yangcq88517 0:c70b7ececf93 279 *
yangcq88517 0:c70b7ececf93 280 *
yangcq88517 0:c70b7ececf93 281 *
yangcq88517 0:c70b7ececf93 282 */
yangcq88517 0:c70b7ececf93 283 uint8_t convertTemperatureResistanceInt(uint16_t heater, int16_t ambient);
yangcq88517 0:c70b7ececf93 284
yangcq88517 0:c70b7ececf93 285
yangcq88517 0:c70b7ececf93 286 /**
yangcq88517 0:c70b7ececf93 287 * @brief This function is used to convert uncompensated gas data to
yangcq88517 0:c70b7ececf93 288 * compensated gas data using compensation formula(integer version)
yangcq88517 0:c70b7ececf93 289 *
yangcq88517 0:c70b7ececf93 290 * @param gas_adc_u16: The value of gas resistance calculated
yangcq88517 0:c70b7ececf93 291 * using temperature
yangcq88517 0:c70b7ececf93 292 * @param gas_range_u8: The value of gas range form register value
yangcq88517 0:c70b7ececf93 293 * @param bme680: structure pointer.
yangcq88517 0:c70b7ececf93 294 *
yangcq88517 0:c70b7ececf93 295 * @return calculated compensated gas from compensation formula
yangcq88517 0:c70b7ececf93 296 * @retval compensated gas data
yangcq88517 0:c70b7ececf93 297 *
yangcq88517 0:c70b7ececf93 298 *
yangcq88517 0:c70b7ececf93 299 */
yangcq88517 0:c70b7ececf93 300 int32_t getCalculateGasInt(int field = 0);
yangcq88517 0:c70b7ececf93 301
yangcq88517 0:c70b7ececf93 302 #else
yangcq88517 0:c70b7ececf93 303 /**
yangcq88517 0:c70b7ececf93 304 * This function used to convert temperature data
yangcq88517 0:c70b7ececf93 305 * to uncompensated temperature data using compensation formula
yangcq88517 0:c70b7ececf93 306 * @note returns the value in Degree centigrade
yangcq88517 0:c70b7ececf93 307 * @note Output value of "51.23" equals 51.23 DegC.
yangcq88517 0:c70b7ececf93 308 * @param field 0-2
yangcq88517 0:c70b7ececf93 309 * @return Return the actual temperature in floating point
yangcq88517 0:c70b7ececf93 310 */
yangcq88517 0:c70b7ececf93 311 double getTemperatureDouble(int field = 0);
yangcq88517 0:c70b7ececf93 312
yangcq88517 0:c70b7ececf93 313 /**
yangcq88517 0:c70b7ececf93 314 * @brief This function is used to convert the uncompensated
yangcq88517 0:c70b7ececf93 315 * humidity data to compensated humidity data data using
yangcq88517 0:c70b7ececf93 316 * compensation formula
yangcq88517 0:c70b7ececf93 317 * @note returns the value in relative humidity (%rH)
yangcq88517 0:c70b7ececf93 318 * @note Output value of "42.12" equals 42.12 %rH
yangcq88517 0:c70b7ececf93 319 *
yangcq88517 0:c70b7ececf93 320 * @param uncom_humidity_u16 : value of uncompensated humidity
yangcq88517 0:c70b7ececf93 321 * @param comp_temperature : value of compensated temperature
yangcq88517 0:c70b7ececf93 322 * @param bme680: structure pointer.
yangcq88517 0:c70b7ececf93 323 *
yangcq88517 0:c70b7ececf93 324 *
yangcq88517 0:c70b7ececf93 325 * @return Return the compensated humidity data in floating point
yangcq88517 0:c70b7ececf93 326 *
yangcq88517 0:c70b7ececf93 327 */
yangcq88517 0:c70b7ececf93 328 double getHumidityDouble(int field = 0);
yangcq88517 0:c70b7ececf93 329
yangcq88517 0:c70b7ececf93 330 /**
yangcq88517 0:c70b7ececf93 331 * @brief This function is used to convert the uncompensated
yangcq88517 0:c70b7ececf93 332 * pressure data to compensated data using compensation formula
yangcq88517 0:c70b7ececf93 333 * @note Returns pressure in Pa as double.
yangcq88517 0:c70b7ececf93 334 * @note Output value of "96386.2"
yangcq88517 0:c70b7ececf93 335 * equals 96386.2 Pa = 963.862 hPa.
yangcq88517 0:c70b7ececf93 336 *
yangcq88517 0:c70b7ececf93 337 *
yangcq88517 0:c70b7ececf93 338 * @param uncom_pressure_u32 : value of uncompensated pressure
yangcq88517 0:c70b7ececf93 339 * @param bme680: structure pointer.
yangcq88517 0:c70b7ececf93 340 *
yangcq88517 0:c70b7ececf93 341 * @return Return the compensated pressure data in floating point
yangcq88517 0:c70b7ececf93 342 *
yangcq88517 0:c70b7ececf93 343 */
yangcq88517 0:c70b7ececf93 344 double getPressureDouble(int field = 0);
yangcq88517 0:c70b7ececf93 345
yangcq88517 0:c70b7ececf93 346 /**
yangcq88517 0:c70b7ececf93 347 * @brief This function is used to convert temperature to resistance
yangcq88517 0:c70b7ececf93 348 * using the compensation formula
yangcq88517 0:c70b7ececf93 349 *
yangcq88517 0:c70b7ececf93 350 * @param heater_temp_u16: The value of heater temperature
yangcq88517 0:c70b7ececf93 351 * @param ambient_temp_s16: The value of ambient temperature
yangcq88517 0:c70b7ececf93 352 * @param bme680: structure pointer.
yangcq88517 0:c70b7ececf93 353 *
yangcq88517 0:c70b7ececf93 354 * @return calculated resistance from temperature
yangcq88517 0:c70b7ececf93 355 *
yangcq88517 0:c70b7ececf93 356 *
yangcq88517 0:c70b7ececf93 357 *
yangcq88517 0:c70b7ececf93 358 */
yangcq88517 0:c70b7ececf93 359 double convertTemperatureResistanceDouble(uint16_t heater, int16_t ambient);
yangcq88517 0:c70b7ececf93 360
yangcq88517 0:c70b7ececf93 361 /**
yangcq88517 0:c70b7ececf93 362 * @brief This function is used to convert uncompensated gas data to
yangcq88517 0:c70b7ececf93 363 * compensated gas data using compensation formula
yangcq88517 0:c70b7ececf93 364 *
yangcq88517 0:c70b7ececf93 365 * @param gas_adc_u16: The value of gas resistance calculated
yangcq88517 0:c70b7ececf93 366 * using temperature
yangcq88517 0:c70b7ececf93 367 * @param gas_range_u8: The value of gas range form register value
yangcq88517 0:c70b7ececf93 368 * @param bme680: structure pointer.
yangcq88517 0:c70b7ececf93 369 *
yangcq88517 0:c70b7ececf93 370 * @return calculated compensated gas from compensation formula
yangcq88517 0:c70b7ececf93 371 * @retval compensated gas
yangcq88517 0:c70b7ececf93 372 *
yangcq88517 0:c70b7ececf93 373 *
yangcq88517 0:c70b7ececf93 374 */
yangcq88517 0:c70b7ececf93 375 double getCalculateGasDouble(int field = 0);
yangcq88517 0:c70b7ececf93 376 #endif
yangcq88517 0:c70b7ececf93 377
yangcq88517 0:c70b7ececf93 378
yangcq88517 0:c70b7ececf93 379 /**
yangcq88517 0:c70b7ececf93 380 * [press_msb] [press_lsb] [press_xlsb]
yangcq88517 0:c70b7ececf93 381 * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
yangcq88517 0:c70b7ececf93 382 * named field0, field1, and field2. The data fields are updated sequentially and always results of
yangcq88517 0:c70b7ececf93 383 * the three latest measurements are available for the user; if the last but one conversion was written
yangcq88517 0:c70b7ececf93 384 * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
yangcq88517 0:c70b7ececf93 385 * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
yangcq88517 0:c70b7ececf93 386 * data if update of the data registers comes simultaneously with serial interface reading out.
yangcq88517 0:c70b7ececf93 387 * Note: Only field0 will be updated in forced mode
yangcq88517 0:c70b7ececf93 388 * @param field 0-2
yangcq88517 0:c70b7ececf93 389 */
yangcq88517 1:85088a918342 390 uint32_t getUncompensatedPressureData(int field = 0);
yangcq88517 0:c70b7ececf93 391
yangcq88517 0:c70b7ececf93 392 /**
yangcq88517 0:c70b7ececf93 393 * [temp1_msb] [temp1_lsb] [temp1_xlsb]
yangcq88517 0:c70b7ececf93 394 * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
yangcq88517 0:c70b7ececf93 395 * named field0, field1, and field2. The data fields are updated sequentially and always results of
yangcq88517 0:c70b7ececf93 396 * the three latest measurements are available for the user; if the last but one conversion was written
yangcq88517 0:c70b7ececf93 397 * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
yangcq88517 0:c70b7ececf93 398 * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
yangcq88517 0:c70b7ececf93 399 * data if update of the data registers comes simultaneously with serial interface reading out.
yangcq88517 0:c70b7ececf93 400 * Note: Only field0 will be updated in forced mode
yangcq88517 0:c70b7ececf93 401 * @param field 0-2
yangcq88517 0:c70b7ececf93 402 */
yangcq88517 1:85088a918342 403 uint32_t getUncompensatedTemp1Data(int field = 0);
yangcq88517 0:c70b7ececf93 404
yangcq88517 0:c70b7ececf93 405 /**
yangcq88517 0:c70b7ececf93 406 * [hum_msb] [hum_lsb]
yangcq88517 0:c70b7ececf93 407 * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
yangcq88517 0:c70b7ececf93 408 * named field0, field1, and field2. The data fields are updated sequentially and always results of
yangcq88517 0:c70b7ececf93 409 * the three latest measurements are available for the user; if the last but one conversion was written
yangcq88517 0:c70b7ececf93 410 * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
yangcq88517 0:c70b7ececf93 411 * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
yangcq88517 0:c70b7ececf93 412 * data if update of the data registers comes simultaneously with serial interface reading out.
yangcq88517 0:c70b7ececf93 413 * Note: Only field0 will be updated in forced mode
yangcq88517 0:c70b7ececf93 414 * @param field 0-2
yangcq88517 0:c70b7ececf93 415 */
yangcq88517 1:85088a918342 416 uint32_t getUncompensatedHumidityData(int field = 0);
yangcq88517 0:c70b7ececf93 417
yangcq88517 0:c70b7ececf93 418 /**
yangcq88517 0:c70b7ececf93 419 * [gas_rl]
yangcq88517 0:c70b7ececf93 420 * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
yangcq88517 0:c70b7ececf93 421 * named field0, field1, and field2. The data fields are updated sequentially and always results of
yangcq88517 0:c70b7ececf93 422 * the three latest measurements are available for the user; if the last but one conversion was written
yangcq88517 0:c70b7ececf93 423 * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
yangcq88517 0:c70b7ececf93 424 * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
yangcq88517 0:c70b7ececf93 425 * data if update of the data registers comes simultaneously with serial interface reading out.
yangcq88517 0:c70b7ececf93 426 * Note: Only field0 will be updated in forced mode
yangcq88517 0:c70b7ececf93 427 * @param field 0-2
yangcq88517 0:c70b7ececf93 428 */
yangcq88517 1:85088a918342 429 uint16_t getUncompensatedGasResistanceData(int field = 0);
yangcq88517 0:c70b7ececf93 430
yangcq88517 0:c70b7ececf93 431 /**
yangcq88517 0:c70b7ececf93 432 * [gas_range_rl]
yangcq88517 0:c70b7ececf93 433 * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
yangcq88517 0:c70b7ececf93 434 * named field0, field1, and field2. The data fields are updated sequentially and always results of
yangcq88517 0:c70b7ececf93 435 * the three latest measurements are available for the user; if the last but one conversion was written
yangcq88517 0:c70b7ececf93 436 * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
yangcq88517 0:c70b7ececf93 437 * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
yangcq88517 0:c70b7ececf93 438 * data if update of the data registers comes simultaneously with serial interface reading out.
yangcq88517 0:c70b7ececf93 439 * Contains ADC range of measured gas resistance
yangcq88517 0:c70b7ececf93 440 * Note: Only field0 will be updated in forced mode
yangcq88517 0:c70b7ececf93 441 * @param field 0-2
yangcq88517 0:c70b7ececf93 442 */
yangcq88517 1:85088a918342 443 uint8_t getGasResistanceRange(int field = 0);
yangcq88517 0:c70b7ececf93 444
yangcq88517 0:c70b7ececf93 445
yangcq88517 0:c70b7ececf93 446 // STATUS #########################################################################
yangcq88517 0:c70b7ececf93 447
yangcq88517 0:c70b7ececf93 448 /**
yangcq88517 0:c70b7ececf93 449 * [new_data_x]
yangcq88517 0:c70b7ececf93 450 * The measured data are stored into the output data registers at the end of each TPHG conversion
yangcq88517 0:c70b7ececf93 451 * phase along with status flags and index of measurement. The part of the register map for output
yangcq88517 0:c70b7ececf93 452 * data storage is composed of 3 data fields (TPHG data field0|1|2)) keeping results from the last 3
yangcq88517 0:c70b7ececf93 453 * measurements. Availability of new (yet unread) results is indicated by new_data_0|1|2 flags.
yangcq88517 0:c70b7ececf93 454 * @param field 0-2
yangcq88517 0:c70b7ececf93 455 */
yangcq88517 1:85088a918342 456 bool isNewData(int field = 0);
yangcq88517 0:c70b7ececf93 457
yangcq88517 0:c70b7ececf93 458 /**
yangcq88517 0:c70b7ececf93 459 * [gas_measuring]
yangcq88517 0:c70b7ececf93 460 * Measuring bit is set to “1‟ only during gas measurements, goes to “0‟ as soon as measurement
yangcq88517 0:c70b7ececf93 461 * is completed and data transferred to data registers. The registers storing the configuration values
yangcq88517 0:c70b7ececf93 462 * for the measurement (gas_wait_shared, gas_wait_x, res_heat_x, idac_heat_x, image registers)
yangcq88517 0:c70b7ececf93 463 * should not be changed when the device is measuring.
yangcq88517 0:c70b7ececf93 464 * @param field 0-2
yangcq88517 0:c70b7ececf93 465 */
yangcq88517 1:85088a918342 466 bool isGasMeasuring(int field = 0);
yangcq88517 0:c70b7ececf93 467
yangcq88517 0:c70b7ececf93 468 /**
yangcq88517 0:c70b7ececf93 469 * [measuring]
yangcq88517 0:c70b7ececf93 470 * Measuring status will be set to ‘1’ whenever a conversion (Pressure, Temperature, humidity &
yangcq88517 0:c70b7ececf93 471 * gas) is running and back to ‘0’ when the results have been transferred to the data registers.
yangcq88517 0:c70b7ececf93 472 * @param field 0-2
yangcq88517 0:c70b7ececf93 473 */
yangcq88517 1:85088a918342 474 bool isMeasuring(int field = 0);
yangcq88517 0:c70b7ececf93 475
yangcq88517 0:c70b7ececf93 476 /**
yangcq88517 0:c70b7ececf93 477 * [gas_meas_index_x]
yangcq88517 0:c70b7ececf93 478 * User can program a sequence of up to 10 conversions by setting nb_conv<3:0>. Each conversion
yangcq88517 0:c70b7ececf93 479 * has its own heater resistance target but 3 field registers to store conversion results. The actual
yangcq88517 0:c70b7ececf93 480 * gas conversion number in the measurement sequence (up to 10 conversions numbered from 0
yangcq88517 0:c70b7ececf93 481 * to 9) is stored in gas_meas_index register.
yangcq88517 0:c70b7ececf93 482 * @param field 0-2
yangcq88517 0:c70b7ececf93 483 */
yangcq88517 1:85088a918342 484 int getGasMeasurementIndex(int field = 0);
yangcq88517 0:c70b7ececf93 485
yangcq88517 0:c70b7ececf93 486 /**
yangcq88517 0:c70b7ececf93 487 * [sub_meas_index_x]
yangcq88517 0:c70b7ececf93 488 * sub_meas_index_x registers form “virtual time sensor” and contain a snapshot of the internal 8
yangcq88517 0:c70b7ececf93 489 * bit conversion counter. Conversion counter is incremented with each TPHG conversion; the
yangcq88517 0:c70b7ececf93 490 * counter thus contains the number of conversions modulo 256 executed since the last change of
yangcq88517 0:c70b7ececf93 491 * device mode.
yangcq88517 0:c70b7ececf93 492 * Note: This index is incremented only if gas conversion is active.
yangcq88517 0:c70b7ececf93 493 * @param field 0-2
yangcq88517 0:c70b7ececf93 494 */
yangcq88517 1:85088a918342 495 int getSubMeasurementIndex(int field = 0);
yangcq88517 0:c70b7ececf93 496
yangcq88517 0:c70b7ececf93 497 /**
yangcq88517 0:c70b7ececf93 498 * [gas_valid_rl]
yangcq88517 0:c70b7ececf93 499 * In parallel mode, each TPHG sequence contains a gas measurement slot, either a real one which
yangcq88517 0:c70b7ececf93 500 * result is used or a dummy one to keep a constant sampling rate and predictable device timing. A
yangcq88517 0:c70b7ececf93 501 * real gas conversion (i.e., not a dummy one) is indicated by the gas_valid_rl status register.
yangcq88517 0:c70b7ececf93 502 * @param field 0-2
yangcq88517 0:c70b7ececf93 503 */
yangcq88517 1:85088a918342 504 bool isGasValid(int field = 0);
yangcq88517 0:c70b7ececf93 505
yangcq88517 0:c70b7ececf93 506 /**
yangcq88517 0:c70b7ececf93 507 * [heat_stab_rl]
yangcq88517 0:c70b7ececf93 508 * Heater temperature stability for target heater resistance is indicated heat_stab_x status bits.
yangcq88517 0:c70b7ececf93 509 * @param field 0-2
yangcq88517 0:c70b7ececf93 510 */
yangcq88517 1:85088a918342 511 bool isHeaterStable(int field = 0);
yangcq88517 0:c70b7ececf93 512
yangcq88517 0:c70b7ececf93 513 // GAS CONTROL #########################################################################
yangcq88517 0:c70b7ececf93 514
yangcq88517 0:c70b7ececf93 515 /**
yangcq88517 0:c70b7ececf93 516 * [idac_heat_x]
yangcq88517 0:c70b7ececf93 517 * BME680 contains a heater control block that will inject enough current into the heater resistance
yangcq88517 0:c70b7ececf93 518 * to achieve the requested heater temperature. There is a control loop which periodically measures
yangcq88517 0:c70b7ececf93 519 * heater resistance value and adapts the value of current injected from a DAC.
yangcq88517 0:c70b7ececf93 520 * BME680 heater operation could be speeded up by setting an initial heater current for a target
yangcq88517 0:c70b7ececf93 521 * heater temperature by using register idac_heat_x<7:0>. This step is optional since the control
yangcq88517 0:c70b7ececf93 522 * loop will find the current after a few iterations anyway.
yangcq88517 0:c70b7ececf93 523 * Current injected to the heater in mA = (idac_heat_7_1 + 1) / 8
yangcq88517 0:c70b7ececf93 524 * Where: idac_heat_7_1 = decimal value stored in idac_heat<7:1> (unsigned, value from 0 to 127)
yangcq88517 0:c70b7ececf93 525 * @param setPoint 0-9
yangcq88517 0:c70b7ececf93 526 */
yangcq88517 0:c70b7ececf93 527 uint8_t getHeaterCurrent(int setPoint);
yangcq88517 0:c70b7ececf93 528
yangcq88517 0:c70b7ececf93 529 /**
yangcq88517 0:c70b7ececf93 530 * [idac_heat_x]
yangcq88517 0:c70b7ececf93 531 * BME680 contains a heater control block that will inject enough current into the heater resistance
yangcq88517 0:c70b7ececf93 532 * to achieve the requested heater temperature. There is a control loop which periodically measures
yangcq88517 0:c70b7ececf93 533 * heater resistance value and adapts the value of current injected from a DAC.
yangcq88517 0:c70b7ececf93 534 * BME680 heater operation could be speeded up by setting an initial heater current for a target
yangcq88517 0:c70b7ececf93 535 * heater temperature by using register idac_heat_x<7:0>. This step is optional since the control
yangcq88517 0:c70b7ececf93 536 * loop will find the current after a few iterations anyway.
yangcq88517 0:c70b7ececf93 537 * Current injected to the heater in mA = (idac_heat_7_1 + 1) / 8
yangcq88517 0:c70b7ececf93 538 * Where: idac_heat_7_1 = decimal value stored in idac_heat<7:1> (unsigned, value from 0 to 127)
yangcq88517 0:c70b7ececf93 539 * @param setPoint 0-9
yangcq88517 0:c70b7ececf93 540 */
yangcq88517 0:c70b7ececf93 541 void setHeaterCurrent(int setPoint, uint8_t value);
yangcq88517 0:c70b7ececf93 542
yangcq88517 0:c70b7ececf93 543 /**
yangcq88517 0:c70b7ececf93 544 * [res_heat_x]
yangcq88517 0:c70b7ececf93 545 * Target heater resistance is programmed by user through res_heat_x<7:0> registers.
yangcq88517 0:c70b7ececf93 546 * res_heat_x = 3.4* ((R_Target*(4/4+res_heat_range))-25) / ((res_heat_val * 0.002) + 1))
yangcq88517 0:c70b7ececf93 547 * Where
yangcq88517 0:c70b7ececf93 548 * R_Target is the target heater resistance in Ohm
yangcq88517 0:c70b7ececf93 549 * res_heat_x is the decimal value that needs to be stored in register with same name
yangcq88517 0:c70b7ececf93 550 * res_heat_range is heater range stored in register address 0x02 <5:4>
yangcq88517 0:c70b7ececf93 551 * res_heat_val is heater resistance correction factor stored in register address 0x00 (signed, value from -128 to 127)
yangcq88517 0:c70b7ececf93 552 * @param setPoint 0-9
yangcq88517 0:c70b7ececf93 553 */
yangcq88517 0:c70b7ececf93 554 int8_t getTargetHeaterResistance(int setPoint);
yangcq88517 0:c70b7ececf93 555
yangcq88517 0:c70b7ececf93 556 /**
yangcq88517 0:c70b7ececf93 557 * [res_heat_x]
yangcq88517 0:c70b7ececf93 558 * Target heater resistance is programmed by user through res_heat_x<7:0> registers.
yangcq88517 0:c70b7ececf93 559 * res_heat_x = 3.4* ((R_Target*(4/4+res_heat_range))-25) / ((res_heat_val * 0.002) + 1))
yangcq88517 0:c70b7ececf93 560 * Where
yangcq88517 0:c70b7ececf93 561 * R_Target is the target heater resistance in Ohm
yangcq88517 0:c70b7ececf93 562 * res_heat_x is the decimal value that needs to be stored in register with same name
yangcq88517 0:c70b7ececf93 563 * res_heat_range is heater range stored in register address 0x02 <5:4>
yangcq88517 0:c70b7ececf93 564 * res_heat_val is heater resistance correction factor stored in register address 0x00 (signed, value from -128 to 127)
yangcq88517 0:c70b7ececf93 565 * @param setPoint 0-9
yangcq88517 0:c70b7ececf93 566 */
yangcq88517 0:c70b7ececf93 567 void setTargetHeaterResistance(int setPoint, int8_t value);
yangcq88517 0:c70b7ececf93 568
yangcq88517 0:c70b7ececf93 569 /**
yangcq88517 0:c70b7ececf93 570 * [gas_wait_x]
yangcq88517 0:c70b7ececf93 571 * gas_wait_x controls heater timing of the gas sensor. Functionality of this register will vary based on power modes.
yangcq88517 0:c70b7ececf93 572 * Forced Mode & Sequential mode
yangcq88517 0:c70b7ececf93 573 * Time between beginning of heat phase and start of sensor resistance conversion depend on gas_wait_x settings as mentioned below.
yangcq88517 0:c70b7ececf93 574 * Parallel Mode
yangcq88517 0:c70b7ececf93 575 * The number of TPHG sub-measurement sequences within the one Gas conversion for one target
yangcq88517 0:c70b7ececf93 576 * temperature resistance is defined by gas_wait_x settings.
yangcq88517 0:c70b7ececf93 577 * Note: Please take care about gas_wait_x on shifting modes between parallel & sequential/forced mode as register functionality will change.
yangcq88517 0:c70b7ececf93 578 * @return result * 0.477 ms
yangcq88517 0:c70b7ececf93 579 * @param setPoint 0-9
yangcq88517 0:c70b7ececf93 580 */
yangcq88517 0:c70b7ececf93 581 int getGasWaitTime(int setPoint);
yangcq88517 0:c70b7ececf93 582
yangcq88517 0:c70b7ececf93 583 /**
yangcq88517 0:c70b7ececf93 584 * [gas_wait_x]
yangcq88517 0:c70b7ececf93 585 * gas_wait_x controls heater timing of the gas sensor. Functionality of this register will vary based on power modes.
yangcq88517 0:c70b7ececf93 586 * Forced Mode & Sequential mode
yangcq88517 0:c70b7ececf93 587 * Time between beginning of heat phase and start of sensor resistance conversion depend on gas_wait_x settings as mentioned below.
yangcq88517 0:c70b7ececf93 588 * Parallel Mode
yangcq88517 0:c70b7ececf93 589 * The number of TPHG sub-measurement sequences within the one Gas conversion for one target
yangcq88517 0:c70b7ececf93 590 * temperature resistance is defined by gas_wait_x settings.
yangcq88517 0:c70b7ececf93 591 * Note: Please take care about gas_wait_x on shifting modes between parallel & sequential/forced mode as register functionality will change.
yangcq88517 0:c70b7ececf93 592 * @return result * 0.477 ms
yangcq88517 0:c70b7ececf93 593 * @param setPoint 0-9
yangcq88517 0:c70b7ececf93 594 * @param time 64 timer values with 1ms step sizes, all zeros means no wait.
yangcq88517 0:c70b7ececf93 595 * @param multiplication [0, 1, 2, 3] -> [1, 4, 16, 64]
yangcq88517 0:c70b7ececf93 596 */
yangcq88517 0:c70b7ececf93 597 void setGasWaitTime(int setPoint, int time, int multiplication);
yangcq88517 0:c70b7ececf93 598
yangcq88517 0:c70b7ececf93 599 /**
yangcq88517 0:c70b7ececf93 600 * [gas_wait_shared]
yangcq88517 0:c70b7ececf93 601 * The programmable wait time between two TPHG sub-measurement sequences of parallel mode depends on gas_wait_shared settings as follows
yangcq88517 0:c70b7ececf93 602 */
yangcq88517 0:c70b7ececf93 603 int getGasWaitShared();
yangcq88517 0:c70b7ececf93 604
yangcq88517 0:c70b7ececf93 605 /**
yangcq88517 0:c70b7ececf93 606 * [gas_wait_shared]
yangcq88517 0:c70b7ececf93 607 * The programmable wait time between two TPHG sub-measurement sequences of parallel mode depends on gas_wait_shared settings as follows
yangcq88517 0:c70b7ececf93 608 * @param setPoint 0-9
yangcq88517 0:c70b7ececf93 609 * @param time 64 timer values with 0.477 ms step sizes, all zeros means no wait.
yangcq88517 0:c70b7ececf93 610 * @param multiplication [0x00, 0x01, 0x10, 0x11] -> [1, 4, 16, 64]
yangcq88517 0:c70b7ececf93 611 */
yangcq88517 0:c70b7ececf93 612 void setGasWaitShared(int time, int multiplication);
yangcq88517 0:c70b7ececf93 613
yangcq88517 0:c70b7ececf93 614 /**
yangcq88517 0:c70b7ececf93 615 * [heat_off]
yangcq88517 0:c70b7ececf93 616 * Turn off current injected to heater
yangcq88517 0:c70b7ececf93 617 */
yangcq88517 0:c70b7ececf93 618 void setHeaterOff();
yangcq88517 0:c70b7ececf93 619
yangcq88517 0:c70b7ececf93 620 /**
yangcq88517 0:c70b7ececf93 621 * [nb_conv]
yangcq88517 0:c70b7ececf93 622 * is used to select heater set-points of BME680
yangcq88517 0:c70b7ececf93 623 * Sequential & Parallel Mode
yangcq88517 0:c70b7ececf93 624 * User can program a sequence of up to 10 conversions by setting nb_conv<3:0>. Each conversion has its own heater resistance target but 3 field registers to store conversion results. The actual
yangcq88517 0:c70b7ececf93 625 * gas conversion number in the measurement sequence (up to 10 conversions numbered from 0 to 9) is stored in gas measurement index register
yangcq88517 0:c70b7ececf93 626 * In parallel mode, no TPH conversions are ran at all. In sequential mode, TPH conversions are run according to osrs_t|p|h settings, gas is skipped
yangcq88517 0:c70b7ececf93 627 * @return Sequential & Parallel : number of profiles (0-10), 0 means no gas conversion
yangcq88517 0:c70b7ececf93 628 * @return Forced : indicates index of heater profile
yangcq88517 0:c70b7ececf93 629 */
yangcq88517 0:c70b7ececf93 630 int getHeaterProfile();
yangcq88517 0:c70b7ececf93 631
yangcq88517 0:c70b7ececf93 632 /**
yangcq88517 0:c70b7ececf93 633 * [nb_conv]
yangcq88517 0:c70b7ececf93 634 * is used to select heater set-points of BME680
yangcq88517 0:c70b7ececf93 635 * Sequential & Parallel Mode
yangcq88517 0:c70b7ececf93 636 * User can program a sequence of up to 10 conversions by setting nb_conv<3:0>. Each conversion has its own heater resistance target but 3 field registers to store conversion results. The actual
yangcq88517 0:c70b7ececf93 637 * gas conversion number in the measurement sequence (up to 10 conversions numbered from 0 to 9) is stored in gas measurement index register
yangcq88517 0:c70b7ececf93 638 * In parallel mode, no TPH conversions are ran at all. In sequential mode, TPH conversions are run according to osrs_t|p|h settings, gas is skipped
yangcq88517 0:c70b7ececf93 639 * @param Sequential & Parallel : number of profiles (0-10), 0 means no gas conversion
yangcq88517 0:c70b7ececf93 640 * @param Forced : indicates index of heater profile
yangcq88517 0:c70b7ececf93 641 */
yangcq88517 0:c70b7ececf93 642 void setHeaterProfile(int value);
yangcq88517 0:c70b7ececf93 643
yangcq88517 0:c70b7ececf93 644 /**
yangcq88517 0:c70b7ececf93 645 * [run_gas_l]
yangcq88517 0:c70b7ececf93 646 * The gas conversions are started only in appropriate mode if run_gas_l=1
yangcq88517 0:c70b7ececf93 647 */
yangcq88517 0:c70b7ececf93 648 void runGasConversion();
yangcq88517 0:c70b7ececf93 649
yangcq88517 0:c70b7ececf93 650 /**
yangcq88517 0:c70b7ececf93 651 * [odr]
yangcq88517 0:c70b7ececf93 652 * Wake period in sequential mode – odr
yangcq88517 0:c70b7ececf93 653 * In the sequential mode operation the device periodically enters stand-by state and returns to an operational state after a given wake-up period. Wake period can be programmed by odr<3:0> register as shown below
yangcq88517 0:c70b7ececf93 654 * @return in ms, 0 means device does not go to standby
yangcq88517 0:c70b7ececf93 655 */
yangcq88517 0:c70b7ececf93 656 float getWakePeriod();
yangcq88517 0:c70b7ececf93 657
yangcq88517 0:c70b7ececf93 658 /**
yangcq88517 0:c70b7ececf93 659 * [odr]
yangcq88517 0:c70b7ececf93 660 * Wake period in sequential mode – odr
yangcq88517 0:c70b7ececf93 661 * In the sequential mode operation the device periodically enters stand-by state and returns to an operational state after a given wake-up period. Wake period can be programmed by odr<3:0> register as shown below
yangcq88517 0:c70b7ececf93 662 * @param value : [0 - 8+] [0.59,62.5,125,250,500,1000,10,20,no standby]
yangcq88517 0:c70b7ececf93 663 */
yangcq88517 0:c70b7ececf93 664 void setWakePeriod(int value);
yangcq88517 0:c70b7ececf93 665
yangcq88517 0:c70b7ececf93 666 // PRESSURE TEMPERATURE HUMIDITY CONTROL #########################################################################
yangcq88517 0:c70b7ececf93 667
yangcq88517 0:c70b7ececf93 668 /**
yangcq88517 0:c70b7ececf93 669 * [osrs_h]
yangcq88517 0:c70b7ececf93 670 * @return value : [0,1,2,4,8,16] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
yangcq88517 0:c70b7ececf93 671 */
yangcq88517 0:c70b7ececf93 672 int getOversamplingHumidity();
yangcq88517 0:c70b7ececf93 673
yangcq88517 0:c70b7ececf93 674 /**
yangcq88517 0:c70b7ececf93 675 * [osrs_h]
yangcq88517 0:c70b7ececf93 676 * @param value : [0,1,2,3,4,5] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
yangcq88517 0:c70b7ececf93 677 */
yangcq88517 0:c70b7ececf93 678 void setOversamplingHumidity(int value);
yangcq88517 0:c70b7ececf93 679
yangcq88517 0:c70b7ececf93 680 /**
yangcq88517 0:c70b7ececf93 681 * [osrs_p]
yangcq88517 0:c70b7ececf93 682 * @return value : [0,1,2,4,8,16] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
yangcq88517 0:c70b7ececf93 683 */
yangcq88517 0:c70b7ececf93 684 int getOversamplingPressure();
yangcq88517 0:c70b7ececf93 685
yangcq88517 0:c70b7ececf93 686 /**
yangcq88517 0:c70b7ececf93 687 * [osrs_p]
yangcq88517 0:c70b7ececf93 688 * @param value : [0,1,2,3,4,5] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
yangcq88517 0:c70b7ececf93 689 */
yangcq88517 0:c70b7ececf93 690 void setOversamplingPressure(int value);
yangcq88517 0:c70b7ececf93 691
yangcq88517 0:c70b7ececf93 692 /**
yangcq88517 0:c70b7ececf93 693 * [osrs_t]
yangcq88517 0:c70b7ececf93 694 * @return value : [0,1,2,4,8,16] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
yangcq88517 0:c70b7ececf93 695 */
yangcq88517 0:c70b7ececf93 696 int getOversamplingTemperature();
yangcq88517 0:c70b7ececf93 697
yangcq88517 0:c70b7ececf93 698 /**
yangcq88517 0:c70b7ececf93 699 * [osrs_t]
yangcq88517 0:c70b7ececf93 700 * @param value : [0,1,2,3,4,5] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
yangcq88517 0:c70b7ececf93 701 */
yangcq88517 0:c70b7ececf93 702 void setOversamplingTemperature(int value);
yangcq88517 0:c70b7ececf93 703
yangcq88517 0:c70b7ececf93 704 /**
yangcq88517 0:c70b7ececf93 705 * [filter]
yangcq88517 0:c70b7ececf93 706 * IIR filter control
yangcq88517 0:c70b7ececf93 707 * IIR filter applies to temperature and pressure data but not to humidity and gas data. The data
yangcq88517 0:c70b7ececf93 708 * coming from the ADC are filtered and then loaded into the data registers. The T, P result registers
yangcq88517 0:c70b7ececf93 709 * are updated together at the same time at the end of measurement. IIR filter output resolution is
yangcq88517 0:c70b7ececf93 710 * 20 bits. The T, P result registers are reset to value 0x80000 when the T, P measurements have
yangcq88517 0:c70b7ececf93 711 * been skipped (osrs_x=”000‟). The appropriate filter memory is kept unchanged (the value fromt he last measurement is kept). When the appropriate OSRS register is set back to nonzero, then
yangcq88517 0:c70b7ececf93 712 * the first value stored to the T, P result register is filtered.
yangcq88517 0:c70b7ececf93 713 * @return value : [0,1,3,7,15,31,63,127]
yangcq88517 0:c70b7ececf93 714 */
yangcq88517 0:c70b7ececf93 715 int getIIRfilterCoefficient();
yangcq88517 0:c70b7ececf93 716
yangcq88517 0:c70b7ececf93 717 /**
yangcq88517 0:c70b7ececf93 718 * [filter]
yangcq88517 0:c70b7ececf93 719 * IIR filter control
yangcq88517 0:c70b7ececf93 720 * IIR filter applies to temperature and pressure data but not to humidity and gas data. The data
yangcq88517 0:c70b7ececf93 721 * coming from the ADC are filtered and then loaded into the data registers. The T, P result registers
yangcq88517 0:c70b7ececf93 722 * are updated together at the same time at the end of measurement. IIR filter output resolution is
yangcq88517 0:c70b7ececf93 723 * 20 bits. The T, P result registers are reset to value 0x80000 when the T, P measurements have
yangcq88517 0:c70b7ececf93 724 * been skipped (osrs_x=”000‟). The appropriate filter memory is kept unchanged (the value fromt he last measurement is kept). When the appropriate OSRS register is set back to nonzero, then
yangcq88517 0:c70b7ececf93 725 * the first value stored to the T, P result register is filtered.
yangcq88517 0:c70b7ececf93 726 * @param value : [0,1,2,3,4,5,6,7] -> [0,1,3,7,15,31,63,127]
yangcq88517 0:c70b7ececf93 727 */
yangcq88517 0:c70b7ececf93 728 void setIIRfilterCoefficient(int value);
yangcq88517 0:c70b7ececf93 729
yangcq88517 0:c70b7ececf93 730 // GENERAL CONTROL #########################################################################
yangcq88517 0:c70b7ececf93 731
yangcq88517 0:c70b7ececf93 732 /**
yangcq88517 0:c70b7ececf93 733 * [mode]
yangcq88517 0:c70b7ececf93 734 * Four measurement modes are available for BME680; that is sleep, sequential, parallel and forced
yangcq88517 0:c70b7ececf93 735 * mode.Four measurement modes are available for BME680; that is sleep, sequential, parallel and forced mode.
yangcq88517 0:c70b7ececf93 736 * @param mode : [0,1,2,3] -> [Sleep, Forced, Parallel, Sequential]
yangcq88517 0:c70b7ececf93 737 */
yangcq88517 0:c70b7ececf93 738 void setMode(int mode);
yangcq88517 0:c70b7ececf93 739
yangcq88517 0:c70b7ececf93 740 /**
yangcq88517 0:c70b7ececf93 741 * [mode]
yangcq88517 0:c70b7ececf93 742 * Four measurement modes are available for BME680; that is sleep, sequential, parallel and forced
yangcq88517 0:c70b7ececf93 743 * mode.Four measurement modes are available for BME680; that is sleep, sequential, parallel and forced mode.
yangcq88517 0:c70b7ececf93 744 * @return value : [0,1,2,3] -> [Sleep, Forced, Parallel, Sequential]
yangcq88517 0:c70b7ececf93 745 */
yangcq88517 0:c70b7ececf93 746 int getMode();
yangcq88517 0:c70b7ececf93 747
yangcq88517 0:c70b7ececf93 748 /**
yangcq88517 0:c70b7ececf93 749 * [chip_id]
yangcq88517 0:c70b7ececf93 750 * Chip id of the device, this should give 0x61
yangcq88517 0:c70b7ececf93 751 */
yangcq88517 0:c70b7ececf93 752 int getChipID();
yangcq88517 0:c70b7ececf93 753 };
yangcq88517 0:c70b7ececf93 754
yangcq88517 0:c70b7ececf93 755 #endif