04-18-2019 05:25 PM
Hi,
I'm new using a Bosch sensor and I want to acess it using "HAL" library.
I have a BME680 sensor and I'm using a Nucleo-144 from ST. I want to use the API in GitHub (https://github.com/BoschSensortec/BME680_driver) but in file "bme680.c" I don't understand how use "read" and "write" called, for example, in function get_mem_page().
In "readme" file there are a template for "int8_t user_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)" and "int8_t user_i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)" but I don´t know how to fill it and where to include it (in main.c? or bme680.c?). Can someone explain it?
Best resgard.
06-04-2020 05:04 PM
It is not clear if your issue is related to the case above, therefore I would suggest creating your own thread/topic.
Some information are missing to support your issue here, for instance:
07-24-2020 08:01 PM
Hi
A seperate note here:
in case you don't want to spend too much time on debugging the i2c communication issues, a much easier way is to use an Arduino board to work with BME680 sensor.
The key is that every Arduino board uses the same APIs for I2C communication and this abstraction make it much more consistent and easier to get started.
Once you have the Arduino board, you could refer to example made available by Adafruit here:
https://github.com/adafruit/Adafruit_BME680
specifically the source code https://github.com/adafruit/Adafruit_BME680/blob/master/Adafruit_BME680.cpp contains a working example of how the read/write are setup by wrapping around the Arduino I2C APIs.
``
bool Adafruit_BME680::begin(uint8_t addr, bool initSettings) {
_i2caddr = addr;
if (_cs == -1) {
// i2c
_wire->begin();
gas_sensor.dev_id = addr;
gas_sensor.intf = BME680_I2C_INTF;
gas_sensor.read = &i2c_read;
gas_sensor.write = &i2c_write;
}
``
}
``
I used this, and it works like a breeze. Hope this helps.
12-21-2020 09:55 AM - edited 12-21-2020 09:57 AM
if (HAL_I2C_Master_Transmit(&hi2c4, (dev_id << 1), ®_addr, 1, 10)!= HAL_OK)
04-01-2021 01:28 PM
Hi Sir ,
I follow all your suggetions can you share your code for user i2c read & write
for your ref Ifollow this lib https://github.com/BoschSensortec/BME680_driver