The document is a continuation of the previous document, if you have landed directly on this page then, Please read from page Get started.

What is Relay?#

Relay is an electronic switch.

Oops!, No Image to display.

List of Relay features implemented in Shunya stack#

With Shunya stack you can make Relay

  1. Switch On/Off.

Using Relay Shunya stack#

Requirements to use Relay Shunya stack#

  1. Shunya OS installed (supported Arm devices) i.e (Raspberry Pi)
  2. 1x Relay

Steps to use Relay Shunya stack#

  1. Connect Relay to your Arm device i.e (Raspberry Pi) .
  2. Switch On/Off Relay.

Run the steps given below inside Shunya OS installed (supported Arm devices).

Step 1: Connect Relay.#

Oops!, No Image to display.

Step 2: Switch On/Off Relay.#

Let's take an example use case: Say we need to

  • Read data from the waterlevel sensor connected to Shunya and,
  • Switch on Relay when the waterlevel is high.

Steps are :

  1. Start with an ready to use template for sending messages via MQTT

    git clone
    cd examples/simple-examples/operate-actuators
  2. Open the operate-actuators.c in an text editor and modify as per your use case.

  3. For our example, we need to first get the waterlevel data, add the code in your main() function

    float waterlevel = 76.98; /* For now lets assume that the waterlevel is 76.89 % full*/
  4. To switch on Relay, modify the code

    int relayPin = 16; /* Define Relay pin, Note this should be as per your connection */
    float waterlevel = 76.89; /* Assume that the waterlevel is 76.89 % full*/
    if (waterlevel == 70.00f){
    setRelay(relayPin, ON); /* Switch on Relay */
    } else {
    setRelay(relayPin, OFF); /* Switch off Relay */
  5. Once you are done editing, save and compile the code , by running

    mkdir build && cd build
    cmake ../
  6. Run the code

    sudo ./operate-actuators

Facing errors with the component?#