LibDriver BME680
Loading...
Searching...
No Matches
driver_bme680.c File Reference

driver bme680 source file More...

#include "driver_bme680.h"
Include dependency graph for driver_bme680.c:

Go to the source code of this file.

Macros

#define CHIP_NAME   "Bosch BME680"
 chip information definition
#define MANUFACTURER_NAME   "Bosch"
#define SUPPLY_VOLTAGE_MIN   1.71f
#define SUPPLY_VOLTAGE_MAX   3.6f
#define MAX_CURRENT   0.849f
#define TEMPERATURE_MIN   -40.0f
#define TEMPERATURE_MAX   85.0f
#define DRIVER_VERSION   1000
#define BME680_REG_NVM_PAR_T1_L   0xE9
 chip register definition
#define BME680_REG_NVM_PAR_T1_H   0xEA
#define BME680_REG_NVM_PAR_T2_L   0x8A
#define BME680_REG_NVM_PAR_T2_H   0x8B
#define BME680_REG_NVM_PAR_T3   0x8C
#define BME680_REG_NVM_PAR_P1_L   0x8E
#define BME680_REG_NVM_PAR_P1_H   0x8F
#define BME680_REG_NVM_PAR_P2_L   0x90
#define BME680_REG_NVM_PAR_P2_H   0x91
#define BME680_REG_NVM_PAR_P3   0x92
#define BME680_REG_NVM_PAR_P4_L   0x94
#define BME680_REG_NVM_PAR_P4_H   0x95
#define BME680_REG_NVM_PAR_P5_L   0x96
#define BME680_REG_NVM_PAR_P5_H   0x97
#define BME680_REG_NVM_PAR_P6   0x99
#define BME680_REG_NVM_PAR_P7   0x98
#define BME680_REG_NVM_PAR_P8_L   0x9C
#define BME680_REG_NVM_PAR_P8_H   0x9D
#define BME680_REG_NVM_PAR_P9_L   0x9E
#define BME680_REG_NVM_PAR_P9_H   0x9F
#define BME680_REG_NVM_PAR_P10   0xA0
#define BME680_REG_NVM_PAR_H1_L   0xE2
#define BME680_REG_NVM_PAR_H1_H   0xE3
#define BME680_REG_NVM_PAR_H2_L   0xE2
#define BME680_REG_NVM_PAR_H2_H   0xE1
#define BME680_REG_NVM_PAR_H3   0xE4
#define BME680_REG_NVM_PAR_H4   0xE5
#define BME680_REG_NVM_PAR_H5   0xE6
#define BME680_REG_NVM_PAR_H6   0xE7
#define BME680_REG_NVM_PAR_H7   0xE8
#define BME680_REG_NVM_PAR_G1   0xED
#define BME680_REG_NVM_PAR_G2_L   0xEB
#define BME680_REG_NVM_PAR_G2_H   0xEC
#define BME680_REG_NVM_PAR_G3   0xEE
#define BME680_REG_NVM_RES_HEAT_RANGE   0x02
#define BME680_REG_NVM_RES_HEAT_VAL   0x00
#define BME680_REG_NVM_RANGE_SWITCH   0x04
#define BME680_REG_STATUS   0x73
#define BME680_REG_RESET   0xE0
#define BME680_REG_ID   0xD0
#define BME680_REG_CONFIG   0x75
#define BME680_REG_CTRL_MEAS   0x74
#define BME680_REG_CTRL_HUM   0x72
#define BME680_REG_CTRL_GAS_1   0x71
#define BME680_REG_CTRL_GAS_0   0x70
#define BME680_REG_GAS_WAIT_X   0x64
#define BME680_REG_RES_HEAT_X   0x5A
#define BME680_REG_IDAC_HEAT_X   0x50
#define BME680_REG_GAS_R_LSB   0x2B
#define BME680_REG_GAS_R_MSB   0x2A
#define BME680_REG_HUM_LSB   0x26
#define BME680_REG_HUM_MSB   0x25
#define BME680_REG_TEMP_XLSB   0x24
#define BME680_REG_TEMP_LSB   0x23
#define BME680_REG_TEMP_MSB   0x22
#define BME680_REG_PRESS_XLSB   0x21
#define BME680_REG_PRESS_LSB   0x20
#define BME680_REG_PRESS_MSB   0x1F
#define BME680_REG_EAS_STATUS_0   0x1D

