GithubHelp home page GithubHelp logo

sensirion / linux-sps30 Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 19 KB

Linux Kernel Driver for Sensirion SPS30. External module based on the upstream sps30 driver that is backported to older kernels

License: Other

Makefile 7.13% C 92.87%
sensor i2c raspberry-pi sensirion sps30 kernel-driver iio particulate-matter

linux-sps30's Introduction

Sensirion SPS30 Linux Kernel Driver

The sps30 driver for the Sensirion SPS30 is based on the IIO subsystem.

The driver contained here was originally submitted to the Linux kernel mailing list: https://lkml.org/lkml/2018/12/14/1066

Sensirion then backported it to older kernel versions.

Requirements

Kernel with the following config options set, either as module or compiled in. The config options must be listed in .config (e.g. selected with make menuconfig)

Minimal driver requirements:

  • CONFIG_CRC8
  • CONFIG_IIO

Directory Structure

/: The root directory contains the Makefile needed for out-of-tree module builds.

/sps30: The sps30 directory contains the driver source and Kconfig as needed for upstream merging with the Linux sources.

Building

Local Machine

Compiling for your local machine is useful to test if the driver compiles correctly. Prerequisites are the kernel headers and build tools.

# Install dependencies
sudo apt install build-essential linux-headers-$(uname -r)
# configure
export KERNELDIR=/lib/modules/$(uname -r)/build
# build
make -j

To check for style issues we can use the check target

make check

Cross Compiling

To cross compile, one needs to install a cross compilation tool chain and set the ARCH and CROSS_COMPILE environment variables accordingly:

# Example to cross compile for raspbian
export ARCH=arm
export CROSS_COMPILE=~/opt/toolchain/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-

Usage

The driver is meant for direct use with sysfs or libiio. Errors are printed to the kernel log (dmesg)

Loading the Kernel Module

Load the dependencies of the sps30.ko kernel module:

sudo modprobe industrialio
sudo modprobe crc8

Load the kernel module with the appropriate command:

  • Out-of-tree build

    sudo insmod sps30.ko
  • In-kernel build

    sudo modprobe sps30

Instantiation

Instantiate the driver on the correct i2c bus with

echo sps30 0x69 | sudo tee /sys/class/i2c-adapter/i2c-1/new_device

Only sps30 is a permissible name.

Operation

Query device files by reading from the iio subsytem's device:

cat /sys/bus/iio/devices/iio\:device0/in_concentration_pm2p5_input

or alternatively on the i2c bus: /sys/bus/i2c/devices/1-0069/iio:device0/

Unloading

Unload the driver by removing the device instance and then unloading the module.

echo 0x69 | sudo tee /sys/class/i2c-adapter/i2c-1/delete_device
sudo rmmod sps30

linux-sps30's People

Contributors

abrauchli avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

linux-sps30's Issues

Q's related to linux drivers

  • Does the sensor still auto-clean according to the pre-set duration? Should I write to start_cleaning periodically? What should I write?
  • Can the sensor sleep between reads? or can sleep be commanded?
  • If I read from the massconcentration files, does that interrupt cleaning? If so, how can I synchronize my monitoring to allow cleaning?
    • Perhaps space the reads long enough to allow cleaning? How long does it clean then?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.