Marcus Lee / BME680

Fork of BME680 by CHENGQI YANG

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BME680.h Source File

BME680.h

00001 #ifndef UK_AC_HERTS_SMARTLAB_BME680
00002 #define UK_AC_HERTS_SMARTLAB_BME680
00003 
00004 #include "mbed.h"
00005 #include "stdint.h"
00006 #include "serial.h"
00007 
00008 /*
00009 * Use below macro for fixed Point Calculation
00010 * else Floating Point calculation will be used
00011 */
00012 #define FIXED_POINT_COMPENSATION
00013 
00014 // no idea what it is for
00015 //#define HEATER_C1_ENABLE
00016 
00017 // Sensor Specific constants */
00018 #define BME680_SLEEP_MODE               (0x00)
00019 #define BME680_FORCED_MODE              (0x01)
00020 #define BME680_PARALLEL_MODE            (0x02)
00021 #define BME680_SEQUENTIAL_MODE          (0x03)
00022 #define BME680_GAS_PROFILE_TEMPERATURE_MIN  (200)
00023 #define BME680_GAS_PROFILE_TEMPERATURE_MAX  (400)
00024 #define BME680_GAS_RANGE_RL_LENGTH      (16)
00025 #define BME680_SIGN_BIT_MASK            (0x08)
00026 
00027 #ifdef FIXED_POINT_COMPENSATION
00028 //< Multiply by 1000, In order to convert float value into fixed point
00029 #define BME680_MAX_HUMIDITY_VALUE       (102400)
00030 #define BME680_MIN_HUMIDITY_VALUE       (0)
00031 #else
00032 #define BME680_MAX_HUMIDITY_VALUE       (double)(100.0)
00033 #define BME680_MIN_HUMIDITY_VALUE       (double)(0.0)
00034 #endif
00035 
00036 /**
00037 * !! MUST CALL init() FIRST !!
00038 * read the chip id and calibration data of the BME680 sensor
00039 * BME680 integrated environmental sensor. This API supports FIXED and FLOATING compenstion.
00040 * By default it supports FIXED, to use FLOATING user need to disable "FIXED_POINT_COMPENSATION" in the BME680.h file.
00041 */
00042 class BME680
00043 {
00044 private:
00045     static const int FREQUENCY_STANDARD = 100000;
00046     static const int FREQUENCY_FULL = 400000;
00047     static const int FREQUENCY_FAST = 1000000;
00048     static const int FREQUENCY_HIGH = 3200000;
00049 
00050     I2C * _i2c_bus;
00051     int _addr;
00052     uint8_t data[30];
00053 
00054     //static const double const_array1[];
00055     //static const double const_array2[];
00056     static const uint64_t lookup_k1_range[];
00057     static const uint64_t lookup_k2_range[];
00058     static const double _lookup_k1_range[];
00059     static const double _lookup_k2_range[];
00060 
00061     /* For Calibration Data*/
00062     static const int DIG_T2_LSB_REG = 1;
00063     static const int DIG_T2_MSB_REG = 2;
00064     static const int DIG_T3_REG = 3;
00065     static const int DIG_P1_LSB_REG = 5;
00066     static const int DIG_P1_MSB_REG = 6;
00067     static const int DIG_P2_LSB_REG = 7;
00068     static const int DIG_P2_MSB_REG = 8;
00069     static const int DIG_P3_REG = 9;
00070     static const int DIG_P4_LSB_REG = 11;
00071     static const int DIG_P4_MSB_REG = 12;
00072     static const int DIG_P5_LSB_REG = 13;
00073     static const int DIG_P5_MSB_REG = 14;
00074     static const int DIG_P7_REG = 15;
00075     static const int DIG_P6_REG = 16;
00076     static const int DIG_P8_LSB_REG = 19;
00077     static const int DIG_P8_MSB_REG = 20;
00078     static const int DIG_P9_LSB_REG = 21;
00079     static const int DIG_P9_MSB_REG = 22;
00080     static const int DIG_P10_REG = 23;
00081     static const int DIG_H2_MSB_REG = 25;
00082     static const int DIG_H2_LSB_REG = 26;
00083     static const int DIG_H1_LSB_REG = 26;
00084     static const int DIG_H1_MSB_REG  = 27;
00085     static const int DIG_H3_REG = 28;
00086     static const int DIG_H4_REG = 29;
00087     static const int DIG_H5_REG = 30;
00088     static const int DIG_H6_REG = 31;
00089     static const int DIG_H7_REG = 32;
00090     static const int DIG_T1_LSB_REG = 33;
00091     static const int DIG_T1_MSB_REG = 34;
00092     static const int DIG_GH2_LSB_REG = 35;
00093     static const int DIG_GH2_MSB_REG = 36;
00094     static const int DIG_GH1_REG = 37;
00095     static const int DIG_GH3_REG = 38;
00096 
00097     static const int BME680_BIT_MASK_H1_DATA = 0x0F;
00098 
00099     int8_t  par_T3;/**<calibration T3 data*/
00100     int8_t  par_P3;/**<calibration P3 data*/
00101     int8_t  par_P6;/**<calibration P6 data*/
00102     int8_t  par_P7;/**<calibration P7 data*/
00103     uint8_t  par_P10;/**<calibration P10 data*/
00104     int8_t  par_H3;/**<calibration H3 data*/
00105     int8_t  par_H4;/**<calibration H4 data*/
00106     int8_t  par_H5;/**<calibration H5 data*/
00107     uint8_t  par_H6;/**<calibration H6 data*/
00108     int8_t  par_H7;/**<calibration H7 data*/
00109     int8_t  par_GH1;/**<calibration GH1 data*/
00110     uint8_t  res_heat_range;/**<resistance calculation*/
00111     int8_t  res_heat_val; /**<correction factor*/
00112     int8_t  range_switching_error;/**<range switching error*/
00113     int16_t par_GH2;/**<calibration GH2 data*/
00114     uint16_t par_T1;/**<calibration T1 data*/
00115     int16_t par_T2;/**<calibration T2 data*/
00116     uint16_t par_P1;/**<calibration P1 data*/
00117     int16_t par_P2;/**<calibration P2 data*/
00118     int16_t par_P4;/**<calibration P4 data*/
00119     int16_t par_P5;/**<calibration P5 data*/
00120     int16_t par_P8;/**<calibration P8 data*/
00121     int16_t par_P9;/**<calibration P9 data*/
00122     uint16_t par_H1;/**<calibration H1 data*/
00123     uint16_t par_H2;/**<calibration H2 data*/
00124     int32_t t_fine;/**<calibration T_FINE data*/
00125     int8_t  par_GH3;/**<calibration GH3 data*/
00126 
00127     void readRegister(int reg, int size = 1);
00128 
00129     void writeRegister(int reg, int value);
00130 
00131 public:
00132 
00133     /**
00134     * TPHG measurements are performed.
00135     * continuously until mode change.
00136     * Between each cycle, the sensor enters stand-by for a period of time according to the odr<3:0> control register.
00137     * Gas sensor heater only operates during gas sub-measurement.
00138     * 100 ms gas wait time, T:X2, P:X16, H:X1
00139     */
00140     void setSequentialMode();
00141 
00142     /**
00143     * Single TPHG cycle is performed.
00144     * Sensor automatically returns to sleep mode afterwards.
00145     * Gas sensor heater only operates during gas sub-measureme.
00146     */
00147     void setForcedMode();
00148 
00149     /**
00150     * TPHG measurements are performed continuously until mode change.
00151     * No stand-by occurs between consecutive TPHG cycles.
00152     * Gas sensor heater operates in parallel with TPH measurements.
00153     */
00154     void setParallelMode();
00155 
00156     /**
00157     * Constructor
00158     * @param i2c I2C interface used for communication
00159     * @param SDO Slave address LSB (High->true, Low->false)
00160     */
00161     BME680(I2C * i2c, bool SDO);
00162 
00163     /**
00164     * !! MUST CALL THIS FIRST !!
00165     * read the chip id and calibration data of the BME680 sensor
00166     */
00167     bool init();
00168     // DATA #########################################################################
00169 
00170 #ifdef FIXED_POINT_COMPENSATION
00171     /**
00172     *  This function is used to convert the uncompensated
00173     *  temperature data to compensated temperature data using
00174     *  compensation formula(integer version)
00175     *  @note Returns the value in 0.01 degree Centigrade
00176     *  Output value of "5123" equals 51.23 DegC.
00177     *
00178     * @param field 0-2
00179     *
00180     *  @return Returns the compensated temperature data
00181     *
00182     */
00183     int32_t getCompensatedTemperature(int field = 0);
00184 
00185     /**
00186     * Reads actual temperature from uncompensated temperature
00187     * @note Returns the value with 500LSB/DegC centred around 24 DegC
00188     * output value of "5123" equals(5123/500)+24 = 34.246DegC
00189     *
00190     *
00191     *  @param v_uncomp_temperature_u32: value of uncompensated temperature
00192     *  @param bme680: structure pointer.
00193     *
00194     *
00195     *  @return Return the actual temperature as s16 output
00196     *
00197     */
00198     int16_t getTemperatureInt(int field = 0);
00199 
00200     /**
00201     *  @brief This function is used to convert the uncompensated
00202     *  humidity data to compensated humidity data using
00203     *  compensation formula(integer version)
00204     *
00205     *  @note Returns the value in %rH as unsigned 32bit integer
00206     *  in Q22.10 format(22 integer 10 fractional bits).
00207     *  @note An output value of 42313
00208     *  represents 42313 / 1024 = 41.321 %rH
00209     *
00210     *
00211     *
00212     *  @param  v_uncomp_humidity_u32: value of uncompensated humidity
00213     *  @param bme680: structure pointer.
00214     *
00215     *  @return Return the compensated humidity data
00216     *
00217     */
00218     int32_t getCompensateHumidity(int field = 0);
00219 
00220     /**
00221     * @brief Reads actual humidity from uncompensated humidity
00222     * @note Returns the value in %rH as unsigned 16bit integer
00223     * @note An output value of 42313
00224     * represents 42313/512 = 82.643 %rH
00225     *
00226     *
00227     *
00228     *  @param v_uncomp_humidity_u32: value of uncompensated humidity
00229     *  @param bme680: structure pointer.
00230     *
00231     *  @return Return the actual relative humidity output as u16
00232     *
00233     */
00234     uint16_t getHumidityInt(int field = 0);
00235 
00236     /**
00237     * @brief This function is used to convert the uncompensated
00238     *  pressure data to compensated pressure data data using
00239     *  compensation formula(integer version)
00240     *
00241     * @note Returns the value in Pascal(Pa)
00242     * Output value of "96386" equals 96386 Pa =
00243     * 963.86 hPa = 963.86 millibar
00244     *
00245     *
00246     *
00247     *  @param v_uncomp_pressure_u32 : value of uncompensated pressure
00248     *  @param bme680: structure pointer.
00249     *
00250     *  @return Return the compensated pressure data
00251     *
00252     */
00253     int32_t getCompensatePressure(int field = 0);
00254 
00255     /**
00256      * @brief Reads actual pressure from uncompensated pressure
00257      * @note Returns the value in Pa.
00258      * @note Output value of "12337434"
00259      * @note represents 12337434 / 128 = 96386.2 Pa = 963.862 hPa
00260      *
00261      *
00262      *
00263      *  @param v_uncomp_pressure_u32 : value of uncompensated pressure
00264      *  @param bme680: structure pointer.
00265      *
00266      *  @return the actual pressure in u32
00267      *
00268     */
00269     uint32_t getPressureInt(int field = 0);
00270 
00271     /**
00272      *  @brief This function is used to convert temperature to resistance
00273      *  using the integer compensation formula
00274      *
00275      *  @param heater_temp_u16: The value of heater temperature
00276      *  @param ambient_temp_s16: The value of ambient temperature
00277      *  @param bme680: structure pointer.
00278      *
00279      *  @return calculated resistance from temperature
00280      *
00281      *
00282      *
00283     */
00284     uint8_t convertTemperatureResistanceInt(uint16_t heater, int16_t ambient);
00285 
00286 
00287     /**
00288      *  @brief This function is used to convert uncompensated gas data to
00289      *  compensated gas data using compensation formula(integer version)
00290      *
00291      *  @param gas_adc_u16: The value of gas resistance calculated
00292      *       using temperature
00293      *  @param gas_range_u8: The value of gas range form register value
00294      *  @param bme680: structure pointer.
00295      *
00296      *  @return calculated compensated gas from compensation formula
00297      *  @retval compensated gas data
00298      *
00299      *
00300     */
00301     int32_t getCalculateGasInt(int field = 0);
00302 
00303 #else
00304     /**
00305     * This function used to convert temperature data
00306     * to uncompensated temperature data using compensation formula
00307     * @note returns the value in Degree centigrade
00308     * @note Output value of "51.23" equals 51.23 DegC.
00309     * @param field 0-2
00310     * @return  Return the actual temperature in floating point
00311     */
00312     double getTemperatureDouble(int field = 0);
00313 
00314     /**
00315     * @brief This function is used to convert the uncompensated
00316     *  humidity data to compensated humidity data data using
00317     *  compensation formula
00318     * @note returns the value in relative humidity (%rH)
00319     * @note Output value of "42.12" equals 42.12 %rH
00320     *
00321     *  @param uncom_humidity_u16 : value of uncompensated humidity
00322     *  @param comp_temperature   : value of compensated temperature
00323     *  @param bme680: structure pointer.
00324     *
00325     *
00326     *  @return Return the compensated humidity data in floating point
00327     *
00328     */
00329     double getHumidityDouble(int field = 0);
00330 
00331     /**
00332      * @brief This function is used to convert the uncompensated
00333      * pressure data to compensated data using compensation formula
00334      * @note Returns pressure in Pa as double.
00335      * @note Output value of "96386.2"
00336      * equals 96386.2 Pa = 963.862 hPa.
00337      *
00338      *
00339      *  @param uncom_pressure_u32 : value of uncompensated pressure
00340      *  @param bme680: structure pointer.
00341      *
00342      *  @return  Return the compensated pressure data in floating point
00343      *
00344     */
00345     double getPressureDouble(int field = 0);
00346 
00347     /**
00348      *  @brief This function is used to convert temperature to resistance
00349      *  using the compensation formula
00350      *
00351      *  @param heater_temp_u16: The value of heater temperature
00352      *  @param ambient_temp_s16: The value of ambient temperature
00353      *  @param bme680: structure pointer.
00354      *
00355      *  @return calculated resistance from temperature
00356      *
00357      *
00358      *
00359     */
00360     double convertTemperatureResistanceDouble(uint16_t heater, int16_t ambient);
00361 
00362     /**
00363      *  @brief This function is used to convert uncompensated gas data to
00364      *  compensated gas data using compensation formula
00365      *
00366      *  @param gas_adc_u16: The value of gas resistance calculated
00367      *       using temperature
00368      *  @param gas_range_u8: The value of gas range form register value
00369      *  @param bme680: structure pointer.
00370      *
00371      *  @return calculated compensated gas from compensation formula
00372      *  @retval compensated gas
00373      *
00374      *
00375     */
00376     double getCalculateGasDouble(int field = 0);
00377 #endif
00378 
00379 
00380     /**
00381     * [press_msb] [press_lsb] [press_xlsb]
00382     * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
00383     * named field0, field1, and field2. The data fields are updated sequentially and always results of
00384     * the three latest measurements are available for the user; if the last but one conversion was written
00385     * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
00386     * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
00387     * data if update of the data registers comes simultaneously with serial interface reading out.
00388     * Note: Only field0 will be updated in forced mode
00389     * @param field 0-2
00390     */
00391     uint32_t getUncompensatedPressureData(int field = 0);
00392 
00393     /**
00394     * [temp1_msb] [temp1_lsb] [temp1_xlsb]
00395     * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
00396     * named field0, field1, and field2. The data fields are updated sequentially and always results of
00397     * the three latest measurements are available for the user; if the last but one conversion was written
00398     * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
00399     * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
00400     * data if update of the data registers comes simultaneously with serial interface reading out.
00401     * Note: Only field0 will be updated in forced mode
00402     * @param field 0-2
00403     */
00404     uint32_t getUncompensatedTemp1Data(int field = 0);
00405 
00406     /**
00407     * [hum_msb] [hum_lsb]
00408     * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
00409     * named field0, field1, and field2. The data fields are updated sequentially and always results of
00410     * the three latest measurements are available for the user; if the last but one conversion was written
00411     * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
00412     * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
00413     * data if update of the data registers comes simultaneously with serial interface reading out.
00414     * Note: Only field0 will be updated in forced mode
00415     * @param field 0-2
00416     */
00417     uint32_t getUncompensatedHumidityData(int field = 0);
00418 
00419     /**
00420     * [gas_rl]
00421     * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
00422     * named field0, field1, and field2. The data fields are updated sequentially and always results of
00423     * the three latest measurements are available for the user; if the last but one conversion was written
00424     * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
00425     * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
00426     * data if update of the data registers comes simultaneously with serial interface reading out.
00427     * Note: Only field0 will be updated in forced mode
00428     * @param field 0-2
00429     */
00430     uint16_t getUncompensatedGasResistanceData(int field = 0);
00431 
00432     /**
00433     * [gas_range_rl]
00434     * Pressure, temperature, humidity and gas data of BME680 are stored in 3 data field registers
00435     * named field0, field1, and field2. The data fields are updated sequentially and always results of
00436     * the three latest measurements are available for the user; if the last but one conversion was written
00437     * to field number k, the current conversion results are written to field with number (k+1) mod 3. All
00438     * data outputs from data fields are buffered using shadowing registers to ensure keeping stable
00439     * data if update of the data registers comes simultaneously with serial interface reading out.
00440     * Contains ADC range of measured gas resistance
00441     * Note: Only field0 will be updated in forced mode
00442     * @param field 0-2
00443     */
00444     uint8_t getGasResistanceRange(int field = 0);
00445 
00446 
00447     // STATUS #########################################################################
00448 
00449     /**
00450     * [new_data_x]
00451     * The measured data are stored into the output data registers at the end of each TPHG conversion
00452     * phase along with status flags and index of measurement. The part of the register map for output
00453     * data storage is composed of 3 data fields (TPHG data field0|1|2)) keeping results from the last 3
00454     * measurements. Availability of new (yet unread) results is indicated by new_data_0|1|2 flags.
00455     * @param field 0-2
00456     */
00457     bool isNewData(int field = 0);
00458 
00459     /**
00460     * [gas_measuring]
00461     * Measuring bit is set to “1‟ only during gas measurements, goes to “0‟ as soon as measurement
00462     * is completed and data transferred to data registers. The registers storing the configuration values
00463     * for the measurement (gas_wait_shared, gas_wait_x, res_heat_x, idac_heat_x, image registers)
00464     * should not be changed when the device is measuring.
00465     * @param field 0-2
00466     */
00467     bool isGasMeasuring(int field = 0);
00468 
00469     /**
00470     * [measuring]
00471     * Measuring status will be set to ‘1’ whenever a conversion (Pressure, Temperature, humidity &
00472     * gas) is running and back to ‘0’ when the results have been transferred to the data registers.
00473     * @param field 0-2
00474     */
00475     bool isMeasuring(int field = 0);
00476 
00477     /**
00478     * [gas_meas_index_x]
00479     * User can program a sequence of up to 10 conversions by setting nb_conv<3:0>. Each conversion
00480     * has its own heater resistance target but 3 field registers to store conversion results. The actual
00481     * gas conversion number in the measurement sequence (up to 10 conversions numbered from 0
00482     * to 9) is stored in gas_meas_index register.
00483     * @param field 0-2
00484     */
00485     int getGasMeasurementIndex(int field = 0);
00486 
00487     /**
00488     * [sub_meas_index_x]
00489     * sub_meas_index_x registers form “virtual time sensor” and contain a snapshot of the internal 8
00490     * bit conversion counter. Conversion counter is incremented with each TPHG conversion; the
00491     * counter thus contains the number of conversions modulo 256 executed since the last change of
00492     * device mode.
00493     * Note: This index is incremented only if gas conversion is active.
00494     * @param field 0-2
00495     */
00496     int getSubMeasurementIndex(int field = 0);
00497 
00498     /**
00499     * [gas_valid_rl]
00500     * In parallel mode, each TPHG sequence contains a gas measurement slot, either a real one which
00501     * result is used or a dummy one to keep a constant sampling rate and predictable device timing. A
00502     * real gas conversion (i.e., not a dummy one) is indicated by the gas_valid_rl status register.
00503     * @param field 0-2
00504     */
00505     bool isGasValid(int field = 0);
00506 
00507     /**
00508     * [heat_stab_rl]
00509     * Heater temperature stability for target heater resistance is indicated heat_stab_x status bits.
00510     * @param field 0-2
00511     */
00512     bool isHeaterStable(int field = 0);
00513 
00514     // GAS CONTROL #########################################################################
00515 
00516     /**
00517     * [idac_heat_x]
00518     * BME680 contains a heater control block that will inject enough current into the heater resistance
00519     * to achieve the requested heater temperature. There is a control loop which periodically measures
00520     * heater resistance value and adapts the value of current injected from a DAC.
00521     * BME680 heater operation could be speeded up by setting an initial heater current for a target
00522     * heater temperature by using register idac_heat_x<7:0>. This step is optional since the control
00523     * loop will find the current after a few iterations anyway.
00524     * Current injected to the heater in mA = (idac_heat_7_1 + 1) / 8
00525     * Where: idac_heat_7_1 = decimal value stored in idac_heat<7:1> (unsigned, value from 0 to 127)
00526     * @param setPoint 0-9
00527     */
00528     uint8_t getHeaterCurrent(int setPoint);
00529 
00530     /**
00531     * [idac_heat_x]
00532     * BME680 contains a heater control block that will inject enough current into the heater resistance
00533     * to achieve the requested heater temperature. There is a control loop which periodically measures
00534     * heater resistance value and adapts the value of current injected from a DAC.
00535     * BME680 heater operation could be speeded up by setting an initial heater current for a target
00536     * heater temperature by using register idac_heat_x<7:0>. This step is optional since the control
00537     * loop will find the current after a few iterations anyway.
00538     * Current injected to the heater in mA = (idac_heat_7_1 + 1) / 8
00539     * Where: idac_heat_7_1 = decimal value stored in idac_heat<7:1> (unsigned, value from 0 to 127)
00540     * @param setPoint 0-9
00541     */
00542     void setHeaterCurrent(int setPoint, uint8_t value);
00543 
00544     /**
00545     * [res_heat_x]
00546     * Target heater resistance is programmed by user through res_heat_x<7:0> registers.
00547     * res_heat_x = 3.4* ((R_Target*(4/4+res_heat_range))-25) / ((res_heat_val * 0.002) + 1))
00548     * Where
00549     * R_Target is the target heater resistance in Ohm
00550     * res_heat_x is the decimal value that needs to be stored in register with same name
00551     * res_heat_range is heater range stored in register address 0x02 <5:4>
00552     * res_heat_val is heater resistance correction factor stored in register address 0x00 (signed, value from -128 to 127)
00553     * @param setPoint 0-9
00554     */
00555     int8_t getTargetHeaterResistance(int setPoint);
00556 
00557     /**
00558     * [res_heat_x]
00559     * Target heater resistance is programmed by user through res_heat_x<7:0> registers.
00560     * res_heat_x = 3.4* ((R_Target*(4/4+res_heat_range))-25) / ((res_heat_val * 0.002) + 1))
00561     * Where
00562     * R_Target is the target heater resistance in Ohm
00563     * res_heat_x is the decimal value that needs to be stored in register with same name
00564     * res_heat_range is heater range stored in register address 0x02 <5:4>
00565     * res_heat_val is heater resistance correction factor stored in register address 0x00 (signed, value from -128 to 127)
00566     * @param setPoint 0-9
00567     */
00568     void setTargetHeaterResistance(int setPoint, int8_t value);
00569 
00570     /**
00571     * [gas_wait_x]
00572     * gas_wait_x controls heater timing of the gas sensor. Functionality of this register will vary based on power modes.
00573     * Forced Mode & Sequential mode
00574     * Time between beginning of heat phase and start of sensor resistance conversion depend on gas_wait_x settings as mentioned below.
00575     * Parallel Mode
00576     * The number of TPHG sub-measurement sequences within the one Gas conversion for one target
00577     * temperature resistance is defined by gas_wait_x settings.
00578     * Note: Please take care about gas_wait_x on shifting modes between parallel & sequential/forced mode as register functionality will change.
00579     * @return result * 0.477 ms
00580     * @param setPoint 0-9
00581     */
00582     int getGasWaitTime(int setPoint);
00583 
00584     /**
00585     * [gas_wait_x]
00586     * gas_wait_x controls heater timing of the gas sensor. Functionality of this register will vary based on power modes.
00587     * Forced Mode & Sequential mode
00588     * Time between beginning of heat phase and start of sensor resistance conversion depend on gas_wait_x settings as mentioned below.
00589     * Parallel Mode
00590     * The number of TPHG sub-measurement sequences within the one Gas conversion for one target
00591     * temperature resistance is defined by gas_wait_x settings.
00592     * Note: Please take care about gas_wait_x on shifting modes between parallel & sequential/forced mode as register functionality will change.
00593     * @return result * 0.477 ms
00594     * @param setPoint 0-9
00595     * @param time 64 timer values with 1ms step sizes, all zeros means no wait.
00596     * @param multiplication [0, 1, 2, 3] -> [1, 4, 16, 64]
00597     */
00598     void setGasWaitTime(int setPoint, int time, int multiplication);
00599 
00600     /**
00601     * [gas_wait_shared]
00602     * The programmable wait time between two TPHG sub-measurement sequences of parallel mode depends on gas_wait_shared settings as follows
00603     */
00604     int getGasWaitShared();
00605 
00606     /**
00607     * [gas_wait_shared]
00608     * The programmable wait time between two TPHG sub-measurement sequences of parallel mode depends on gas_wait_shared settings as follows
00609     * @param setPoint 0-9
00610     * @param time 64 timer values with 0.477 ms step sizes, all zeros means no wait.
00611     * @param multiplication [0x00, 0x01, 0x10, 0x11] -> [1, 4, 16, 64]
00612     */
00613     void setGasWaitShared(int time, int multiplication);
00614 
00615     /**
00616     * [heat_off]
00617     * Turn off current injected to heater
00618     */
00619     void setHeaterOff();
00620 
00621     /**
00622     * [nb_conv]
00623     * is used to select heater set-points of BME680
00624     * Sequential & Parallel Mode
00625     * 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
00626     * gas conversion number in the measurement sequence (up to 10 conversions numbered from 0 to 9) is stored in gas measurement index register
00627     * 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
00628     * @return Sequential & Parallel : number of profiles (0-10), 0 means no gas conversion
00629     * @return Forced : indicates index of heater profile
00630     */
00631     int getHeaterProfile();
00632 
00633     /**
00634     * [nb_conv]
00635     * is used to select heater set-points of BME680
00636     * Sequential & Parallel Mode
00637     * 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
00638     * gas conversion number in the measurement sequence (up to 10 conversions numbered from 0 to 9) is stored in gas measurement index register
00639     * 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
00640     * @param Sequential & Parallel : number of profiles (0-10), 0 means no gas conversion
00641     * @param Forced : indicates index of heater profile
00642     */
00643     void setHeaterProfile(int value);
00644 
00645     /**
00646     * [run_gas_l]
00647     * The gas conversions are started only in appropriate mode if run_gas_l=1
00648     */
00649     void runGasConversion();
00650 
00651     /**
00652     * [odr]
00653     * Wake period in sequential mode – odr
00654     * 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
00655     * @return in ms, 0 means device does not go to standby
00656     */
00657     float getWakePeriod();
00658 
00659     /**
00660     * [odr]
00661     * Wake period in sequential mode – odr
00662     * 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
00663     * @param value : [0 - 8+] [0.59,62.5,125,250,500,1000,10,20,no standby]
00664     */
00665     void setWakePeriod(int value);
00666 
00667     // PRESSURE TEMPERATURE HUMIDITY CONTROL #########################################################################
00668 
00669     /**
00670     * [osrs_h]
00671     * @return value : [0,1,2,4,8,16] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
00672     */
00673     int getOversamplingHumidity();
00674 
00675     /**
00676     * [osrs_h]
00677     * @param value : [0,1,2,3,4,5] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
00678     */
00679     void setOversamplingHumidity(int value);
00680 
00681     /**
00682     * [osrs_p]
00683     * @return value : [0,1,2,4,8,16] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
00684     */
00685     int getOversamplingPressure();
00686 
00687     /**
00688     * [osrs_p]
00689     * @param value : [0,1,2,3,4,5] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
00690     */
00691     void setOversamplingPressure(int value);
00692 
00693     /**
00694     * [osrs_t]
00695     * @return value : [0,1,2,4,8,16] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
00696     */
00697     int getOversamplingTemperature();
00698 
00699     /**
00700     * [osrs_t]
00701     * @param value : [0,1,2,3,4,5] -> [skip,X1,X2,X4,X8,X16], 0 means skipped (output set to 0x8000)
00702     */
00703     void setOversamplingTemperature(int value);
00704 
00705     /**
00706     * [filter]
00707     * IIR filter control
00708     * IIR filter applies to temperature and pressure data but not to humidity and gas data. The data
00709     * coming from the ADC are filtered and then loaded into the data registers. The T, P result registers
00710     * are updated together at the same time at the end of measurement. IIR filter output resolution is
00711     * 20 bits. The T, P result registers are reset to value 0x80000 when the T, P measurements have
00712     * 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
00713     * the first value stored to the T, P result register is filtered.
00714     * @return value : [0,1,3,7,15,31,63,127]
00715     */
00716     int getIIRfilterCoefficient();
00717 
00718     /**
00719     * [filter]
00720     * IIR filter control
00721     * IIR filter applies to temperature and pressure data but not to humidity and gas data. The data
00722     * coming from the ADC are filtered and then loaded into the data registers. The T, P result registers
00723     * are updated together at the same time at the end of measurement. IIR filter output resolution is
00724     * 20 bits. The T, P result registers are reset to value 0x80000 when the T, P measurements have
00725     * 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
00726     * the first value stored to the T, P result register is filtered.
00727     * @param value : [0,1,2,3,4,5,6,7] -> [0,1,3,7,15,31,63,127]
00728     */
00729     void setIIRfilterCoefficient(int value);
00730 
00731     // GENERAL CONTROL #########################################################################
00732 
00733     /**
00734     * [mode]
00735     * Four measurement modes are available for BME680; that is sleep, sequential, parallel and forced
00736     * mode.Four measurement modes are available for BME680; that is sleep, sequential, parallel and forced mode.
00737     * @param mode : [0,1,2,3] -> [Sleep, Forced, Parallel, Sequential]
00738     */
00739     void setMode(int mode);
00740 
00741     /**
00742     * [mode]
00743     * Four measurement modes are available for BME680; that is sleep, sequential, parallel and forced
00744     * mode.Four measurement modes are available for BME680; that is sleep, sequential, parallel and forced mode.
00745     * @return value : [0,1,2,3] -> [Sleep, Forced, Parallel, Sequential]
00746     */
00747     int getMode();
00748 
00749     /**
00750     * [chip_id]
00751     * Chip id of the device, this should give 0x61
00752     */
00753     int getChipID();
00754 };
00755 
00756 #endif