I use to work with libraries for sensors like this one
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme280;
uint8_t BME280_Init(uint8_t slave_addr)
{
uint8_t result;
Wire.setClock(400000);
if (slave_addr == 0)
result = bme280.begin();
else
result = bme280.begin(slave_addr);
return result;
}
Now when I call BME280_Init I’m stuck, looks like a hard fault exception.