Functions

uint8_t bme680_set_addr_pin (bme680_handle_t *handle, bme680_address_t addr_pin)
 set the iic address pin
uint8_t bme680_get_addr_pin (bme680_handle_t *handle, bme680_address_t *addr_pin)
 get the iic address pin
uint8_t bme680_set_interface (bme680_handle_t *handle, bme680_interface_t interface)
 set the interface
uint8_t bme680_get_interface (bme680_handle_t *handle, bme680_interface_t *interface)
 get the interface
uint8_t bme680_init (bme680_handle_t *handle)
 initialize the chip
uint8_t bme680_deinit (bme680_handle_t *handle)
 close the chip
uint8_t bme680_set_idac_heat (bme680_handle_t *handle, uint8_t index, uint8_t reg)
 set idac heat
uint8_t bme680_get_idac_heat (bme680_handle_t *handle, uint8_t index, uint8_t *reg)
 get idac heat
uint8_t bme680_set_resistance_heat (bme680_handle_t *handle, uint8_t index, uint8_t reg)
 set resistance heat
uint8_t bme680_get_resistance_heat (bme680_handle_t *handle, uint8_t index, uint8_t *reg)
 get resistance heat
uint8_t bme680_set_gas_wait (bme680_handle_t *handle, uint8_t index, uint8_t reg)
 set gas wait
uint8_t bme680_get_gas_wait (bme680_handle_t *handle, uint8_t index, uint8_t *reg)
 get gas wait
uint8_t bme680_soft_reset (bme680_handle_t *handle)
 soft reset
uint8_t bme680_get_new_data_status (bme680_handle_t *handle, bme680_bool_t *enable)
 get new data status
uint8_t bme680_get_gas_measuring_status (bme680_handle_t *handle, bme680_bool_t *enable)
 get gas measuring status
uint8_t bme680_get_measuring_status (bme680_handle_t *handle, bme680_bool_t *enable)
 get measuring status
uint8_t bme680_get_gas_measuring_index (bme680_handle_t *handle, uint8_t *index)
 get gas measuring index
uint8_t bme680_get_gas_valid_status (bme680_handle_t *handle, bme680_bool_t *enable)
 get gas valid status
uint8_t bme680_get_heater_stability_status (bme680_handle_t *handle, bme680_bool_t *enable)
 get heater stability status
uint8_t bme680_set_spi_wire_3_data_interrupt (bme680_handle_t *handle, bme680_bool_t enable)
 enable or disable spi wire3 data interrupt
uint8_t bme680_get_spi_wire_3_data_interrupt (bme680_handle_t *handle, bme680_bool_t *enable)
 get spi wire3 data interrupt status
uint8_t bme680_set_humidity_oversampling (bme680_handle_t *handle, bme680_oversampling_t oversampling)
 set humidity oversampling
uint8_t bme680_get_humidity_oversampling (bme680_handle_t *handle, bme680_oversampling_t *oversampling)
 get humidity oversampling
uint8_t bme680_set_temperature_oversampling (bme680_handle_t *handle, bme680_oversampling_t oversampling)
 set temperature oversampling
uint8_t bme680_get_temperature_oversampling (bme680_handle_t *handle, bme680_oversampling_t *oversampling)
 get temperature oversampling
uint8_t bme680_set_pressure_oversampling (bme680_handle_t *handle, bme680_oversampling_t oversampling)
 set pressure oversampling
uint8_t bme680_get_pressure_oversampling (bme680_handle_t *handle, bme680_oversampling_t *oversampling)
 get pressure oversampling
uint8_t bme680_set_mode (bme680_handle_t *handle, bme680_mode_t mode)
 set mode
uint8_t bme680_get_mode (bme680_handle_t *handle, bme680_mode_t *mode)
 get mode
uint8_t bme680_set_filter (bme680_handle_t *handle, bme680_filter_t filter)
 set filter
uint8_t bme680_get_filter (bme680_handle_t *handle, bme680_filter_t *filter)
 get filter
uint8_t bme680_set_spi_wire (bme680_handle_t *handle, bme680_spi_wire_t spi)
 set spi wire
