Skip to content

Portable, multi-instance driver for BME280 temperature/pressure/humidity sensors

License

Notifications You must be signed in to change notification settings

johnmgreenwell/bme280

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BME280 Driver Build StatusDocumentation

This is a driver for the BME280 Humidity, Barometric Pressure + Temp sensor

Designed originally to work with the Adafruit BME280 Breakout (but works with many other variants)

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Modified by John Greenwell to adapt driver for custom HAL support, 2025.

Usage

For this modified version, the following hardware abstraction layer (HAL) requirements must be satisfied:

  • A header file hal.h providing access to HAL classes and methods.
  • An I2C class within the HAL namespace with the following methods:
    • Write n bytes to the device: uint8_t I2C::write(uint8_t addr, uint8_t * data, uint32_t len)
    • Write n bytes to the device, execute a repeated start, then read n bytes from the device: uint8_t I2C::writeRead(uint8_t addr, uint8_t * wr_data, uint32_t wr_len, uint8_t * r_data, uint32_t r_len)
  • A function in the HAL namespace that delays execution for n milliseconds: void delay_ms(uint32_t time_ms)
  • A function in the HAL namespace that returns milliseconds elapsed during runtime (compare to well-known Arduino function of the same name): uint32_t millis()

Some further requirements may also be found. Typically, these will mirror the Arduino framework and should be added to hal.h.

Installation

To install, use the Arduino Library Manager and search for "Adafruit BME280" and install the library.

Dependencies

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Documentation and doxygen

Documentation is produced by doxygen. Contributions should include documentation for any new code added.

Some examples of how to use doxygen can be found in these guide pages:

https://learn.adafruit.com/the-well-automated-arduino-library/doxygen

https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips

Formatting and clang-format

This library uses clang-format to standardize the formatting of .cpp and .h files. Contributions should be formatted using clang-format:

The -i flag will make the changes to the file.

clang-format -i *.cpp *.h

If you prefer to make the changes yourself, running clang-format without the -i flag will print out a formatted version of the file. You can save this to a file and diff it against the original to see the changes.

Note that the formatting output by clang-format is what the automated formatting checker will expect. Any diffs from this formatting will result in a failed build until they are addressed. Using the -i flag is highly recommended.

clang-format resources

About this Driver

Written by Ladyada for Adafruit Industries.

BSD license, check license.txt for more information

All text above must be included in any redistribution

About

Portable, multi-instance driver for BME280 temperature/pressure/humidity sensors

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%