Help on reading sensors: bme280_set_mode

Hi!
Is there any tutorial or help devoted to sensors of ruuvitag?
I am trying to read sensors in a new project (not a sample but I looked to firmware sample)
I have this code:
…
int main(void)
{
uint32_t err_code;
err_code = NRF_LOG_INIT(NULL);APP_ERROR_CHECK(err_code);

APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
APP_ERROR_CHECK(err_code);

init_sensors();

ble_stack_init();

//TIMER (now with RTC due to cle_stack_init call)
init_timer(main_timer_id, MAIN_LOOP_INTERVAL_RAW, main_timer_handler);
app_timer_stop(main_timer_id);
//app_timer_start(main_timer_id, APP_TIMER_TICKS(MAIN_LOOP_INTERVAL_RAW, RUUVITAG_APP_TIMER_PRESCALER), NULL); // 1 event / 1000 ms
app_timer_start(main_timer_id, 32768, NULL); // 1 event / 1000 ms 

bme280_set_oversampling_hum(BME280_HUMIDITY_OVERSAMPLING);
bme280_set_oversampling_temp(BME280_TEMPERATURE_OVERSAMPLING);
bme280_set_oversampling_press(BME280_PRESSURE_OVERSAMPLING);
bme280_set_iir(BME280_IIR);
bme280_set_interval(BME280_DELAY);

bme280_set_mode(BME280_MODE_NORMAL);

init_watchdog(NULL);


advertising_init();
advertising_start();

// Enter main loop.
for (;; )
{
     power_manage();
}

Then, in the main_timer_handler() I call:

bme280_read_measurements();
raw_t = bme280_get_temperature();
raw_p = bme280_get_pressure();
raw_h = bme280_get_humidity();

but program hangs in bme280_read_measurements()


what could be the reason for this?

Note: no debug facility, I am flashing tag using mobile phone.

Thanks a lot

Alex

You really should get yourself a Ruuvi Devkit for developing. It’s enough to have nRF52 devkit and a TagConnect cable if debug connection is enough.

Ruuvi Blog has a lot of posts related to sensor development, Environmental Sensing post would be most related to your use-case.

I think your issue is that SPI is not initialized, so the BME280 driver will hang.