Skip to content

πŸ’§ Kernel space driver for Bosch Sensortec BME280 – combined temperature, pressure, humidity sensor. The driver allows using the sensor over I2C bus on a single-board computer like Raspberry Pi, Orange Pi, Asus Tinker Board, etc.

License

Notifications You must be signed in to change notification settings

malokhvii-eduard/lkmod-bme280

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

74 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’§ Kernel space driver for Bosch Sensortec BME280

The driver allows using the sensor via I2C bus on a single-board computer like Raspberry Pi, Orange Pi, Asus Tinker Board, etc.

License pre-commit pre-commit.ci Style Guide clang-format markdownlint commitlint platform Tested on Raspberry Pi Tested on Tinker Board

πŸŽ‰ Features

  • πŸ—ƒοΈ 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

🌻 Motivation

Final project for my education in Linux Kernel GL BaseCamp. I participated in the course from November 2019 until March 2020.

✨ Getting Started

πŸ“š Prerequisites

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.

πŸ“¦ Installation

  1. Clone the Repository
  2. Build this Kernel Module (make clean modules_release)
  3. Install this Kernel Module (make modules_install)

πŸ‘€ Usage

  1. Connect the sensor to your host
  2. Scan I2C bus to find the sensor address (i2cdetect)
  3. Initialize the sensor from user space (echo "bme280 'your address, usually 0x76 or 0x77'" > /sys/bus/i2c/devices/i2c-'your adapter number'/new_device)

❓ FAQs

πŸ™‹β€β™‚οΈ How to access sensor settings, calibration data, measurements?

πŸ‘‰ 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

πŸ™‹β€β™‚οΈ How to switch to another sensor?

πŸ‘‰ 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).

πŸ› οΈ Tech Stack

EditorConfig Markdown C Makefile pre-commit clang-format commitlint markdownlint Linux Linux Kernel BME280 Raspberry Pi Tinker Board Shields.io Git GitHub

✍️ Contributing

πŸ‘πŸŽ‰ 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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/awesome-feature)
  3. Commit your Changes (git commit -m 'Add awesome feature')
  4. Push to the Branch (git push origin feature/awesome-feature)
  5. Open a Pull Request

⚠️ License

lkmod-bme280 is licenced under the MIT License. See the LICENSE for more information.

About

πŸ’§ Kernel space driver for Bosch Sensortec BME280 – combined temperature, pressure, humidity sensor. The driver allows using the sensor over I2C bus on a single-board computer like Raspberry Pi, Orange Pi, Asus Tinker Board, etc.

Topics

Resources

License

Stars

Watchers

Forks