uint8_t bme680_get_spi_wire (bme680_handle_t *handle, bme680_spi_wire_t *spi)
 get spi wire
uint8_t bme680_set_heat_off (bme680_handle_t *handle, bme680_bool_t enable)
 enable or disable heat off
uint8_t bme680_get_heat_off (bme680_handle_t *handle, bme680_bool_t *enable)
 get heat off status
uint8_t bme680_set_run_gas (bme680_handle_t *handle, bme680_bool_t enable)
 enable or disable run gas
uint8_t bme680_get_run_gas (bme680_handle_t *handle, bme680_bool_t *enable)
 get run gas status
uint8_t bme680_set_convert_index (bme680_handle_t *handle, uint8_t index)
 set convert index
uint8_t bme680_get_convert_index (bme680_handle_t *handle, uint8_t *index)
 get convert index
uint8_t bme680_resistance_heat_convert_to_register (bme680_handle_t *handle, float degree_celsius, uint8_t *reg)
 convert the resistance heat to the register raw data
uint8_t bme680_idac_heat_convert_to_register (bme680_handle_t *handle, float ma, uint8_t *reg)
 convert the idac heat to the register raw data
uint8_t bme680_idac_heat_convert_to_data (bme680_handle_t *handle, uint8_t reg, float *ma)
 convert the register raw data to idac heat
uint8_t bme680_gas_wait_convert_to_register (bme680_handle_t *handle, uint16_t ms, uint8_t *reg)
 convert the gas wait to the register raw data
uint8_t bme680_read_gas_resistance (bme680_handle_t *handle, uint16_t *adc_raw, uint8_t *adc_range, float *ohms, uint8_t *index)
 read the gas resistance
uint8_t bme680_read_pressure (bme680_handle_t *handle, uint32_t *pressure_raw, float *pressure_pa)
 read the pressure data
uint8_t bme680_read_temperature (bme680_handle_t *handle, uint32_t *temperature_raw, float *temperature_c)
 read the temperature data
uint8_t bme680_read_humidity (bme680_handle_t *handle, uint32_t *humidity_raw, float *humidity_percentage)
 read the humidity data
uint8_t bme680_read_temperature_pressure_humidity (bme680_handle_t *handle, uint32_t *temperature_raw, float *temperature_c, uint32_t *pressure_raw, float *pressure_pa, uint32_t *humidity_raw, float *humidity_percentage)
 read the temperature pressure and humidity data
uint8_t bme680_read (bme680_handle_t *handle, uint32_t *temperature_raw, float *temperature_c, uint32_t *pressure_raw, float *pressure_pa, uint32_t *humidity_raw, float *humidity_percentage, uint16_t *adc_raw, uint8_t *adc_range, float *ohms, uint8_t *index)
 read the temperature pressure humidity and gas resistance
