sensor.mcp3008
Platypush documentation
sensor.mcp3008
- class platypush.backend.sensor.mcp3008.SensorMcp3008Backend(**kwargs)[source]
Bases:
SensorBackend
Backend to poll analog sensor values from an MCP3008 chipset (https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/mcp3008)
Requires:
adafruit-mcp3008
(pip install adafruit-mcp3008
)The
platypush.plugins.gpio.sensor.mcp3008
plugin configured
Triggers:
platypush.message.event.sensor.SensorDataChangeEvent
if the measurements of a sensor have changedplatypush.message.event.sensor.SensorDataAboveThresholdEvent
if the measurements of a sensor havegone above a configured threshold
platypush.message.event.sensor.SensorDataBelowThresholdEvent
if the measurements of a sensor havegone below a configured threshold
- __init__(**kwargs)[source]
- Parameters:
plugin (str) – If set, then this plugin instance, referenced by plugin id, will be polled through
get_plugin()
. Example:'gpio.sensor.bme280'
or'gpio.sensor.envirophat'
.plugin_args (dict) – If plugin is set and its
get_measurement()
method accepts optional arguments, then you can pass those arguments throughplugin_args
.thresholds – Thresholds can be either a scalar value or a dictionary (e.g.
{"temperature": 20.0}
). Sensor threshold events will be fired when measurements get above or below these values. Set it as a scalar if your get_measurement() code returns a scalar, as a dictionary if it returns a dictionary of values. For instance, if your sensor code returns both humidity and temperature in a format like{'humidity':60.0, 'temperature': 25.0}
, you’ll want to set up a threshold on temperature with a syntax like{'temperature':20.0}
to trigger events when the temperature goes above/below 20 degrees.If set, then the sensor change events will be triggered only if the difference between the new value and the previous value is higher than the specified tolerance. Example:
{ "temperature": 0.01, # Tolerance on the 2nd decimal digit "humidity": 0.1 # Tolerance on the 1st decimal digit }
poll_seconds (float) – If set, the thread will wait for the specified number of seconds between a read and the next one.
enabled_sensors (dict (in the form
name -> [True/False]
), set or list) – Ifget_measurement()
returns data in dict form, thenenabled_sensors
selects which keys should be taken into account when monitoring for new events (e.g. “temperature” or “humidity”).