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.
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 theHAL
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)
- Write n bytes to the device:
- 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
.
To install, use the Arduino Library Manager and search for "Adafruit BME280" and install the library.
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
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
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.
Written by Ladyada for Adafruit Industries.
BSD license, check license.txt for more information
All text above must be included in any redistribution