The gpio
extension controls and monitors GPIO pins connected to a linux sbc board such as a Raspberry Pi. Provided are a set of interfaces through the support of adafruit-blinka
. There are a large variety of supported linux boards that you can use.
This extension does not take an extension level config and is focused on interfaces.
Provides a sensor that returns a GPIO pin reading.
Option | Type | Required | Description |
key | [String] | Yes | Unique slug id for the component |
pin | [String] | Yes | GPIO pin to use on board i.e. D12 or A1 . |
name | [String] | No | Friendly display name of component. Useful for UI. |
classifier | [String] | No | Choose a specific sensor classifier to change formatting on frontend. Default: general |
Here is a config of a complete gpio sensor.
"sensor": [{
"key": "gpio_sensor_D12",
"interface": "gpio",
"pin": "D12",
"classifier": "general"
}]
Attach a control to a linux board GPIO such as a button
, switch
or potentiometer
.
Option | Type | Required | Description |
key | [String] | Yes | Unique slug id for the component |
pin | [String] | Yes | GPIO pin to use on board i.e. D12 or A1 . |
name | [String] | No | Friendly display name of component. Useful for UI. |
type | [String] | No | Type of control behavior. Options: button control or potentiometer . Default: button |
resistor | [String] | No | Set internal resistor to pull up or pull down . Default None |
edge_detection | [String] | No | Set edge detection on gpio for more responsive feedback. Options rose , fell or both . |
debounce | [Float] | No | Time in seconds to wait for gpio to settle before firing. Prevents multiple fires from one press. Default 0 . A good starting value is 0.05 . |
Here is a config of a complete gpio control.
"control": [{
"key": "gpio_button_D12",
"interface": "gpio",
"name": "Button Pin D12",
"type": "button",
"resistor": "down",
"edge_detection": "both",
"debounce": 0.05
}]
Note: Be mindful of how edge_detection
works. If you listen to just the fell
or rose
events technically you would never know when the state is the opposite. To help, MudPi still checks for the actual pin state and uses this for what is stored. It is suggested to use the both
option for edge_detection
.
Additional events are exposed to interact with these edge detection changes. ControlPressed
is emitted when a rose
edge is detected and ControlReleased
when a fell
detected. These events are reveresed if invert_state
is true.
Provides a toggle that can turn a GPIO pin on or off.
Option | Type | Required | Description |
key | [String] | Yes | Unique slug id for the component |
pin | [String] | Yes | GPIO pin to use on board i.e. D12 or A1 . |
name | [String] | No | Friendly display name of component. Useful for UI. |
max_duration | [Integer] | No | Failsafe duration (in seconds) to turn off toggle after. 0 means off. Default 0 |
invert_state | [Boolean] | No | Set to True if toggle is off when pin is in HIGH state. Default False |
Here is a config of a complete gpio toggle.
"toggle": [{
"key": "gpio_toggle_D12",
"interface": "gpio",
"name": "Light - Pin D12"
"pin": "D12",
"max_duration": 360,
"invert_state": false
}]