malokhvii-eduard / lkmod-bme280

💧 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.
MIT License
4 stars 0 forks source link
bme280 bosch humidity i2c kernel kernel-module linux pressure temperature

💧 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](https://img.shields.io/badge/license-MIT-3178C6?style=flat)](LICENSE) [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)][github-pre-commit] [![pre-commit.ci](https://results.pre-commit.ci/badge/github/malokhvii-eduard/lkmod-bme280/master.svg)][pre-commit.ci] ![Style Guide](https://img.shields.io/badge/code%20style-linux-FFC557?style=flat) ![clang-format](https://img.shields.io/badge/formatter-clang--format-262D3A?style=flat) [![markdownlint](https://img.shields.io/badge/linter-markdownlint-000?style=flat)][github-markdownlint] [![commitlint](https://img.shields.io/badge/linter-commitlint-F7B93E?style=flat)][github-commitlint] ![platform](https://img.shields.io/badge/platform-linux-FFC557?style=flat) [![Tested on Raspberry Pi](https://img.shields.io/badge/tested%20on-raspberry%20pi-A22846)][raspberrypi] [![Tested on Tinker Board](https://img.shields.io/badge/tested%20on-tinker%20board-005571)][tinker-board]

🎉 Features

🌻 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.