Skip to content

Commit

Permalink
Updated to v3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BST-Github-Admin committed Jun 23, 2017
1 parent cf40d00 commit 4dbd10a
Show file tree
Hide file tree
Showing 6 changed files with 1,849 additions and 4,267 deletions.
204 changes: 146 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,152 @@
# BME280 sensor API
## Introduction
This package contains the Bosch Sensortec's BME280 pressure sensor driver (sensor API)

CONTENTS OF THIS FILE
=======================
* Introduction
* Version
* Integration details
* Driver files information
* Supported sensor interface
* Copyright

INTRODUCTION
===============
- This package contains the Bosch Sensortec MEMS humidity sensor driver(sensor API)
- The sensor driver package includes bme280.h, bme280.c and bme280_support.c files

VERSION
=========
- Version of bme280 sensor driver is:
* bme280.c - V2.0.5
* bme280.h - V2.0.5
* bme280_support.c - V1.0.6

INTEGRATION DETAILS
=====================
- Integrate bme280.h and bme280.c file in to your project.
- The bme280_support.c file contains only examples for API use cases, so it is not required to integrate into project.

DRIVER FILES INFORMATION
===========================
bme280.h
-----------
* This header file has the register address definition, constant definitions, data type definition and supported sensor driver calls declarations.

bme280.c
------------
* This file contains the implementation for the sensor driver APIs.

bme280_support.c
----------------------
* This file shall be used as an user guidance, here you can find samples of
* Initialize the sensor with I2C/SPI communication
- Add your code to the SPI and/or I2C bus read and bus write functions.
- Return value can be chosen by yourself
- API just passes that value to your application code
- Add your code to the delay function
- Change I2C address accordingly in bme280.h
* Power mode configuration of the sensor
* Get and set functions usage
* Reading the sensor read out data

SUPPORTED SENSOR INTERFACE
====================================
- This humidity sensor driver supports SPI and I2C interfaces


COPYRIGHT
===========
- Copyright (C) 2013 - 2016 Bosch Sensortec GmbH
The sensor driver package includes bme280.c, bme280.h and bme280_defs.h files.

## Version
File | Version | Date
-----|---------|-----
bme280.c | 3.2.0 | 21 Mar 2017
bme280.h | 3.2.0 | 21 Mar 2017
bme280_defs.h | 3.2.0 | 21 Mar 2017


## 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.id = 0;
dev.interface = 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.id = BME280_I2C_ADDR_PRIM;
dev.interface = 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 user needs double version, user has to
enable FLOATING_POINT_REPRESENTATION macro in bme280_defs.h file.

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 user wants 32 bit variant, user can disable the
macro MACHINE_64_BIT in bme280_defs.h file.

### Get sensor data
#### Get sensor data in forced mode

``` c
int8_t get_sensor_data_forced_mode(struct bme280_dev *dev)
{
int8_t rslt;
uint8_t settings_sel;
struct bme280_data comp_data;

/* Continuously get the sensor data */
while (1) {
dev->settings.osr_h = BME280_OVERSAMPLING_4X;
dev->settings.osr_p = BME280_OVERSAMPLING_4X;
dev->settings.osr_t = BME280_OVERSAMPLING_4X;

settings_sel = BME280_OSR_PRESS_SEL|BME280_OSR_TEMP_SEL|BME280_OSR_HUM_SEL;

rslt = bme280_set_sensor_settings(settings_sel, dev);
rslt = bme280_set_sensor_mode(BME280_FORCED_MODE, dev);
/* Give some delay for the sensor to go into force mode */
dev->delay_ms(5);
rslt = bme280_get_sensor_data(BME280_PRESS | BME280_HUM | BME280_TEMP, &comp_data, dev);
print_sensor_data(&comp_data);
}
return rslt;
}

void print_sensor_data(struct bme280_data *comp_data)
{
#ifdef FLOATING_POINT_REPRESENTATION
printf("%0.2f\t\t%0.2f\t\t%0.2f\t\n",comp_data->temperature, comp_data->pressure, comp_data->humidity);
#else
printf("%ld\t\t%ld\t\t%ld\t\n",comp_data->temperature, comp_data->pressure, comp_data->humidity);
#endif
}

```
##### Get sensor data in normal mode
``` c
int8_t get_sensor_data_normal_mode(struct bme280_dev *dev)
{
int8_t rslt;
uint8_t settings_sel;
struct bme280_data comp_data;
dev->settings.osr_h = BME280_OVERSAMPLING_4X;
dev->settings.osr_p = BME280_OVERSAMPLING_4X;
dev->settings.osr_t = BME280_OVERSAMPLING_4X;
settings_sel = BME280_OSR_PRESS_SEL|BME280_OSR_TEMP_SEL|BME280_OSR_HUM_SEL;
rslt = bme280_set_sensor_settings(settings_sel, dev);
rslt = bme280_set_sensor_mode(BME280_NORMAL_MODE, dev);
/* Give some delay for the sensor to go into normal mode */
dev->delay_ms(5);
while (1) {
rslt = bme280_get_sensor_data(BME280_PRESS | BME280_HUM | BME280_TEMP, &comp_data, dev);
print_sensor_data(&comp_data);
}
return rslt;
}
void print_sensor_data(struct bme280_data *comp_data)
{
#ifdef FLOATING_POINT_REPRESENTATION
printf("%0.2f\t\t%0.2f\t\t%0.2f\t\n",comp_data->temperature, comp_data->pressure, comp_data->humidity);
#else
printf("%ld\t\t%ld\t\t%ld\t\n",comp_data->temperature, comp_data->pressure, comp_data->humidity);
#endif
}
```

## Copyright (C) 2016 - 2017 Bosch Sensortec GmbH
Loading

0 comments on commit 4dbd10a

Please sign in to comment.