RocketLogger  2.0.1
bme280.h File Reference
#include <stdint.h>
+ Include dependency graph for bme280.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  bme280_calibration
 

Macros

#define BME280_I2C_ADDRESS_LEFT   0x76
 
#define BME280_I2C_ADDRESSES    { (BME280_I2C_ADDRESS_LEFT) }
 
#define BME280_CHANNEL_TEMPERATURE   0
 
#define BME280_CHANNEL_HUMIDITY   1
 
#define BME280_CHANNEL_PRESSURE   2
 
#define BME280_ID   0x60
 
#define BME280_REG_CALIBRATION_BLOCK1   0x88
 
#define BME280_REG_ID   0xD0
 
#define BME280_REG_RESET   0xE0
 
#define BME280_REG_CALIBRATION_BLOCK2   0xE1
 
#define BME280_REG_CONTROL_HUMIDITY   0xF2
 
#define BME280_REG_STATUS   0xF3
 
#define BME280_REG_CONTROL_MEASURE   0xF4
 
#define BME280_REG_CONFIG   0xF5
 
#define BME280_REG_PRESSURE_MSB   0xF7
 
#define BME280_REG_PRESSURE_LSB   0xF8
 
#define BME280_REG_PRESSURE_XLSB   0xF9
 
#define BME280_REG_TEMPERATURE_MSB   0xFA
 
#define BME280_REG_TEMPERATURE_LSB   0xFB
 
#define BME280_REG_TEMPERATURE_XLSB   0xFC
 
#define BME280_REG_HUMIDITY_MSB   0xFD
 
#define BME280_REG_HUMIDITY_LSB   0xFE
 
#define BME280_CALIBRATION_BLOCK1_SIZE   26
 
#define BME280_CALIBRATION_BLOCK2_SIZE   7
 
#define BME280_DATA_BLOCK_SIZE   8
 
#define BME280_RESET_VALUE   0xB6
 
#define BME280_OVERSAMPLE_HUMIDITY_OFF   0x00
 
#define BME280_OVERSAMPLE_HUMIDITY_1   0x01
 
#define BME280_OVERSAMPLE_HUMIDITY_2   0x02
 
#define BME280_OVERSAMPLE_HUMIDITY_4   0x03
 
#define BME280_OVERSAMPLE_HUMIDITY_8   0x04
 
#define BME280_OVERSAMPLE_HUMIDITY_16   0x0f
 
#define BME280_MEASURING   0x03
 
#define BME280_UPDATE   0x1
 
#define BME280_OVERSAMPLE_TEMPERATURE_OFF   0x00
 
#define BME280_OVERSAMPLE_TEMPERATURE_1   0x20
 
#define BME280_OVERSAMPLE_TEMPERATURE_2   0x40
 
#define BME280_OVERSAMPLE_TEMPERATURE_4   0x60
 
#define BME280_OVERSAMPLE_TEMPERATURE_8   0x80
 
#define BME280_OVERSAMPLE_TEMPERATURE_16   0xA0
 
#define BME280_OVERSAMPLE_PRESSURE_OFF   0x00
 
#define BME280_OVERSAMPLE_PRESSURE_1   0x04
 
#define BME280_OVERSAMPLE_PRESSURE_2   0x08
 
#define BME280_OVERSAMPLE_PRESSURE_4   0x0C
 
#define BME280_OVERSAMPLE_PRESSURE_8   0x10
 
#define BME280_OVERSAMPLE_PRESSURE_16   0x14
 
#define BME280_MODE_SLEEP   0x00
 
#define BME280_MODE_FORCE   0x01
 
#define BME280_MODE_NORMAL   0x03
 
#define BME280_STANDBY_DURATION_0_5   0x00
 
#define BME280_STANDBY_DURATION_62   0x20
 
#define BME280_STANDBY_DURATION_125   0x40
 
#define BME280_STANDBY_DURATION_250   0x60
 
#define BME280_STANDBY_DURATION_500   0x80
 
#define BME280_STANDBY_DURATION_1000   0xA0
 
#define BME280_STANDBY_DURATION_10   0xC0
 
#define BME280_STANDBY_DURATION_20   0xE0
 
#define BME280_FILTER_OFF   0x00
 
