2019-08-16 09:08 AM
I am trying to read data from from BMP 280 bosch sensor but could not able to do , Any expertise on I2C/ Bosch sensor please?
I could able to communicate with my sensor by checking if the device address is right or wrong using function : HAL_I2C_IsDeviceReady(&hi2c1, 0xED,2,10). But I would like to read humidity and temperature from the sensor, I used the following functions but of no use.
HAL_I2C_Master_Transmit(&hi2c1, 0XEC,buffer, 1,100);
and HAL_I2C_Master_Receive( above parameters) ;
didnt get the data in buffer so used memory write and read in i2c but of no use!!
HAL_I2C_Mem_Write(&hi2c1, 0xEC,0XFD, 1, buffer, 1, 100);
Below I have attached the data sheet of Bosch sensor, I am aware to some extent that inorder to receive data of humidity sensor i have to write the register 0XFD and for Temperature has to write data to register 0XFA
Bosch also have drivers for this sensor, Do I need to use these drivers to get the data of temperature ? or HAL's API is sufficient? I am learning ,I do not know how to proceed! I had a glance of files of Bosch drivers, again do not know which functions to be used to get the value of Temperature from driver files of Bosch sensor.
https://github.com/BoschSensortec/BMP280_driver/tree/master/examples
Using STM32F0 discovery kit via I2c,
Any insights are much appreciated.
2019-08-16 09:56 AM
Should be able to use the HAL API to do a memory read, and read one or several of the registers back.
Bosch code may help combine registers to useful and scaled data.
2019-08-16 11:21 AM
uint8_t buffer[1];
HAL_I2C_Mem_Read(&hi2c1, 0xEC, 0xFD, 1, buffer, 1, 100); // Read 1-byte from internal reg 0xFD
uint8_t buffer[8];
HAL_I2C_Mem_Read(&hi2c1, 0xEC, 0x20, 1, buffer, 8, 100); // Read 1-bytes starting from internal reg 0x20 and auto-incrementing