EasyManua.ls Logo

Waveshare NRF52840 - Page 36

Waveshare NRF52840
72 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19 36 / 72
}
BME280 Initialization in main.c
struct bme280_dev dev;
int8_t rslt = BME280_OK;
dev.dev_id = BME280_I2C_ADDR_SEC;
dev.intf = BME280_I2C_INTF;
dev.read = user_i2c_read;
dev.write = user_i2c_write;
dev.delay_ms = user_delay_ms;
//before you init bme280, you can choose to do a selftest
rslt = bme280_crc_selftest(&dev);
if(rslt == 0)
{
NRF_LOG_INFO("BME280 self test pass\r\n");
NRF_LOG_FLUSH();
}
rslt = bme280_init(&dev);
if(rslt == 0)
{
NRF_LOG_INFO("Init Success\r\n");
NRF_LOG_FLUSH();
}
else
{
NRF_LOG_INFO("Init Fail,Please Check your address or the wire
you connected!!!\r\n");
NRF_LOG_FLUSH();
while(1);
}
/*
Using normal mode to read the data
*/
stream_sensor_data_normal_mode(&dev);
bme280_crc_selftest(): Self testing function
stream_sensor_data_normal_mode(&dev): Read data of bme280 and calculate. Use
bme280_get_sensor_data() and print_sensor_data() to read and print_sensor_data().