BME680 I2C functions using C code

Hello im just wondering if anyone can explain how the I2C functions (read/write) need to be set up for the BME680 sensor and possible any examples? i am using the raspberry pi 4b and just trying to read the sensors values and print them to the screen then save the outcomes in a text file

 

Best reply by BSTRobin

Hello Callum42069,

There was example code in github for BME680, https://github.com/BoschSensortec/BME68x-Sensor-API/blob/master/examples/common/common.c

For I2C read/write function, you need to implement the following functions in bold. There functions were general I2C reading, writing.

BME68X_INTF_RET_TYPE bme68x_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr)
{
uint8_t dev_addr = *(uint8_t*)intf_ptr;

return coines_read_i2c(dev_addr, reg_addr, reg_data, (uint16_t)len);
}

BME68X_INTF_RET_TYPE bme68x_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, void *intf_ptr)
{
uint8_t dev_addr = *(uint8_t*)intf_ptr;

return coines_write_i2c(dev_addr, reg_addr, (uint8_t *)reg_data, (uint16_t)len);
}

View original
7 replies
Resolved