Documentation

GPIO Extension

The GPIO extension controls and monitors GPIO pins on Linux SBC boards such as a Raspberry Pi using adafruit-blinka.

Overview

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.

Sensor Interface

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, e.g. 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

Config Example

mudpi.config.json
{
  "sensor": [
    {
      "key": "gpio_sensor_D12",
      "interface": "gpio",
      "pin": "D12",
      "classifier": "general"
    }
  ]
}

Control Interface

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, e.g. 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.

Config Example

mudpi.config.json
{
  "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. It is suggested to use the both option. MudPi still checks for the actual pin state and uses this for what is stored. Additional events ControlPressed and ControlReleased are emitted for edge detection changes. These events are reversed if invert_state is true.

Toggle Interface

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, e.g. 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

Config Example

mudpi.config.json
{
  "toggle": [
    {
      "key": "gpio_toggle_D12",
      "interface": "gpio",
      "name": "Light - Pin D12",
      "pin": "D12",
      "max_duration": 360,
      "invert_state": false
    }
  ]
}