#define BME280_FILTER_2   0x04
 
#define BME280_FILTER_4   0x08
 
#define BME280_FILTER_8   0x0C
 
#define BME280_FILTER_16   0x10
 
#define BME280_SPI_EN   0x01
 

Typedefs

typedef struct bme280_calibration bme280_calibration_t
 

Functions

int bme280_init (int)
 
void bme280_deinit (int)
 
int bme280_read (int)
 
int32_t bme280_get_value (int, int)
 

Macro Definition Documentation

◆ BME280_CALIBRATION_BLOCK1_SIZE

#define BME280_CALIBRATION_BLOCK1_SIZE   26

Definition at line 66 of file bme280.h.

◆ BME280_CALIBRATION_BLOCK2_SIZE

#define BME280_CALIBRATION_BLOCK2_SIZE   7

Definition at line 67 of file bme280.h.

◆ BME280_CHANNEL_HUMIDITY

#define BME280_CHANNEL_HUMIDITY   1

Definition at line 43 of file bme280.h.

◆ BME280_CHANNEL_PRESSURE

#define BME280_CHANNEL_PRESSURE   2

Definition at line 44 of file bme280.h.

◆ BME280_CHANNEL_TEMPERATURE

#define BME280_CHANNEL_TEMPERATURE   0

Definition at line 42 of file bme280.h.

◆ BME280_DATA_BLOCK_SIZE

#define BME280_DATA_BLOCK_SIZE   8

Definition at line 69 of file bme280.h.

◆ BME280_FILTER_16

#define BME280_FILTER_16   0x10

Definition at line 111 of file bme280.h.

◆ BME280_FILTER_2

#define BME280_FILTER_2   0x04

Definition at line 108 of file bme280.h.

◆ BME280_FILTER_4

#define BME280_FILTER_4   0x08

Definition at line 109 of file bme280.h.

◆ BME280_FILTER_8

#define BME280_FILTER_8   0x0C

Definition at line 110 of file bme280.h.

◆ BME280_FILTER_OFF

#define BME280_FILTER_OFF   0x00

Definition at line 107 of file bme280.h.

◆ BME280_I2C_ADDRESS_LEFT

#define BME280_I2C_ADDRESS_LEFT   0x76

Copyright (c) 2016-2020, ETH Zurich, Computer Engineering Group All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition at line 37 of file bme280.h.

◆ BME280_I2C_ADDRESSES

#define BME280_I2C_ADDRESSES    { (BME280_I2C_ADDRESS_LEFT) }

Definition at line 39 of file bme280.h.

◆ BME280_ID

#define BME280_ID   0x60

Definition at line 47 of file bme280.h.

◆ BME280_MEASURING

#define BME280_MEASURING   0x03

Definition at line 80 of file bme280.h.

◆ BME280_MODE_FORCE

#define BME280_MODE_FORCE   0x01

Definition at line 96 of file bme280.h.

◆ BME280_MODE_NORMAL

#define BME280_MODE_NORMAL   0x03

Definition at line 97 of file bme280.h.

◆ BME280_MODE_SLEEP

#define BME280_MODE_SLEEP   0x00

Definition at line 95 of file bme280.h.

◆ BME280_OVERSAMPLE_HUMIDITY_1

#define BME280_OVERSAMPLE_HUMIDITY_1   0x01

Definition at line 74 of file bme280.h.

◆ BME280_OVERSAMPLE_HUMIDITY_16

#define BME280_OVERSAMPLE_HUMIDITY_16   0x0f

Definition at line 78 of file bme280.h.

◆ BME280_OVERSAMPLE_HUMIDITY_2

#define BME280_OVERSAMPLE_HUMIDITY_2   0x02

Definition at line 75 of file bme280.h.

◆ BME280_OVERSAMPLE_HUMIDITY_4

#define BME280_OVERSAMPLE_HUMIDITY_4   0x03

Definition at line 76 of file bme280.h.

◆ BME280_OVERSAMPLE_HUMIDITY_8

#define BME280_OVERSAMPLE_HUMIDITY_8   0x04

Definition at line 77 of file bme280.h.

◆ BME280_OVERSAMPLE_HUMIDITY_OFF

#define BME280_OVERSAMPLE_HUMIDITY_OFF   0x00

