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

Uploaded Source

Built Distribution

plugandpie-0.1a5-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file plugandpie-0.1a5.zip.

File metadata

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

File hashes

Hashes for plugandpie-0.1a5.zip
Algorithm Hash digest
SHA256 e699d6766b57e0c55816b4993ef4d45a6ae2acf06f25d80bd251dcc17d1a0f5a
MD5 5619db91e38fe635183b10ea75f6721b
BLAKE2b-256 539978dc9c9d6a9d0ec3edbc1bc168b433f7307d5d08fa45d4f7524d1ae949b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plugandpie-0.1a5-py3-none-any.whl
Algorithm Hash digest
SHA256 3727ad8044c2f4ccc294f78db38917ce60060c1e7abcfa3bea3aa2e9eb4baa4e
MD5 31fb1dfad304f8c0cef259ff62555598
BLAKE2b-256 2afdf116abd749fc61ef04ed6acbff4511df95daf0b248a0e6125f7219227656

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