The driver allows using the sensor via I2C bus on a single-board computer like Raspberry Pi, Orange Pi, Asus Tinker Board, etc.
- ποΈ Provides an interface in sysfs and procfs for sensor settings, calibration data, measurements
- βοΈ Supports multiple sensors on the same I2C adapter
- π Supports multiple I2C adapters
- βοΈ Tested on: Rasbperry Pi 3B+, Asus Tinker Board
Final project for my education in Linux Kernel GL BaseCamp. I participated in the course from November 2019 until March 2020.
Firstly you will need to install build dependencies such as compiler
(build-essential
, g++-arm-linux-gnueabihf
, gdb-multiarch
) and
linux-headers. Next, you will need to get source code for exact kernel version
you are running. You can find the kernel version via uname -r
.
- Clone the Repository
- Build this Kernel Module (
make clean modules_release
) - Install this Kernel Module (
make modules_install
)
- Connect the sensor to your host
- Scan I2C bus to find the sensor address (
i2cdetect
) - Initialize the sensor from user space (
echo "bme280 'your address, usually 0x76 or 0x77'" > /sys/bus/i2c/devices/i2c-'your adapter number'/new_device
)
π sysfs β filesystem for exporting kernel objects
Mapping | Operations | Description |
---|---|---|
/sys/class/bme280/i2c | read/write | I2C adapter and device address |
/sys/class/bme280/chip_id | read | Chip identifier |
/sys/class/bme280/reset | write | Reset |
/sys/class/bme280/mode | read/write | Power mode |
/sys/class/bme280/osrs_p | read/write | Pressure oversampling |
/sys/class/bme280/osrs_t | read/write | Temperature oversampling |
/sys/class/bme280/osrs_h | read/write | Humidity oversampling |
/sys/class/bme280/filter | read/write | Filter coefficient |
/sys/class/bme280/standby_time | read/write | Standby time |
/sys/class/bme280/pressure | read | Pressure (Pa) |
/sys/class/bme280/temperature | read | Temperature (Β°C * 100) |
/sys/class/bme280/humidity | read | Humidity (% * 1024) |
π procfs β process information pseudo-filesystem
Mapping | Operations | Description |
---|---|---|
/proc/bme280info | read | Device information as a table |
/proc/bme280calib | read | Calibration data as a table |
π If you want to switch to another sensor, use /sys/bme280/i2c
mapping, write to it a number of I2C adapter in decimal and device address in
hex (echo "0 0x77" > /sys/bme280/i2c
).
ππ First off, thanks for taking the time to contribute! ππ
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/awesome-feature
) - Commit your Changes (
git commit -m 'Add awesome feature'
) - Push to the Branch (
git push origin feature/awesome-feature
) - Open a Pull Request
lkmod-bme280
is licenced under the MIT License. See the LICENSE for
more information.