RPJ's RPi OS: a sensor data platform for the Raspberry Pi built with python2.7 and redis. https://rpjios.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
dependabot[bot] bab2f90731
Bump psutil from 5.4.7 to 5.6.6 (#22)
2 个月前
bin Minor change: make sensors-src quit immediately if no sensors are enabled 1年前
embedded-sps @ 836d5fc10a Update embedded-sps pointer 1年前
git-hooks Remove gh-pages cruft; switch versioning a bit 1年前
lib/rpjios Fix Discovery bug when frequency can't be convert to a float 9 个月前
.gitignore Add SPS30 support (#1) 1年前
.gitmodules Potential fix (#19) 1年前
LICENSE Create LICENSE 1年前
README.md Update README.md 1年前
config.json Add SPS30 support (#1) 1年前
mapping.json D'oh 1年前
requirements-nonRPi.txt Bump psutil from 5.4.7 to 5.6.6 (#22) 2 个月前
requirements.txt Bump psutil from 5.4.7 to 5.6.6 (#22) 2 个月前
setup.sh Fix libjpeg install bug 1年前
version.txt 0.0.5 9 个月前

README.md

RPJiOS

Raspberry Pi Zero W Python Redis Debian

A pub/sub-based implementation of a Raspberry Pi data pipeline built on redis and centered around sensors.

The general philosophy is that a “sensor” is any entity (physical or not) that operates primarily in an output-only mode (configuration doesn’t necessarily count as an “input” so is allowable).

These outputs are treated ephemerally, in a “fire and forget” manner, creating a data stream. The intent is for interested entities to subscribe to the data stream and transform, interpret and/or persist it according to their requirements.

Caveat emptor

This is still very much an active work-in-progress! However, as it is functional and actively deployed I figured it was worth making public in the event it might help others in their projects.

Those current deployments consist of my atmospheric particulate matter sensor and my garden monitoring bots, with the entire system handling (on average) about a half-million units of sensor data per day.

Requirements

  • Hardware:
    • a Raspberry Pi running a recent Raspbian build (for sensor nodes)
    • any Debian-like system running apt (for managment/non-sensor nodes)
  • some sensors, configured appropriately (most easily done with raspi-config):
    • depending on your chosen sensors: I2C enabled, SPI enabled, 1-wire enabled
    • other sensors (LM335, Soil, TEPT5700) require an external ADC which itself will require SPI

Setup

  • Clone the repo
  • cd into repo dir
  • ./setup.sh (you might need to enter your sudo password to install requirements)
  • source env/bin/activate and go!

Tools

  • sensors-src: source daemon that manages all specified sensors and publishes their data as configured
  • downsample: a very flexible data stream downsampler/forwarder/transformer. example uses:
    • an at-frequency forwarder (set -r 1)
    • a loopback downsampler (set -o to the same as -i)
    • a many-to-one reducer (set -t to key)
    • a one-to-many exploder (set -m to flatten:[options])
    • a bounded ephemeral cache (set -t to list:[options], where the limit=X option sets the bound)
    • ...
    • profit!
  • sqlite-sink: an SQLite sink for data streams. examples:
    • sink to an SQLite database on a different host a downsampled data stream:
      1. on the source device:
        • downsample -i redis://localhost -o redis://sql-db-host -r ... -p ...
      2. on the sink host “sql-db-host”:
        • sqlite-sink path-to-db.sqlite3
          • (lots of “TODOs” here, obviously)
  • oled-display: an OLED display driver for consuming & display some sensor data, among other things
  • thingspeak: a simple example of a ThingSpeak data forwarder for the SPS30 particulate matter sensor data. Example resulting data set.

Library

Sensors

The following are currently supported (with the required drivers / interfaces setup of course):

Variants of these sensors could likely be made to work with this system via simple modifications if any are required at all.

Devices

  • A simple Python wrapper driver for the SPS30 sensor is included here, wrapping the included embedded-sps I2C driver from Sensiron implemented in C (forked to include a shared object build step for Python consumption).
  • A simple Python driver for the 74HC595 8-bit shift register is included here.
  • The venerable MCP3008 10-bit 8-channel analog-to-digital converter is directly supported by the base analog sensor implementation. Other ADCs would be quite simple to adapt (even more so if I implemented a HAL... #TODO).
  • The old now-archived repository from whence this all came
    • might still contain some useful stuff: D3-based “live” analog data plotting code in rpjctrl, and I’m still using ledCount.py on some of my units because I’m too lazy to re-write it properly