View on GitHub

relay-docs

General Purpose Input Output (GPIO)

Devices can declare their GPIO capabilities which allows the Relay Cloud portal to show simple controls for reading and writing GPIO pins.

This allows you switch connected devices on and off, and read high and low values.

Controlling Raspberry Pi GPIO

GPIO Data Specification

Request from Relay Cloud

The Relay cloud will make a request to {device IP}:{device port}/api/1.0/gpio.

The request will be accompanied by a JWT on the Authorization header, the scheme will be Bearer.

The JWT will be digitally signed and can be cryptographically verified by the keys published here.

To minimise the potential of replay attacks, the JWT will contain a single scope: read-gpio, and the lifetime of the JWT will be 5 minutes. The JWT does not support refresh flows.

Response from your device

The response from your device will be a JSON array containing zero or more objects with the following structure:

    [{
        "pinInfo":{
            "number":2,
            "type":"Gpio",
            "canRead":true,
            "canWrite":true,
            "name":"GPIO 2 (SDA)"
        },
        "pinOpen":false,
        "pinMode":null,
        "value":null
    }
    ....
    ]

Explanation of properties:

The response represents two things. First, the pin and its capabilities:

And the current state of the pin:

PinInfo Object

For more advanced device data handling than just high/low, please see Custom Properties.