-
Notifications
You must be signed in to change notification settings - Fork 41
Configuring GPIO for use with the gpio adapter
Michael Stegeman edited this page Apr 11, 2018
·
3 revisions
By default, the gpio-adapter only has a single gpio pin enabled, pin 18.
To view the GPIO configuration, you can navigate to Settings -> Add-ons in the UI, and click Configure
on the gpio-adapter
entry.
The gpio-adapter uses the node library onoff to configure the pins, so you can refer to that documentation for full details.
-
"pin"
is the pin number. -
"name"
is an arbitrary name that you assign to the pin. This will show up in the UI as the default name. -
"direction"
may be"in"
or"out"
(currently"high"
and"low"
are not supported).- If
direction
is set toin
, the following may also be configured:-
"edge"
which may be one of"none"
,"rising"
,"falling"
, or"both"
. -
"debounce"
which is a number indicating the number of milliseconds that the input should be debounced for. If no debounce is provided, then a default of 10 milliseconds will be used. Setting debounce to 0 will disable the debounce logic.
-
- If
direction
is set toout
, the following may also be configured:-
"value"
which is the initial value
-
- If
So for example, the following configuration would have pin 18 as an output and pin 23 as an input:
{
"gpios": [
{
"pin": 18,
"name": "led",
"direction": "out",
"value": 0
},
{
"pin": 23,
"name": "button",
"direction": "in",
"edge": "both",
"debounce": 10
}
]
}