uint8_t bme680_set_reg (bme680_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 set the chip register
uint8_t bme680_get_reg (bme680_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 get the chip register
uint8_t bme680_info (bme680_info_t *info)
 get chip's information

Detailed Description

driver bme680 source file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2025-07-15

history

Date Version Author Description
2025/07/15 1.0 Shifeng Li first upload

Definition in file driver_bme680.c.

Macro Definition Documentation

◆ BME680_REG_CONFIG

#define BME680_REG_CONFIG   0x75

config register

Definition at line 94 of file driver_bme680.c.

◆ BME680_REG_CTRL_GAS_0

#define BME680_REG_CTRL_GAS_0   0x70

control gas0 register

Definition at line 98 of file driver_bme680.c.

◆ BME680_REG_CTRL_GAS_1

#define BME680_REG_CTRL_GAS_1   0x71

control gas1 register

Definition at line 97 of file driver_bme680.c.

◆ BME680_REG_CTRL_HUM

#define BME680_REG_CTRL_HUM   0x72

control humidity register

Definition at line 96 of file driver_bme680.c.

◆ BME680_REG_CTRL_MEAS

#define BME680_REG_CTRL_MEAS   0x74

control meas register

Definition at line 95 of file driver_bme680.c.

◆ BME680_REG_EAS_STATUS_0

#define BME680_REG_EAS_STATUS_0   0x1D

eas status 0 register

Definition at line 112 of file driver_bme680.c.

◆ BME680_REG_GAS_R_LSB

#define BME680_REG_GAS_R_LSB   0x2B

gas r lsb register

Definition at line 102 of file driver_bme680.c.

◆ BME680_REG_GAS_R_MSB

#define BME680_REG_GAS_R_MSB   0x2A

gas r msb register

Definition at line 103 of file driver_bme680.c.

◆ BME680_REG_GAS_WAIT_X

#define BME680_REG_GAS_WAIT_X   0x64

gas wait x register

Definition at line 99 of file driver_bme680.c.

◆ BME680_REG_HUM_LSB

#define BME680_REG_HUM_LSB   0x26

hum lsb register

Definition at line 104 of file driver_bme680.c.

◆ BME680_REG_HUM_MSB

#define BME680_REG_HUM_MSB   0x25

hum msb register

Definition at line 105 of file driver_bme680.c.

◆ BME680_REG_ID

#define BME680_REG_ID   0xD0

id register

Definition at line 93 of file driver_bme680.c.

◆ BME680_REG_IDAC_HEAT_X

#define BME680_REG_IDAC_HEAT_X   0x50

idac heat x register

Definition at line 101 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_G1

#define BME680_REG_NVM_PAR_G1   0xED

NVM PAR G1 register

Definition at line 84 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_G2_H

#define BME680_REG_NVM_PAR_G2_H   0xEC

NVM PAR G2 high register

Definition at line 86 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_G2_L

#define BME680_REG_NVM_PAR_G2_L   0xEB

NVM PAR G2 low register

Definition at line 85 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_G3

#define BME680_REG_NVM_PAR_G3   0xEE

NVM PAR G3 register

Definition at line 87 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_H1_H

#define BME680_REG_NVM_PAR_H1_H   0xE3

NVM PAR H1 high register

Definition at line 76 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_H1_L

#define BME680_REG_NVM_PAR_H1_L   0xE2

NVM PAR H1 low register

Definition at line 75 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_H2_H

#define BME680_REG_NVM_PAR_H2_H   0xE1

NVM PAR H2 high register

Definition at line 78 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_H2_L

#define BME680_REG_NVM_PAR_H2_L   0xE2

NVM PAR H2 low register

Definition at line 77 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_H3

#define BME680_REG_NVM_PAR_H3   0xE4

NVM PAR H3 register

Definition at line 79 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_H4

#define BME680_REG_NVM_PAR_H4   0xE5

NVM PAR H4 register

Definition at line 80 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_H5

#define BME680_REG_NVM_PAR_H5   0xE6

NVM PAR H5 register

Definition at line 81 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_H6

#define BME680_REG_NVM_PAR_H6   0xE7

NVM PAR H6 register

Definition at line 82 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_H7

#define BME680_REG_NVM_PAR_H7   0xE8

NVM PAR H7 register

Definition at line 83 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P10

#define BME680_REG_NVM_PAR_P10   0xA0

NVM PAR P10 register

Definition at line 74 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P1_H

#define BME680_REG_NVM_PAR_P1_H   0x8F

NVM PAR P1 high register

Definition at line 60 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P1_L

#define BME680_REG_NVM_PAR_P1_L   0x8E

NVM PAR P1 low register

Definition at line 59 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P2_H

#define BME680_REG_NVM_PAR_P2_H   0x91

NVM PAR P2 high register

Definition at line 62 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P2_L

#define BME680_REG_NVM_PAR_P2_L   0x90

NVM PAR P2 low register

Definition at line 61 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P3

#define BME680_REG_NVM_PAR_P3   0x92

NVM PAR P3 register

Definition at line 63 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P4_H

#define BME680_REG_NVM_PAR_P4_H   0x95

NVM PAR P4 high register

Definition at line 65 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P4_L

#define BME680_REG_NVM_PAR_P4_L   0x94

NVM PAR P4 low register

Definition at line 64 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P5_H

#define BME680_REG_NVM_PAR_P5_H   0x97

NVM PAR P5 high register

Definition at line 67 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P5_L

#define BME680_REG_NVM_PAR_P5_L   0x96

NVM PAR P5 low register

Definition at line 66 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P6

#define BME680_REG_NVM_PAR_P6   0x99

NVM PAR P6 register

Definition at line 68 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P7

#define BME680_REG_NVM_PAR_P7   0x98

NVM PAR P7 register

Definition at line 69 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P8_H

#define BME680_REG_NVM_PAR_P8_H   0x9D

NVM PAR P8 high register

Definition at line 71 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P8_L

#define BME680_REG_NVM_PAR_P8_L   0x9C

NVM PAR P8 low register

Definition at line 70 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P9_H

#define BME680_REG_NVM_PAR_P9_H   0x9F

NVM PAR P9 high register

Definition at line 73 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_P9_L

#define BME680_REG_NVM_PAR_P9_L   0x9E

NVM PAR P9 low register

Definition at line 72 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_T1_H

#define BME680_REG_NVM_PAR_T1_H   0xEA

NVM PAR T1 high register

Definition at line 55 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_T1_L

#define BME680_REG_NVM_PAR_T1_L   0xE9

chip register definition

NVM PAR T1 low register

Definition at line 54 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_T2_H

#define BME680_REG_NVM_PAR_T2_H   0x8B

NVM PAR T2 high register

Definition at line 57 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_T2_L

#define BME680_REG_NVM_PAR_T2_L   0x8A

NVM PAR T2 low register

Definition at line 56 of file driver_bme680.c.

◆ BME680_REG_NVM_PAR_T3

#define BME680_REG_NVM_PAR_T3   0x8C

NVM PAR T3 register

Definition at line 58 of file driver_bme680.c.

◆ BME680_REG_NVM_RANGE_SWITCH

#define BME680_REG_NVM_RANGE_SWITCH   0x04

NVM RANGE SWITCH ERROR register

Definition at line 90 of file driver_bme680.c.

◆ BME680_REG_NVM_RES_HEAT_RANGE

#define BME680_REG_NVM_RES_HEAT_RANGE   0x02

NVM RES HEAT RANGE register

Definition at line 88 of file driver_bme680.c.

◆ BME680_REG_NVM_RES_HEAT_VAL

#define BME680_REG_NVM_RES_HEAT_VAL   0x00

NVM RES HEAT VAL register

Definition at line 89 of file driver_bme680.c.

◆ BME680_REG_PRESS_LSB

#define BME680_REG_PRESS_LSB   0x20

press lsb register

Definition at line 110 of file driver_bme680.c.

◆ BME680_REG_PRESS_MSB

#define BME680_REG_PRESS_MSB   0x1F

press msb register

Definition at line 111 of file driver_bme680.c.

◆ BME680_REG_PRESS_XLSB

#define BME680_REG_PRESS_XLSB   0x21

press xlsb register

Definition at line 109 of file driver_bme680.c.

◆ BME680_REG_RES_HEAT_X

#define BME680_REG_RES_HEAT_X   0x5A

res heat x register

Definition at line 100 of file driver_bme680.c.

◆ BME680_REG_RESET

#define BME680_REG_RESET   0xE0

reset register

Definition at line 92 of file driver_bme680.c.

◆ BME680_REG_STATUS

#define BME680_REG_STATUS   0x73

status register

Definition at line 91 of file driver_bme680.c.

◆ BME680_REG_TEMP_LSB

#define BME680_REG_TEMP_LSB   0x23

temp lsb register

Definition at line 107 of file driver_bme680.c.

◆ BME680_REG_TEMP_MSB

#define BME680_REG_TEMP_MSB   0x22

temp msb register

Definition at line 108 of file driver_bme680.c.

◆ BME680_REG_TEMP_XLSB

#define BME680_REG_TEMP_XLSB   0x24

temp xlsb register

Definition at line 106 of file driver_bme680.c.

◆ CHIP_NAME

#define CHIP_NAME   "Bosch BME680"

chip information definition

chip name

Definition at line 42 of file driver_bme680.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 49 of file driver_bme680.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "Bosch"

manufacturer name

Definition at line 43 of file driver_bme680.c.

◆ MAX_CURRENT

#define MAX_CURRENT   0.849f

chip max current

Definition at line 46 of file driver_bme680.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   3.6f

chip max supply voltage

Definition at line 45 of file driver_bme680.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   1.71f

chip min supply voltage

Definition at line 44 of file driver_bme680.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   85.0f

chip max operating temperature

Definition at line 48 of file driver_bme680.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -40.0f

chip min operating temperature

Definition at line 47 of file driver_bme680.c.