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.1a4.zip (13.7 kB view details)

Uploaded Source

Built Distribution

plugandpie-0.1a4-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file plugandpie-0.1a4.zip.

File metadata

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

File hashes

Hashes for plugandpie-0.1a4.zip
Algorithm Hash digest
SHA256 b86864d46f9ce2df67214741f353f2db6623260642922b3bbf2ab5597c7bdf79
MD5 211efa183d836c50f82fdb3ef5f976d4
BLAKE2b-256 324f7d20db032a0985806306aab5cf5a4b53d671ff1d88087cb6236b5b89ffbc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plugandpie-0.1a4-py3-none-any.whl
Algorithm Hash digest
SHA256 2014218d55f17ff39f10979ab658ddd3484f362186917de81a9267095471df7a
MD5 82d11c6e6b31e8d4f8ec94df83e9baa3
BLAKE2b-256 eede0684b6abfb68443ef77b216e75b98f26d7f00a95ec0dad7064b56197d333

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