Skip to main content

Device driver and automation for common sensors

Project description

The plugandpie package goal is to simplify the process of setting up and using sensors with Raspberry Pi. Just by importing the package, if your sensor interface has a “device driver” available (community contribution) and it gives no ambiguity, you are ready to go.

For example, for a MMA8452Q accelerometer board by Microstack:

>>> import plugandpie as pnp
>>> pnp.accelerometer.get_ms2()
{'x': 4.50109912109375, 'y': -6.4739212890625, 'z': 5.42047255859375}

plugandpie is specially better for I2C addresses because we can make good guesses about the device given it’s address.

There are some cases where things are not going to be so trivial:

  • Device could not be automatically identified, but there is a driver for it

  • The driver does not give access to all desired registers (or it’s buggy)

  • No driver has been made for this sensor yet

The first case should be as simple as manually plugging the sensor proxy object (e.g. pnp.accelerometer) to the device. The second and third cases have different ways to work around:

  • Create/Modify the driver for this device (and give it back to the community!)

  • Translate the device datasheet into a configuration importable by plugandpie

  • Instantiate a generic device reader for the given interface that simply pulls all raw data

Examples of each scenario are present in the documentation.

After plugging your sensors and verifying that its data is accessible, life is all fresh juicy raspberry pie. plugandpie also aims to provide utilities for monitoring and analyzing sensors, so you can make software-level polling and set up complex observation models. For example, calling some function if the acceleration gets too high or automatically dump sensor data fine-grained to milliseconds.

Installation: pipv pipstatus pipl pippyversions pipdm

plugandpie requires SMBus, which at this time has no good Python 3 implementation or bindings. A workaround can be found at https://procrastinative.ninja/2014/07/21/smbus-for-python34-on-raspberry/

Also, SMBus requires repeated starts in the i2c driver. This is not enabled by default on Raspberry Pi and can be fixed with:

echo -n 1 > /sys/module/i2c_bcm2708/parameters/combined

This configuration resets on boot, so make sure to put this in a startup script.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plugandpie-0.1a6.zip (21.5 kB view details)

Uploaded Source

Built Distribution

plugandpie-0.1a6-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file plugandpie-0.1a6.zip.

File metadata

  • Download URL: plugandpie-0.1a6.zip
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for plugandpie-0.1a6.zip
Algorithm Hash digest
SHA256 97b8a87d71bba8cc171272c4bf7c93f7e2e058e803781135d07e8ccfd28e49da
MD5 24dba685d50c2b7ad3a19d71aff49296
BLAKE2b-256 e03ca0780851984dea835bac7e0267d0c61a73069603408b7a7965e26bcf7286

See more details on using hashes here.

File details

Details for the file plugandpie-0.1a6-py3-none-any.whl.

File metadata

File hashes

Hashes for plugandpie-0.1a6-py3-none-any.whl
Algorithm Hash digest
SHA256 2a91bf17d2b566a86dd5aa29efb6644fe5c39006f358acb9747d02b5384a10e1
MD5 19edb92c2440b682296ec0da18c9fd31
BLAKE2b-256 ed4dbddc4c9f9dfc7e03fd4db0c49fb270eab52e3b9d08d36cdf3c9258bd3722

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page