Definition at line 73 of file bme280.h.

◆ BME280_OVERSAMPLE_PRESSURE_1

#define BME280_OVERSAMPLE_PRESSURE_1   0x04

Definition at line 90 of file bme280.h.

◆ BME280_OVERSAMPLE_PRESSURE_16

#define BME280_OVERSAMPLE_PRESSURE_16   0x14

Definition at line 94 of file bme280.h.

◆ BME280_OVERSAMPLE_PRESSURE_2

#define BME280_OVERSAMPLE_PRESSURE_2   0x08

Definition at line 91 of file bme280.h.

◆ BME280_OVERSAMPLE_PRESSURE_4

#define BME280_OVERSAMPLE_PRESSURE_4   0x0C

Definition at line 92 of file bme280.h.

◆ BME280_OVERSAMPLE_PRESSURE_8

#define BME280_OVERSAMPLE_PRESSURE_8   0x10

Definition at line 93 of file bme280.h.

◆ BME280_OVERSAMPLE_PRESSURE_OFF

#define BME280_OVERSAMPLE_PRESSURE_OFF   0x00

Definition at line 89 of file bme280.h.

◆ BME280_OVERSAMPLE_TEMPERATURE_1

#define BME280_OVERSAMPLE_TEMPERATURE_1   0x20

Definition at line 84 of file bme280.h.

◆ BME280_OVERSAMPLE_TEMPERATURE_16

#define BME280_OVERSAMPLE_TEMPERATURE_16   0xA0

Definition at line 88 of file bme280.h.

◆ BME280_OVERSAMPLE_TEMPERATURE_2

#define BME280_OVERSAMPLE_TEMPERATURE_2   0x40

Definition at line 85 of file bme280.h.

◆ BME280_OVERSAMPLE_TEMPERATURE_4

#define BME280_OVERSAMPLE_TEMPERATURE_4   0x60

Definition at line 86 of file bme280.h.

◆ BME280_OVERSAMPLE_TEMPERATURE_8

#define BME280_OVERSAMPLE_TEMPERATURE_8   0x80

Definition at line 87 of file bme280.h.

◆ BME280_OVERSAMPLE_TEMPERATURE_OFF

#define BME280_OVERSAMPLE_TEMPERATURE_OFF   0x00

Definition at line 83 of file bme280.h.

◆ BME280_REG_CALIBRATION_BLOCK1

#define BME280_REG_CALIBRATION_BLOCK1   0x88

Definition at line 49 of file bme280.h.

◆ BME280_REG_CALIBRATION_BLOCK2

#define BME280_REG_CALIBRATION_BLOCK2   0xE1

Definition at line 52 of file bme280.h.

◆ BME280_REG_CONFIG

#define BME280_REG_CONFIG   0xF5

Definition at line 56 of file bme280.h.

◆ BME280_REG_CONTROL_HUMIDITY

#define BME280_REG_CONTROL_HUMIDITY   0xF2

Definition at line 53 of file bme280.h.

◆ BME280_REG_CONTROL_MEASURE

#define BME280_REG_CONTROL_MEASURE   0xF4

Definition at line 55 of file bme280.h.

◆ BME280_REG_HUMIDITY_LSB

#define BME280_REG_HUMIDITY_LSB   0xFE

Definition at line 64 of file bme280.h.

◆ BME280_REG_HUMIDITY_MSB

#define BME280_REG_HUMIDITY_MSB   0xFD

Definition at line 63 of file bme280.h.

◆ BME280_REG_ID

#define BME280_REG_ID   0xD0

Definition at line 50 of file bme280.h.

◆ BME280_REG_PRESSURE_LSB

#define BME280_REG_PRESSURE_LSB   0xF8

Definition at line 58 of file bme280.h.

◆ BME280_REG_PRESSURE_MSB

#define BME280_REG_PRESSURE_MSB   0xF7

Definition at line 57 of file bme280.h.

◆ BME280_REG_PRESSURE_XLSB

#define BME280_REG_PRESSURE_XLSB   0xF9

Definition at line 59 of file bme280.h.

◆ BME280_REG_RESET

#define BME280_REG_RESET   0xE0

Definition at line 51 of file bme280.h.

◆ BME280_REG_STATUS

