-# BME280 sensor API
-## Introduction
-This package contains the Bosch Sensortec's BME280 pressure sensor driver (sensor API)
-
-The sensor driver package includes bme280.c, bme280.h and bme280_defs.h files.
-
-## Version
-File | Version | Date
---------------|---------|------------
-bme280.c | 3.3.6 | 08 Mar 2019
-bme280.h | 3.3.6 | 08 Mar 2019
-bme280_defs.h | 3.3.6 | 08 Mar 2019
-
-## Integration details
-* Integrate bme280.h, bme280_defs.h and bme280.c file in to the project.
-* Include the bme280.h file in your code like below.
-``` c
-#include "bme280.h"
-```
-
-## File information
-* bme280_defs.h : This header file has the constants, macros and datatype declarations.
-* bme280.h : This header file contains the declarations of the sensor driver APIs.
-* bme280.c : This source file contains the definitions of the sensor driver APIs.
-
-## Supported sensor interfaces
-* SPI 4-wire
-* I2C
-
-SPI 3-wire is currently not supported in the API.
-## Usage guide
-### Initializing the sensor
-To initialize the sensor, user need to create a device structure. User can do this by
-creating an instance of the structure bme280_dev. After creating the device strcuture, user
-need to fill in the various parameters as shown below.
-
-#### Example for SPI 4-Wire
-``` c
-struct bme280_dev dev;
-int8_t rslt = BME280_OK;
-
-/* Sensor_0 interface over SPI with native chip select line */
-dev.dev_id = 0;
-dev.intf = BME280_SPI_INTF;
-dev.read = user_spi_read;
-dev.write = user_spi_write;
-dev.delay_ms = user_delay_ms;
-
-rslt = bme280_init(&dev);
-```
-#### Example for I2C
-``` c
-struct bme280_dev dev;
-int8_t rslt = BME280_OK;
-
-dev.dev_id = BME280_I2C_ADDR_PRIM;
-dev.intf = BME280_I2C_INTF;
-dev.read = user_i2c_read;
-dev.write = user_i2c_write;
-dev.delay_ms = user_delay_ms;
-
-rslt = bme280_init(&dev);
-```
-Regarding compensation functions for temperature,pressure and humidity we have two implementations.
-1) Double precision floating point version
-2) Integer version
-
-By default, integer version is used in the API. If the user needs the floating point version, the user has to uncomment BME280_FLOAT_ENABLE macro in bme280_defs.h file or add that to the compiler flags.
-
-In integer compensation functions, we also have below two implementations for pressure.
-1) For 32 bit machine.
-2) For 64 bit machine.
-
-By default, 64 bit variant is used in the API. If the user wants 32 bit variant, the user can disable the
-macro BME280_64BIT_ENABLE in bme280_defs.h file.
-
-### Sensor data units
-> The sensor data units depends on the following macros being enabled or not,
-> (in bme280_defs.h file or as compiler macros)
-> * BME280_FLOAT_ENABLE
-> * BME280_64BIT_ENABLE
-
-In case of the macro "BME280_FLOAT_ENABLE" enabled,
-The outputs are in double and the units are
-
- - °C for temperature
- - % relative humidity
- - Pascal for pressure
-
-In case if "BME280_FLOAT_ENABLE" is not enabled, then it is
-
- - int32_t for temperature with the units 100 * °C
- - uint32_t for humidity with the units 1024 * % relative humidity
- - uint32_t for pressure
- If macro "BME280_64BIT_ENABLE" is enabled, which it is by default, the unit is 100 * Pascal
- If this macro is disabled, Then the unit is in Pascal
-
-### Stream sensor data
-#### Stream sensor data in forced mode
-
-``` c
-int8_t stream_sensor_data_forced_mode(struct bme280_dev *dev)
-{
- int8_t rslt;
- uint8_t settings_sel;
- struct bme280_data comp_data;
-
- /* Recommended mode of operation: Indoor navigation */
- dev->settings.osr_h = BME280_OVERSAMPLING_1X;
- dev->settings.osr_p = BME280_OVERSAMPLING_16X;
- dev->settings.osr_t = BME280_OVERSAMPLING_2X;
- dev->settings.filter = BME280_FILTER_COEFF_16;
-
- settings_sel = BME280_OSR_PRESS_SEL | BME280_OSR_TEMP_SEL | BME280_OSR_HUM_SEL | BME280_FILTER_SEL;
-
- rslt = bme280_set_sensor_settings(settings_sel, dev);
-
- printf("Temperature, Pressure, Humidity\r\n");
- /* Continuously stream sensor data */
- while (1) {
- rslt = bme280_set_sensor_mode(BME280_FORCED_MODE, dev);
- /* Wait for the measurement to complete and print data @25Hz */
- dev->delay_ms(40);
- rslt = bme280_get_sensor_data(BME280_ALL, &comp_data, dev);
- print_sensor_data(&comp_data);
- }
- return rslt;
-}
-
-void print_sensor_data(struct bme280_data *comp_data)
-{
-#ifdef BME280_FLOAT_ENABLE
- printf("%0.2f, %0.2f, %0.2f\r\n",comp_data->temperature, comp_data->pressure, comp_data->humidity);
-#else
- printf("%ld, %ld, %ld\r\n",comp_data->temperature, comp_data->pressure, comp_data->humidity);
-#endif
-}
-```
-##### Stream sensor data in normal mode
-``` c
-int8_t stream_sensor_data_normal_mode(struct bme280_dev *dev)
-{
- int8_t rslt;
- uint8_t settings_sel;
- struct bme280_data comp_data;
-
- /* Recommended mode of operation: Indoor navigation */
- dev->settings.osr_h = BME280_OVERSAMPLING_1X;
- dev->settings.osr_p = BME280_OVERSAMPLING_16X;
- dev->settings.osr_t = BME280_OVERSAMPLING_2X;
- dev->settings.filter = BME280_FILTER_COEFF_16;
- dev->settings.standby_time = BME280_STANDBY_TIME_62_5_MS;
-
- settings_sel = BME280_OSR_PRESS_SEL;
- settings_sel |= BME280_OSR_TEMP_SEL;
- settings_sel |= BME280_OSR_HUM_SEL;
- settings_sel |= BME280_STANDBY_SEL;
- settings_sel |= BME280_FILTER_SEL;
- rslt = bme280_set_sensor_settings(settings_sel, dev);
- rslt = bme280_set_sensor_mode(BME280_NORMAL_MODE, dev);
-
- printf("Temperature, Pressure, Humidity\r\n");
- while (1) {
- /* Delay while the sensor completes a measurement */
- dev->delay_ms(70);
- rslt = bme280_get_sensor_data(BME280_ALL, &comp_data, dev);
- print_sensor_data(&comp_data);
- }
-
- return rslt;
-}
-
-void print_sensor_data(struct bme280_data *comp_data)
-{
-#ifdef BME280_FLOAT_ENABLE
- printf("%0.2f, %0.2f, %0.2f\r\n",comp_data->temperature, comp_data->pressure, comp_data->humidity);
-#else
- printf("%ld, %ld, %ld\r\n",comp_data->temperature, comp_data->pressure, comp_data->humidity);
-#endif
-}
-```
-
-### Templates for function pointers
-``` c
-
-void user_delay_ms(uint32_t period)
-{
- /*
- * Return control or wait,
- * for a period amount of milliseconds
- */
-}
-
-int8_t user_spi_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
-{
- int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */
-
- /*
- * The parameter dev_id can be used as a variable to select which Chip Select pin has
- * to be set low to activate the relevant device on the SPI bus
- */
-
- /*
- * Data on the bus should be like
- * |----------------+---------------------+-------------|
- * | MOSI | MISO | Chip Select |
- * |----------------+---------------------|-------------|
- * | (don't care) | (don't care) | HIGH |
- * | (reg_addr) | (don't care) | LOW |
- * | (don't care) | (reg_data[0]) | LOW |
- * | (....) | (....) | LOW |
- * | (don't care) | (reg_data[len - 1]) | LOW |
- * | (don't care) | (don't care) | HIGH |
- * |----------------+---------------------|-------------|
- */
-
- return rslt;
-}
-
-int8_t user_spi_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
-{
- int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */
-
- /*
- * The parameter dev_id can be used as a variable to select which Chip Select pin has
- * to be set low to activate the relevant device on the SPI bus
- */
-
- /*
- * Data on the bus should be like
- * |---------------------+--------------+-------------|
- * | MOSI | MISO | Chip Select |
- * |---------------------+--------------|-------------|
- * | (don't care) | (don't care) | HIGH |
- * | (reg_addr) | (don't care) | LOW |
- * | (reg_data[0]) | (don't care) | LOW |
- * | (....) | (....) | LOW |
- * | (reg_data[len - 1]) | (don't care) | LOW |
- * | (don't care) | (don't care) | HIGH |
- * |---------------------+--------------|-------------|
- */
-
- return rslt;
-}
-
-int8_t user_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
-{
- int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */
-
- /*
- * The parameter dev_id can be used as a variable to store the I2C address of the device
- */
-
- /*
- * Data on the bus should be like
- * |------------+---------------------|
- * | I2C action | Data |
- * |------------+---------------------|
- * | Start | - |
- * | Write | (reg_addr) |
- * | Stop | - |
- * | Start | - |
- * | Read | (reg_data[0]) |
- * | Read | (....) |
- * | Read | (reg_data[len - 1]) |
- * | Stop | - |
- * |------------+---------------------|
- */
-
- return rslt;
-}
-
-int8_t user_i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
-{
- int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */
-
- /*
- * The parameter dev_id can be used as a variable to store the I2C address of the device
- */
-
- /*
- * Data on the bus should be like
- * |------------+----------------------|
- * | I2C action | Data |
- * |------------+----------------------|
- * | Start | - |
- * | Write | (reg_addr) |
- * | Write | (reg_data[0]) |
- * | Write | (reg_addr + 1) |
- * | Write | (reg_data[1]) |
- * | Write | (....) |
- * | Write | (reg_addr + len - 1) |
- * | Write | (reg_data[len - 1]) |
- * | Stop | - |
- * |------------+----------------------|
- */
-
- return rslt;
-}
-
-```
-
-## Copyright (C) 2016 - 2017 Bosch Sensortec GmbH
+# BME280 sensor API\r
+## Introduction\r
+This package contains the Bosch Sensortec's BME280 pressure sensor driver (sensor API)\r
+\r
+The sensor driver package includes bme280.c, bme280.h and bme280_defs.h files.\r
+\r
+## Version\r
+File | Version | Date\r
+--------------|---------|------------\r
+bme280.c | 3.3.7 | 26 Aug 2019\r
+bme280.h | 3.3.7 | 26 Aug 2019\r
+bme280_defs.h | 3.3.7 | 26 Aug 2019\r
+\r
+## Integration details\r
+* Integrate bme280.h, bme280_defs.h and bme280.c file in to the project.\r
+* Include the bme280.h file in your code like below.\r
+``` c\r
+#include "bme280.h"\r
+```\r
+\r
+## File information\r
+* bme280_defs.h : This header file has the constants, macros and datatype declarations.\r
+* bme280.h : This header file contains the declarations of the sensor driver APIs.\r
+* bme280.c : This source file contains the definitions of the sensor driver APIs.\r
+\r
+## Supported sensor interfaces\r
+* SPI 4-wire\r
+* I2C\r
+\r
+SPI 3-wire is currently not supported in the API.\r
+## Usage guide\r
+### Initializing the sensor\r
+To initialize the sensor, user need to create a device structure. User can do this by \r
+creating an instance of the structure bme280_dev. After creating the device strcuture, user \r
+need to fill in the various parameters as shown below.\r
+\r
+#### Example for SPI 4-Wire\r
+``` c\r
+struct bme280_dev dev;\r
+int8_t rslt = BME280_OK;\r
+\r
+/* Sensor_0 interface over SPI with native chip select line */\r
+dev.dev_id = 0;\r
+dev.intf = BME280_SPI_INTF;\r
+dev.read = user_spi_read;\r
+dev.write = user_spi_write;\r
+dev.delay_ms = user_delay_ms;\r
+\r
+rslt = bme280_init(&dev);\r
+```\r
+#### Example for I2C\r
+``` c\r
+struct bme280_dev dev;\r
+int8_t rslt = BME280_OK;\r
+\r
+dev.dev_id = BME280_I2C_ADDR_PRIM;\r
+dev.intf = BME280_I2C_INTF;\r
+dev.read = user_i2c_read;\r
+dev.write = user_i2c_write;\r
+dev.delay_ms = user_delay_ms;\r
+\r
+rslt = bme280_init(&dev);\r
+```\r
+Regarding compensation functions for temperature,pressure and humidity we have two implementations.\r
+1) Double precision floating point version\r
+2) Integer version\r
+\r
+By default, integer version is used in the API. If the user needs the floating point version, the user has to uncomment BME280_FLOAT_ENABLE macro in bme280_defs.h file or add that to the compiler flags.\r
+\r
+In integer compensation functions, we also have below two implementations for pressure.\r
+1) For 32 bit machine.\r
+2) For 64 bit machine.\r
+\r
+By default, 64 bit variant is used in the API. If the user wants 32 bit variant, the user can disable the\r
+macro BME280_64BIT_ENABLE in bme280_defs.h file.\r
+\r
+### Sensor data units\r
+> The sensor data units depends on the following macros being enabled or not, \r
+> (in bme280_defs.h file or as compiler macros)\r
+> * BME280_FLOAT_ENABLE\r
+> * BME280_64BIT_ENABLE\r
+\r
+In case of the macro "BME280_FLOAT_ENABLE" enabled,\r
+The outputs are in double and the units are\r
+\r
+ - °C for temperature\r
+ - % relative humidity\r
+ - Pascal for pressure\r
+\r
+In case if "BME280_FLOAT_ENABLE" is not enabled, then it is\r
+\r
+ - int32_t for temperature with the units 100 * °C\r
+ - uint32_t for humidity with the units 1024 * % relative humidity\r
+ - uint32_t for pressure\r
+ If macro "BME280_64BIT_ENABLE" is enabled, which it is by default, the unit is 100 * Pascal\r
+ If this macro is disabled, Then the unit is in Pascal\r
+\r
+### Stream sensor data\r
+#### Stream sensor data in forced mode\r
+\r
+``` c\r
+int8_t stream_sensor_data_forced_mode(struct bme280_dev *dev)\r
+{\r
+ int8_t rslt;\r
+ uint8_t settings_sel;\r
+ struct bme280_data comp_data;\r
+\r
+ /* Recommended mode of operation: Indoor navigation */\r
+ dev->settings.osr_h = BME280_OVERSAMPLING_1X;\r
+ dev->settings.osr_p = BME280_OVERSAMPLING_16X;\r
+ dev->settings.osr_t = BME280_OVERSAMPLING_2X;\r
+ dev->settings.filter = BME280_FILTER_COEFF_16;\r
+\r
+ settings_sel = BME280_OSR_PRESS_SEL | BME280_OSR_TEMP_SEL | BME280_OSR_HUM_SEL | BME280_FILTER_SEL;\r
+\r
+ rslt = bme280_set_sensor_settings(settings_sel, dev);\r
+\r
+ printf("Temperature, Pressure, Humidity\r\n");\r
+ /* Continuously stream sensor data */\r
+ while (1) {\r
+ rslt = bme280_set_sensor_mode(BME280_FORCED_MODE, dev);\r
+ /* Wait for the measurement to complete and print data @25Hz */\r
+ dev->delay_ms(40);\r
+ rslt = bme280_get_sensor_data(BME280_ALL, &comp_data, dev);\r
+ print_sensor_data(&comp_data);\r
+ }\r
+ return rslt;\r
+}\r
+\r
+void print_sensor_data(struct bme280_data *comp_data)\r
+{\r
+#ifdef BME280_FLOAT_ENABLE\r
+ printf("%0.2f, %0.2f, %0.2f\r\n",comp_data->temperature, comp_data->pressure, comp_data->humidity);\r
+#else\r
+ printf("%ld, %ld, %ld\r\n",comp_data->temperature, comp_data->pressure, comp_data->humidity);\r
+#endif\r
+}\r
+```\r
+##### Stream sensor data in normal mode\r
+``` c\r
+int8_t stream_sensor_data_normal_mode(struct bme280_dev *dev)\r
+{\r
+ int8_t rslt;\r
+ uint8_t settings_sel;\r
+ struct bme280_data comp_data;\r
+\r
+ /* Recommended mode of operation: Indoor navigation */\r
+ dev->settings.osr_h = BME280_OVERSAMPLING_1X;\r
+ dev->settings.osr_p = BME280_OVERSAMPLING_16X;\r
+ dev->settings.osr_t = BME280_OVERSAMPLING_2X;\r
+ dev->settings.filter = BME280_FILTER_COEFF_16;\r
+ dev->settings.standby_time = BME280_STANDBY_TIME_62_5_MS;\r
+\r
+ settings_sel = BME280_OSR_PRESS_SEL;\r
+ settings_sel |= BME280_OSR_TEMP_SEL;\r
+ settings_sel |= BME280_OSR_HUM_SEL;\r
+ settings_sel |= BME280_STANDBY_SEL;\r
+ settings_sel |= BME280_FILTER_SEL;\r
+ rslt = bme280_set_sensor_settings(settings_sel, dev);\r
+ rslt = bme280_set_sensor_mode(BME280_NORMAL_MODE, dev);\r
+\r
+ printf("Temperature, Pressure, Humidity\r\n");\r
+ while (1) {\r
+ /* Delay while the sensor completes a measurement */\r
+ dev->delay_ms(70);\r
+ rslt = bme280_get_sensor_data(BME280_ALL, &comp_data, dev);\r
+ print_sensor_data(&comp_data);\r
+ }\r
+\r
+ return rslt;\r
+}\r
+\r
+void print_sensor_data(struct bme280_data *comp_data)\r
+{\r
+#ifdef BME280_FLOAT_ENABLE\r
+ printf("%0.2f, %0.2f, %0.2f\r\n",comp_data->temperature, comp_data->pressure, comp_data->humidity);\r
+#else\r
+ printf("%ld, %ld, %ld\r\n",comp_data->temperature, comp_data->pressure, comp_data->humidity);\r
+#endif\r
+}\r
+```\r
+\r
+### Templates for function pointers\r
+``` c\r
+\r
+void user_delay_ms(uint32_t period)\r
+{\r
+ /*\r
+ * Return control or wait,\r
+ * for a period amount of milliseconds\r
+ */\r
+}\r
+\r
+int8_t user_spi_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)\r
+{\r
+ int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */\r
+\r
+ /*\r
+ * The parameter dev_id can be used as a variable to select which Chip Select pin has\r
+ * to be set low to activate the relevant device on the SPI bus\r
+ */\r
+\r
+ /*\r
+ * Data on the bus should be like\r
+ * |----------------+---------------------+-------------|\r
+ * | MOSI | MISO | Chip Select |\r
+ * |----------------+---------------------|-------------|\r
+ * | (don't care) | (don't care) | HIGH |\r
+ * | (reg_addr) | (don't care) | LOW |\r
+ * | (don't care) | (reg_data[0]) | LOW |\r
+ * | (....) | (....) | LOW |\r
+ * | (don't care) | (reg_data[len - 1]) | LOW |\r
+ * | (don't care) | (don't care) | HIGH |\r
+ * |----------------+---------------------|-------------|\r
+ */\r
+\r
+ return rslt;\r
+}\r
+\r
+int8_t user_spi_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)\r
+{\r
+ int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */\r
+\r
+ /*\r
+ * The parameter dev_id can be used as a variable to select which Chip Select pin has\r
+ * to be set low to activate the relevant device on the SPI bus\r
+ */\r
+\r
+ /*\r
+ * Data on the bus should be like\r
+ * |---------------------+--------------+-------------|\r
+ * | MOSI | MISO | Chip Select |\r
+ * |---------------------+--------------|-------------|\r
+ * | (don't care) | (don't care) | HIGH |\r
+ * | (reg_addr) | (don't care) | LOW |\r
+ * | (reg_data[0]) | (don't care) | LOW |\r
+ * | (....) | (....) | LOW |\r
+ * | (reg_data[len - 1]) | (don't care) | LOW |\r
+ * | (don't care) | (don't care) | HIGH |\r
+ * |---------------------+--------------|-------------|\r
+ */\r
+\r
+ return rslt;\r
+}\r
+\r
+int8_t user_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)\r
+{\r
+ int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */\r
+\r
+ /*\r
+ * The parameter dev_id can be used as a variable to store the I2C address of the device\r
+ */\r
+\r
+ /*\r
+ * Data on the bus should be like\r
+ * |------------+---------------------|\r
+ * | I2C action | Data |\r
+ * |------------+---------------------|\r
+ * | Start | - |\r
+ * | Write | (reg_addr) |\r
+ * | Stop | - |\r
+ * | Start | - |\r
+ * | Read | (reg_data[0]) |\r
+ * | Read | (....) |\r
+ * | Read | (reg_data[len - 1]) |\r
+ * | Stop | - |\r
+ * |------------+---------------------|\r
+ */\r
+\r
+ return rslt;\r
+}\r
+\r
+int8_t user_i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)\r
+{\r
+ int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */\r
+\r
+ /*\r
+ * The parameter dev_id can be used as a variable to store the I2C address of the device\r
+ */\r
+\r
+ /*\r
+ * Data on the bus should be like\r
+ * |------------+---------------------|\r
+ * | I2C action | Data |\r
+ * |------------+---------------------|\r
+ * | Start | - |\r
+ * | Write | (reg_addr) |\r
+ * | Write | (reg_data[0]) |\r
+ * | Write | (....) |\r
+ * | Write | (reg_data[len - 1]) |\r
+ * | Stop | - |\r
+ * |------------+---------------------|\r
+ */\r
+\r
+ return rslt;\r
+}\r
+\r
+```\r
+\r
+## Copyright (C) 2016 - 2017 Bosch Sensortec GmbH
\ No newline at end of file