SensorLib
Commonly used I2C , SPI device multi-platform libraries
Install / Use
/learn @lewisxhe/SensorLibREADME
Highlights
- One library for Arduino / PlatformIO / ESP-IDF
- Supports I2C and SPI devices
- A collection of ready-to-run examples under
examples/
Contents
Installation
Arduino IDE
Option A: Install from Library Manager (recommended)
- Open Arduino IDE
- Go to
Tools→Manage Libraries... - Search for SensorLib
- Click Install
- Restart Arduino IDE if needed
Option B: Install from ZIP
- GitHub page →
Code→Download ZIP - Arduino IDE →
Sketch→Include Library→Add .ZIP Library... - Select the downloaded ZIP file
- Restart Arduino IDE if the library does not appear immediately
Option C: Install with Git (manual)
- Clone this repository into your Arduino libraries folder:
- Windows:
Documents/Arduino/libraries/ - macOS:
~/Documents/Arduino/libraries/ - Linux:
~/Arduino/libraries/
- Windows:
- Folder name should be
SensorLib - Restart Arduino IDE
PlatformIO
Option A: Install from PlatformIO Registry (recommended)
Add to your platformio.ini:
[env:your_env]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
lewisxhe/SensorLib@^0.4.0
Option B: Install from GitHub (latest)
[env:your_env]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
https://github.com/lewisxhe/SensorLib.git
Option C: Put it into lib/ (local library)
- Copy/clone this repository into your PlatformIO project folder:
<your_project>/lib/SensorLib/
- PlatformIO will auto-detect it as a local library
ESP-IDF
SensorLib is now published in the official ESP-IDF Component Registry, and supports ESP-IDF v4.4+ (recommended v5.1+).
1. Add Dependency (in project root idf_component.yml)
Create or edit idf_component.yml in your ESP-IDF project root:
dependencies:
lewisxhe/sensorlib:
version: "^0.4.0" # or use "*" to get the latest version
Examples
- PlatformIO examples: see
platformio.iniand uncomment the examplesrc_diryou want to build. - More examples are located in the
examples/folder.
Support list
| Sensor | Description | I2C | SPI | | --------------- | ------------------------ | --- | --- | | PCF8563/HYM8563 | Real-time clock | ✔️ | ❌ | | PCF85063 | Real-time clock | ✔️ | ❌ | | QMI8658 | IMU | ✔️ | ✔️ | | BHI260AP | IMU | ✔️ | ✔️ | | BHI360 | IMU | ✔️ | ✔️ | | QMC6310U/N | Magnetic Sensor | ✔️ | ❌ | | QMC5883P | Magnetic Sensor | ✔️ | ❌ | | QMC5883L | Magnetic Sensor | ✔️ | ❌ | | BMM150 | Magnetic Sensor | ✔️ | ❌ | | XL9555 | I/O expander | ✔️ | ❌ | | PCA9570 | I/O expander | ✔️ | ❌ | | BMA422 | Accelerometer | ✔️ | ❌ | | BMA423 | Accelerometer | ✔️ | ❌ | | BMA456 | Accelerometer | ✔️ | ❌ | | DRV2605 | Haptic Driver | ✔️ | ❌ | | CM32181 | Ambient Light Sensor | ✔️ | ❌ | | LTR553 | Light & Proximity Sensor | ✔️ | ❌ | | FT3267 | Capacitive touch | ✔️ | ❌ | | FT5206 | Capacitive touch | ✔️ | ❌ | | FT6206 | Capacitive touch | ✔️ | ❌ | | FT6236 | Capacitive touch | ✔️ | ❌ | | CST820 | Capacitive touch | ✔️ | ❌ | | CST816S/T/D | Capacitive touch | ✔️ | ❌ | | CST226SE | Capacitive touch | ✔️ | ❌ | | CHSC5816 | Capacitive touch | ✔️ | ❌ | | GT911 | Capacitive touch | ✔️ | ❌ | | CST9217 | Capacitive touch | ✔️ | ❌ | | CST9220 | Capacitive touch | ✔️ | ❌ | | GT9895 | Capacitive touch | ✔️ | ❌ | | HI8561 | Capacitive touch | ✔️ | ❌ | | AW9364 | Led Driver (GPIO) | ❌ | ❌ | | BQ27220 | Gauge Meter | ✔️ | ❌ | | AXP2602 | Gauge Meter | ✔️ | ❌ |
Notes
- I2C devices typically require proper pull-up resistors on SDA/SCL.
- If you cannot detect devices, check wiring, address selection, and I2C speed (100kHz / 400kHz).
License
SensorLib is licensed under the MIT License. See LICENSE.
Third-party licenses
This repository includes third-party code under src/bosch/ from Bosch Sensortec, licensed under the BSD 3-Clause License (BSD-3-Clause).
See THIRD_PARTY_NOTICES.md for details.