#define BME280_REG_STATUS   0xF3

Definition at line 54 of file bme280.h.

◆ BME280_REG_TEMPERATURE_LSB

#define BME280_REG_TEMPERATURE_LSB   0xFB

Definition at line 61 of file bme280.h.

◆ BME280_REG_TEMPERATURE_MSB

#define BME280_REG_TEMPERATURE_MSB   0xFA

Definition at line 60 of file bme280.h.

◆ BME280_REG_TEMPERATURE_XLSB

#define BME280_REG_TEMPERATURE_XLSB   0xFC

Definition at line 62 of file bme280.h.

◆ BME280_RESET_VALUE

#define BME280_RESET_VALUE   0xB6

Definition at line 71 of file bme280.h.

◆ BME280_SPI_EN

#define BME280_SPI_EN   0x01

Definition at line 112 of file bme280.h.

◆ BME280_STANDBY_DURATION_0_5

#define BME280_STANDBY_DURATION_0_5   0x00

Definition at line 99 of file bme280.h.

◆ BME280_STANDBY_DURATION_10

#define BME280_STANDBY_DURATION_10   0xC0

Definition at line 105 of file bme280.h.

◆ BME280_STANDBY_DURATION_1000

#define BME280_STANDBY_DURATION_1000   0xA0

Definition at line 104 of file bme280.h.

◆ BME280_STANDBY_DURATION_125

#define BME280_STANDBY_DURATION_125   0x40

Definition at line 101 of file bme280.h.

◆ BME280_STANDBY_DURATION_20

#define BME280_STANDBY_DURATION_20   0xE0

Definition at line 106 of file bme280.h.

◆ BME280_STANDBY_DURATION_250

#define BME280_STANDBY_DURATION_250   0x60

Definition at line 102 of file bme280.h.

◆ BME280_STANDBY_DURATION_500

#define BME280_STANDBY_DURATION_500   0x80

Definition at line 103 of file bme280.h.

◆ BME280_STANDBY_DURATION_62

#define BME280_STANDBY_DURATION_62   0x20

Definition at line 100 of file bme280.h.

◆ BME280_UPDATE

#define BME280_UPDATE   0x1

Definition at line 81 of file bme280.h.

Typedef Documentation

◆ bme280_calibration_t

Definition at line 1 of file bme280.h.

Function Documentation

◆ bme280_deinit()

void bme280_deinit ( int  sensor_identifier)

Deinitialize BME280 ambient sensor.

Parameters
sensor_identifierThe I2C address of the sensor

Definition at line 190 of file bme280.c.

◆ bme280_get_value()

int32_t bme280_get_value ( int  sensor_identifier,
int  channel 
)

Get the values read from the sensor.

Parameters
sensor_identifierThe I2C address of the sensor
channelThe channel of the sensor to get
Returns
Sensor value in lux

Definition at line 238 of file bme280.c.

References BME280_CHANNEL_HUMIDITY, BME280_CHANNEL_PRESSURE, BME280_CHANNEL_TEMPERATURE, bme280_get_index(), bme280_humidity, bme280_pressure, and bme280_temperature.

+ Here is the call graph for this function:

◆ bme280_init()

int bme280_init ( int  sensor_identifier)

Initialize the BME280 ambient sensor.

Parameters
sensor_identifierThe I2C address of the sensor
Returns
Returns 0 on success, negative on failure with errno set accordingly

Definition at line 145 of file bme280.c.

References bme280_get_id(), BME280_ID, bme280_read_calibration(), bme280_set_parameters(), rl_log(), RL_LOG_ERROR, sensor_bus, sensors_get_bus(), and sensors_init_comm().

+ Here is the call graph for this function:

◆ bme280_read()

int bme280_read ( int  sensor_identifier)

Read the sensor values.

Parameters
sensor_identifierThe I2C address of the sensor
Returns
Returns 0 on success, negative on failure with errno set accordingly

Definition at line 194 of file bme280.c.

References BME280_DATA_BLOCK_SIZE, bme280_get_index(), BME280_REG_PRESSURE_MSB, bme280_temperature, data, rl_log(), RL_LOG_ERROR, sensor_bus, sensors_get_bus(), and sensors_init_comm().

+ Here is the call graph for this function: