# Controlling Relay and LED via Downlink Command

In this section, you will use the **Antares Workshop Shield** on the **Lynx-32 Antares Development Board** module. The **Antares Workshop Shield** contains temperature and humidity sensors (DHT11), relays, LEDs and push buttons. In this tutorial, you will control the relays and LEDs via downlink. The process of sending this downlink uses POSTMAN software which performs a HIT API downlink to the Antares Platform.

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/f4PvA57zISDGOs19xcNE/0_Workshop%20Shield.png" alt=""><figcaption><p>Image of Development Board Lynx-32 and Shield Workshop Antares.</p></figcaption></figure>

## Prerequisites

The required materials follow the **General Prerequisites** on the previous page. If you have not prepared the requirements on that page, then you can visit the following page.

{% content-ref url="../general-prerequisites-esp32-lora" %}
[general-prerequisites-esp32-lora](https://docs.antares.id/en/code-and-library-examples/esp32-lora/general-prerequisites-esp32-lora)
{% endcontent-ref %}

The additional materials specific to this project are as follows.

1. Shield Workshop Antares
2. Postman Software

{% hint style="info" %}
If you have not installed **POSTMAN Software**, you can follow the steps in the following link.

[postman-installation](https://docs.antares.id/en/getting-started/software-installation/postman-installation "mention")
{% endhint %}

## Follow These Steps

### **1.** Launch the Arduino IDE application

### **2.** Opening Sample Programme&#x20;

{% tabs %}
{% tab title="Class A" %}
{% hint style="info" %}
You can open the programme code in the Arduino IDE via  **File > Examples > Antares LoRaWAN >  Lynx32-Simple-Project** > **Class A > DOWNLINK\_RELAY\_LED\_CLASS\_A**
{% endhint %}

Here is the programme code of the **DOWNLINK\_RELAY\_LED\_CLASS\_A** example

```cpp
#include <lorawan.h>
#define RELAY_PIN 25
#define LED_PIN 12

//ABP Credentials
/*
  Notes:
  - select ABP Activation on ANTARES
  - select inherit to generate your keys
  - nwkSKey: 32 digit hex, you can put 16 first digits by first 16 digits your access key and add 16 digits with 0 (ex : abcdef01234567890000000000000000)
  - appSKey: 32 digit hex, put 16 first digits by 0 and put last 16 digits by last 16 digit your access key (ex : 0000000000000000abcdef0123456789)
*/
const char *devAddr = "Lora-Device-Address";      // Replace with the Device Address that you have in the Antares console
const char *nwkSKey = "Network-Session-Key";      // Replace with the Network Session Key that you have in the Antares console
const char *appSKey = "Application-Session-Key";  // Replace with the Application Session Key that you have in the Antares console

const unsigned long interval = 60000;  // 60 s interval to send message
unsigned long previousMillis = 0;      // will store last time message sent
unsigned int counter = 0;              // message counter

char myStr[50];
char outStr[255];
byte recvStatus = 0;
int channel;

const sRFM_pins RFM_pins = {
  .CS = 5,     //LYNX32 to RFM NSS
  .RST = 0,    //LYNX32 to RFM RST
  .DIO0 = 27,  //LYNX32 to RFM DIO0
  .DIO1 = 2,   //LYNX32 to RFM DIO1
};

void setup() {
  // Setup loraid access
  Serial.begin(115200);
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(LED_PIN, OUTPUT);

  digitalWrite(RELAY_PIN, LOW);  // Pastikan relay mati saat awalnya
  digitalWrite(LED_PIN, LOW);    // Matikan LED saat awalnya

  delay(2000);
  if (!lora.init()) {
    Serial.println("RFM95 not detected");
    delay(5000);
    return;
  }

  // Set LoRaWAN Class change CLASS_A or CLASS_C
  lora.setDeviceClass(CLASS_A);

  // Set Data Rate
  lora.setDataRate(SF10BW125);

  // set channel to random
  lora.setChannel(MULTI);

  // Set TxPower to 15 dBi (max)
  lora.setTxPower1(15);

  // Put ABP Key and DevAddress here
  lora.setNwkSKey(nwkSKey);
  lora.setAppSKey(appSKey);
  lora.setDevAddr(devAddr);
}

void loop() {
  // Check interval overflow
  if (millis() - previousMillis > interval) {
    previousMillis = millis();

    sprintf(myStr, "Lora Counter-%d", counter);

    Serial.print("Sending : ");
    Serial.println(myStr);

    lora.sendUplink(myStr, strlen(myStr), 0, 5);
    counter++;
    channel = lora.getChannel();
    Serial.print(F("Ch : "));
    Serial.print(channel);
    Serial.println(" ");
  }

  // Check Lora RX
  lora.update();

  recvStatus = lora.readData(outStr);
  if (recvStatus) {
    int counter = 0;

    for (int i = 0; i < recvStatus; i++) {
      if (((outStr[i] >= 32) && (outStr[i] <= 126)) || (outStr[i] == 10) || (outStr[i] == 13))
        counter++;
    }
    if (counter == recvStatus) {
      Serial.print(F("Received String : "));
      for (int i = 0; i < recvStatus; i++) {
        Serial.print(char(outStr[i]));
      }
    } else {
      Serial.print(F("Received Hex : "));
      for (int i = 0; i < recvStatus; i++) {
        Serial.print(outStr[i], HEX);
        Serial.print(" ");
      }
    }
    Serial.println();

    // Check if the received HEX data is "AA11"
    if (recvStatus == 2 && outStr[0] == 0xAA && outStr[1] == 0x11) {

      digitalWrite(RELAY_PIN, HIGH);
      digitalWrite(LED_PIN, HIGH);
    }
    // Check if the received HEX data is "AA10"
    else if (recvStatus == 2 && outStr[0] == 0xAA && outStr[1] == 0x10) {
      digitalWrite(RELAY_PIN, HIGH);
      digitalWrite(LED_PIN, LOW);
    }
    // Check if the received HEX data is "AA01"
    else if (recvStatus == 2 && outStr[0] == 0xAA && outStr[1] == 0x01) {
      digitalWrite(RELAY_PIN, LOW);
      digitalWrite(LED_PIN, HIGH);
    }
    // Check if the received HEX data is "AA00"
    else if (recvStatus == 2 && outStr[0] == 0xAA && outStr[1] == 0x00) {
      digitalWrite(RELAY_PIN, LOW);
      digitalWrite(LED_PIN, LOW);
    }
  }
}
```

{% endtab %}

{% tab title="Class C" %}
{% hint style="info" %}
You can open the programme code in the Arduino IDE via**File > Examples > Antares LoRaWAN >  Lynx32-Simple-Project** > **Class C > DOWNLINK\_RELAY\_LED\_CLASS\_C**
{% endhint %}

Here is the programme code of the **DOWNLINK\_RELAY\_LED\_CLASS\_C** example

```cpp
#include <lorawan.h>
#define RELAY_PIN 25
#define LED_PIN 12

//ABP Credentials
/*
  Notes:
  - select ABP Activation on ANTARES
  - select inherit to generate your keys
  - nwkSKey: 32 digit hex, you can put 16 first digits by first 16 digits your access key and add 16 digits with 0 (ex : abcdef01234567890000000000000000)
  - appSKey: 32 digit hex, put 16 first digits by 0 and put last 16 digits by last 16 digit your access key (ex : 0000000000000000abcdef0123456789)
*/
const char *devAddr = "Lora-Device-Address";      // Replace with the Device Address that you have in the Antares console
const char *nwkSKey = "Network-Session-Key";      // Replace with the Network Session Key that you have in the Antares console
const char *appSKey = "Application-Session-Key";  // Replace with the Application Session Key that you have in the Antares console

const unsigned long interval = 60000;  // 60 s interval to send message
unsigned long previousMillis = 0;      // will store last time message sent
unsigned int counter = 0;              // message counter

char myStr[50];
char outStr[255];
byte recvStatus = 0;
int channel;

const sRFM_pins RFM_pins = {
  .CS = 5,     //LYNX32 to RFM NSS
  .RST = 0,    //LYNX32 to RFM RST
  .DIO0 = 27,  //LYNX32 to RFM DIO0
  .DIO1 = 2,   //LYNX32 to RFM DIO1
};

void setup() {
  // Setup loraid access
  Serial.begin(115200);
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(LED_PIN, OUTPUT);

  digitalWrite(RELAY_PIN, LOW);  // Pastikan relay mati saat awalnya
  digitalWrite(LED_PIN, LOW);    // Matikan LED saat awalnya

  delay(2000);
  if (!lora.init()) {
    Serial.println("RFM95 not detected");
    delay(5000);
    return;
  }

  // Set LoRaWAN Class change CLASS_A or CLASS_C
  lora.setDeviceClass(CLASS_C);

  // Set Data Rate
  lora.setDataRate(SF10BW125);

  // set channel to random
  lora.setChannel(MULTI);

  // Set TxPower to 15 dBi (max)
  lora.setTxPower1(15);

  // Put ABP Key and DevAddress here
  lora.setNwkSKey(nwkSKey);
  lora.setAppSKey(appSKey);
  lora.setDevAddr(devAddr);
}

void loop() {
  // Check interval overflow
  if (millis() - previousMillis > interval) {
    previousMillis = millis();

    sprintf(myStr, "Lora Counter-%d", counter);

    Serial.print("Sending : ");
    Serial.println(myStr);

    lora.sendUplink(myStr, strlen(myStr), 0, 5);
    counter++;
    channel = lora.getChannel();
    Serial.print(F("Ch : "));
    Serial.print(channel);
    Serial.println(" ");
  }

  // Check Lora RX
  lora.update();

  recvStatus = lora.readData(outStr);
  if (recvStatus) {
    int counter = 0;

    for (int i = 0; i < recvStatus; i++) {
      if (((outStr[i] >= 32) && (outStr[i] <= 126)) || (outStr[i] == 10) || (outStr[i] == 13))
        counter++;
    }
    if (counter == recvStatus) {
      Serial.print(F("Received String : "));
      for (int i = 0; i < recvStatus; i++) {
        Serial.print(char(outStr[i]));
      }
    } else {
      Serial.print(F("Received Hex : "));
      for (int i = 0; i < recvStatus; i++) {
        Serial.print(outStr[i], HEX);
        Serial.print(" ");
      }
    }
    Serial.println();

    // Check if the received HEX data is "AA11"
    if (recvStatus == 2 && outStr[0] == 0xAA && outStr[1] == 0x11) {

      digitalWrite(RELAY_PIN, HIGH);
      digitalWrite(LED_PIN, HIGH);
    }
    // Check if the received HEX data is "AA10"
    else if (recvStatus == 2 && outStr[0] == 0xAA && outStr[1] == 0x10) {
      digitalWrite(RELAY_PIN, HIGH);
      digitalWrite(LED_PIN, LOW);
    }
    // Check if the received HEX data is "AA01"
    else if (recvStatus == 2 && outStr[0] == 0xAA && outStr[1] == 0x01) {
      digitalWrite(RELAY_PIN, LOW);
      digitalWrite(LED_PIN, HIGH);
    }
    // Check if the received HEX data is "AA00"
    else if (recvStatus == 2 && outStr[0] == 0xAA && outStr[1] == 0x00) {
      digitalWrite(RELAY_PIN, LOW);
      digitalWrite(LED_PIN, LOW);
    }
  }
}
```

{% endtab %}
{% endtabs %}

### 3. Set LoRaWAN Parameters in Antares

On the Antares Device console page, set the LoRa by pressing the **Set LoRa** button as shown below.

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/YyjZE2pHTfxq4odKKDqt/ESP%20LORA.png" alt=""><figcaption><p>Image of Antares Console Page for LoRa Set.</p></figcaption></figure>

{% tabs %}
{% tab title="Class A" %}

Input LoRaWAN parameters with **Lora Device Class A, Activation Mode ABP, ABP Parameters Inherit** as shown below.

{% hint style="info" %}
When selecting **ABP Parameters Inherit**, the LoRa parameters will be generated by Antares. From the device side, the **Lynx32 Development Board** needs to adjust the LoRa parameters.
{% endhint %}

{% hint style="warning" %}
Don't forget to save **(copy)** the **Network Session Key** and **Application Session Key** parameters before clicking **Set LoRa** to facilitate the next process.
{% endhint %}

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/UQ12XloVfe7Qsw3FaFmM/kotak%20setlora.png" alt=""><figcaption><p>The Form image contains the LoRa Class A Parameter Set.</p></figcaption></figure>

{% hint style="danger" %}
Make sure your antares account has an active LoRa package.
{% endhint %}
{% endtab %}

{% tab title="Class C" %}

Input LoRaWAN parameters with **Lora Device Class C, Activation Mode ABP, ABP Parameters Inherit** as shown below.

{% hint style="info" %}
When selecting **ABP Parameters Inherit**, the LoRa parameters will be generated by Antares. From the device side, the **Lynx32 Development Board** needs to adjust the LoRa parameters.
{% endhint %}

{% hint style="warning" %}
Don't forget to save **(copy)** the **Network Session Key** and **Application Session Key** parameters before clicking **Set LoRa** to facilitate the next process.
{% endhint %}

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/RVtEL5Tk6XYaZJ7RHKDl/CLASS%20C%20kotak%20setlora.png" alt=""><figcaption><p>The Form image contains the LoRa Class C Parameter Set.</p></figcaption></figure>

{% hint style="danger" %}
Make sure your antares account has an active LoRa package.
{% endhint %}
{% endtab %}
{% endtabs %}

### 4. Set LoRaWAN Parameters in Programme Code

Change the LoRaWAN ABP parameters in the following variables  **`*devAddr`** , **`*nwkSkey`** and **`*appSKey.`** Adjust to the parameters in the Antares console.

```arduino
const char *devAddr = "Lora-Device-Address";
const char *nwkSKey = "Network-Session-Key";
const char *appSKey = "Application-Session-Key"
```

{% hint style="info" %}
The **\*devAddr** parameter that has been generated by Antares can be seen on the device page after completing the **LoRa Set**.
{% endhint %}

{% hint style="info" %}
The parameters **\*nwkSKey** and **\*appSKey** are obtained during **Set LoRa** in the previous step.
{% endhint %}

<figure><img src="https://3873791589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7cujmJ5QHdJaAjH815aZ%2Fuploads%2FqSN5XBRQwz7u9X2FBfA2%2Fimage.png?alt=media&#x26;token=5cd6e73a-b1b6-43fa-9830-164b32165761" alt=""><figcaption><p>Figure Antares Console Page After successful LoRa Set</p></figcaption></figure>

{% hint style="danger" %}
Jika anda lupa menyimpan \***nwkSkey** dan **\*appSKey** pada langkah sebelumnya maka lihat accesskey pada akun antares anda kemudian ikuti format berikut.

{% code overflow="wrap" %}

```arduino
Example Accesskey = "aaaaaaaaaaaaaaaa:bbbbbbbbbbbbbbbb"; //32 digit accesskey

const char *nwkSKey = "aaaaaaaaaaaaaaaa0000000000000000"; //16 digit first accesskey plus 16 digit zero

const char *appSKey = "0000000000000000bbbbbbbbbbbbbbbb"; //16 digit zero plus 16 digit last acesskey
```

{% endcode %}
{% endhint %}

### 5. Compile and Upload Program

Connect the **Lynx-32 Development Board** to your computer and make sure the **Communication Port** is read.

{% hint style="info" %}
On Windows operating systems the check can be done via **Device Manager**. If your **Lynx-32 Development Board** is read, the **USB-Serial CH340** will appear with the port adjusting the port availability (in this case it reads **COM4**).
{% endhint %}

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/O7wSf70q7VXN6doRehSr/Device%20Manager.jpeg" alt=""><figcaption><p>Device Manager image on Windows.</p></figcaption></figure>

Set up the **Lynx-32 Board** by clicking **Tools > Board > ESP32 Arduino** in the Arduino IDE, then make sure the board used is the **ESP32 Dev Module**. Select the port according to the communicaion port that is read (in this case COM4). The result will look like the following picture.

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/jMzRtHhu80aWG1qgmQXt/Menu%20Tools.jpeg" alt=""><figcaption><p>Image of the Tools Menu in the Arduino IDE.</p></figcaption></figure>

After all the setup is complete, upload the programme by pressing the arrow icon as shown below. Wait for the compile and upload process to finish.

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/KDI5lxeTuqyp0QYmXeve/Icon%20Verify%20dan%20Upload.jpeg" alt=""><figcaption><p>Image of the Verify and Upload Icon in the Arduino IDE.</p></figcaption></figure>

{% hint style="info" %}
**The Tick icon** on the Arduino IDE is just the verify process. Usually used to **Compile** the programme to find out whether there are errors or not. \
**The Arrow icon** on the Arduino IDE is the verify and upload process. Usually used to **Compile** the programme as well as Flash the programme to the target board.
{% endhint %}

If the programme upload is successful, it will look like the following image.

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/v1Gox1gwKygCgqewVExu/Upload%20Berhasil.jpeg" alt=""><figcaption><p>Arduino IDE page image after successful upload.</p></figcaption></figure>

After uploading the programme, you can view the **serial monitor** to debug the programme. The **serial monitor** icon is shown in the following image.

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/7iXHNwJUBJMdTPvroCHy/Icon%20Serial%20Monitor.jpeg" alt=""><figcaption><p>Image of the Serial Monitor Icon in the Arduino IDE.</p></figcaption></figure>

Set the **serial baud rate** to 115200 and select BothNL & CR. The result will look like the following image.

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/xIKhbtWlyAL5kV2dMWgm/Gambar%20Serial%20Monitor.jpeg" alt=""><figcaption><p>Serial Monitor Display</p></figcaption></figure>

{% hint style="danger" %}
Make sure the **serial baud rate** matches the value defined in the programme code. If the **serial baud rate** is not the same between the **programme code** and the **serial monitor**, the ASCII characters will not be read properly
{% endhint %}

### 6. Setup POSTMAN Software

In this step, you need POSTMAN software. You can input the **end-point, request header**, and **request body** first by following the following format.

#### End Point

<table data-header-hidden><thead><tr><th width="119"></th><th></th></tr></thead><tbody><tr><td><strong>Methode</strong></td><td>POST</td></tr><tr><td><strong>URL</strong></td><td>https://platform.antares.id:8443/~/antares-cse/antares-id/<mark style="color:red;">your-application-name/your-device-name</mark></td></tr></tbody></table>

{% hint style="info" %}
Customise <mark style="color:red;">your-application-name</mark> and <mark style="color:red;">your-device-name</mark> to the names registered to your Antares account.
{% endhint %}

#### Request Header

| **Key**      | **Value**                                       |
| ------------ | ----------------------------------------------- |
| X-M2M-Origin | <mark style="color:red;">your-access-key</mark> |
| Content-Type | application/json;ty=4                           |
| Accept       | application/json                                |

{% hint style="info" %}
Customise <mark style="color:red;">your-access-key</mark> with your Antares account access key.
{% endhint %}

The result is as shown in the following image.

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/7p87ee4RDHN5micRaC2h/POSTMAN%201.png" alt=""><figcaption><p>Image of end-point and header settings in POSTMAN software.</p></figcaption></figure>

Next you need to input the request body to follow the following format.

#### Request Body

{% tabs %}
{% tab title="Default Downlink Port" %}

```json
{
      "m2m:cin": {
        "con": "{\"type\":\"downlink\", \"data\":\"your-downlink-data\"}"
    }
}
```

{% hint style="info" %}
Default Downlink Port is port 10.&#x20;
{% endhint %}
{% endtab %}

{% tab title="Custom  Downlink Port" %}

```json
{
      "m2m:cin": {
        "con": "{\"type\":\"downlink\", \"data\":\"your-downlink-data\", \"fport\":5}"
    }
}
```

{% hint style="info" %}
If you are using a Custom Downlink Port then fill the "fport" field with an integer number other than 0.&#x20;
{% endhint %}
{% endtab %}
{% endtabs %}

In the POSTMAN software, select the **Body** tab then select **raw** and enter the payload according to the request body you want to use as shown below.

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/gCm9rHiAXIzQI32ZKM3I/POSTMAN2.png" alt=""><figcaption><p>Image of the contents of the payload request body in the POSTMAN software</p></figcaption></figure>

{% hint style="info" %}
Customise the contents of the **"data"** field according to the downlink command you want to send.
{% endhint %}

### 7. Sending Downlink Messages

After the POSTMAN software setup is complete, it's time to send the downlink command. The "data" field is filled with a hexadecimal number of 4 Inputs as a message to be sent via the downlink lorawan. If you have finished filling in the "data" field, then press the **Send** button on the POSTMAN software.

There are 4 Hexadecimal Inputs to control the Relay and LEDs listed in the table below.

| Input Hexadecimal | Relay | LED |
| ----------------- | ----- | --- |
| AA00              | OFF   | OFF |
| AA01              | OFF   | ON  |
| AA10              | ON    | OFF |
| AA11              | ON    | ON  |

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/rHhftCBo6ZoRjCjLgGOP/Isi%20Pesan%20Downlink.png" alt=""><figcaption><p>Image of downlink message content in POSTMAN software.</p></figcaption></figure>

If the HTTP request through POSTMAN software is successful, the POSTMAN software response section will display a message as shown below.

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/lC1W8q70PlTq6sqUrZ4G/Response%20HIT%20API.png" alt=""><figcaption><p>Downlink API hit response image in POSTMAN software.</p></figcaption></figure>

### 8.Check Data in Antares&#x20;

After the step of sending the downlink message in the POSTMAN software is successful, then open the Antares device page and see if the downlink command has entered Antares.

<figure><img src="https://3873791589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7cujmJ5QHdJaAjH815aZ%2Fuploads%2FTQToq1ILadCOeEuawf2P%2Fimage.png?alt=media&#x26;token=c6351f97-afb2-4b30-a9cb-8a10cd3c7bc5" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3873791589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7cujmJ5QHdJaAjH815aZ%2Fuploads%2FNaOL4A8US9ByNes638ht%2Fimage.png?alt=media&#x26;token=7a70f7cd-efe4-47cc-8408-aa0221a0ad6f" alt=""><figcaption></figcaption></figure>

The form of downlink data received by the antares will be in JSON format as follows.

<pre class="language-json"><code class="lang-json">{
<strong>    "type": "downlink",
</strong>    "data": "AA11"
}
</code></pre>

{% hint style="info" %}
The data sent from **POSTMAN** is in the form of **"type": "downlink"** and **"data"**. The downlink message passed to the **Lynx-32 Development Board** is in the **"data"** field.
{% endhint %}

### 9. View Downlink Messages

The downlink messages forwarded from Antares to the **Lynx-32 Development Board** can be seen in the Serial Monitor as shown below.

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/perxBNU2YCOkLKyrLnTj/Pesan%20Downlink%20Serial%20Monitor.png" alt=""><figcaption><p>Image of the downlink message received on the Serial Monitor.</p></figcaption></figure>

{% tabs %}
{% tab title="Class A" %}
{% hint style="info" %}
In LoRaWAN Class A, the downlink message will be received by **Lynx-32** after **Lynx-32** performs an uplink.
{% endhint %}
{% endtab %}

{% tab title="Class C" %}
{% hint style="info" %}
In LoRaWAN Class C, downlink messages will be received by **Lynx-32** at any time.
{% endhint %}
{% endtab %}
{% endtabs %}

The received downlink message commands the Relay and LED to Switch Off or On

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/4M9zd9DdYZxgnN56ZxJr/ESP32%20RELAY_LED.png" alt=""><figcaption><p>Relay Picture of LED Turning On</p></figcaption></figure>
