Antares
Antares
en
en
  • Getting Started
    • Account Registration
    • Create App
    • Add Devices to the Application
    • Installation Board and Library
      • ESP8266
      • ESP32
      • STM32
    • Arduino IDE Installation
    • Arduino Library Installation
      • Antares LoRaWAN
      • Antares Wi-Fi HTTP
      • Antares Wi-Fi MQTT
      • DHT11 Sensor Library
      • Adafruit SSD1306
    • STM32 Cube IDE Installation
    • Expansion Pack I-CUBE-LRWAN Installation
    • Software Installation
      • MQTTX Installation
      • Postman Installation
      • Operating System (OS) on SD Card Installation
    • Quickstart
  • Antares Insight Hub
    • Getting Started
      • Request Demo
      • Request Free Trial
    • Usecase
      • Power Meter
        • Power Meter Usecase Prerequisites
        • Power Meter Device Recommendation
        • Payload Example Power Meter
        • Setup Device Threshold Power Meter
      • Water Meter
        • Water Meter Usecase Prerequisites
        • Water Meter Device Recommendation
        • Payload Example Water Meter
        • Setup Device Threshold Water Meter
      • Water Level
        • Water Level Usecase Prerequisites
        • Water Level Device Recommendation
        • Payload Example Water Level
        • Setup Device Threshold Water Level
      • Environment Monitoring
        • Prerequisites for Use of Environmental Monitoring
        • Environment Monitoring Device Recommendation
        • Payload Example Environment Monitoring
        • Setup Device Threshold Environment Monitoring
    • Settings
      • Manage Alert Recipient (Telegram)
      • Manage User
      • Roles
  • Subscription and Payment
    • Platform
      • How to Use Platform Packages
      • How to Purchase a Platform Subscription
        • Payment Using Antares Coins
        • Payment Using Virtual Account
          • Mandiri Bank
          • Permata Bank
          • BRI Bank
          • BNI Bank
        • Payment Using e-Wallet (LinkAja)
        • Payment Using Credit Cards (CC)
      • Procedure for Renewing a Platform Subscription
      • Procedure for Changing Platform Subscription
    • Connectivity
      • How to Use Connectivity Packages
      • How to Purchase a Connectivity Subscription
        • Payment Using Antares Coins
        • Payment Using Virtual Account
          • Mandiri Bank
          • Permata Bank
          • BRI Bank
          • BNI Bank
        • Payment Using e-Wallet (LinkAja)
        • Payment Using Credit Cards (CC)
      • Procedure for Renewing a Platform Subscription
      • Procedure for Changing Connectivity Subscription
    • Antares Coins
      • Antares Coins Top Up Payment Procedures
        • Payment Using Virtual Account
          • Mandiri Bank
          • Permata Bank
          • BRI Bank
          • BNI Bank
        • Payment Using e-Wallet (LinkAja)
        • Payment Using Credit Cards (CC)
  • Code and library examples
    • ESP8266 (Wi-Fi)
      • General Prerequisites ESP8266 Wi-Fi
      • ESP8266 (Wi-Fi) HTTP Protocol
        • Sending Simple Data to Antares with HTTP Protocol
        • Retrieve the Last Data from Antares Server with HTTP Protocol
        • Simple Project ESP8266 HTTP Antares
          • Periodic Post DHT 11 Data
          • Post DHT 11 Data with Push Button
          • Post DHT 11 data and Display on OLED
          • Get Data displayed on OLED
          • Post and Get DHT 11 Data displayed on OLED
          • Controlling Relays and LEDs Through Get Commands
      • ESP8266 (Wi-Fi) MQTT Protocol
        • Sending Simple Data to Antares with the MQTT Protocol
        • Retrieve Last Data from Antares Server with MQTT Protocol
        • Simple Project ESP8266 MQTT Antares
          • Periodic Send DHT 11 Data
          • Send DHT 11 Data with Push Button
          • Send DHT 11 data and display on OLED display
          • Retrieve Data displayed on OLED Display
          • DHT 11 Send Data and Retrieve Data displayed on OLED Display
          • Controlling Relays and LEDs Through Get Commands
    • Arduino Uno
      • Arduino IDE Installation
      • Antares Ethernet Shield Library Installation
      • Configuration
      • Send Simple Data to Antares
    • ESP32 (Wi-Fi)
      • General Prerequisites ESP32 Wi-Fi
      • ESP32 (Wi-Fi) HTTP Protocol
        • Sending Simple Data to Antares with HTTP Protocol
        • Retrieve the Last Data from Antares Server with HTTP Protocol
        • Simple Project Lynx-32 HTTP Antares
          • Periodic Post DHT 11 Data
          • Post DHT 11 Data with Push Button
          • Post DHT 11 Data and Display on OLED
          • Get Data displayed on OLED
          • Post and Get DHT 11 Data displayed on OLED
          • Controlling Relays and LEDs Through Get Commands
      • ESP32 (Wi-Fi) MQTT Protocol
        • Sending Simple Data to Antares with the MQTT Protocol
        • Retrieve Last Data from Antares Server with MQTT Protocol
        • Simple Project Lynx-32 MQTT Antares
          • Periodic Send DHT 11 Data
          • Send Data DHT 11 dengan Push Button
          • Send DHT 11 Data and Display on OLED
          • Retrieve Data displayed on OLED Display
          • DHT 11 Send Data and Retrieve Data displayed on OLED
          • Controlling Relays and LEDs Through Retrieve Commands
      • HTTP & MQTT Protocol
    • ESP32 (LoRa)
      • General Prerequisites ESP32 LoRa
      • Sending Simple Data to Antares
      • Project Simple Lynx-32 LoRa Antares
        • Uplink DHT11 Data Periodically
        • Uplink Data DHT11 dengan Push Button
        • Uplink DHT11 Data and Display on OLED Display
        • Downlink Data Displayed on OLED
        • DHT 11 Uplink Data and Downlink Data displayed on OLED
        • Controlling Relay and LED via Downlink Command
      • LoRaWAN Class
    • STM32 (LoRa) STM32Cube IDE
      • General Prerequisites STM32 (LoRa) STM32Cube IDE
      • Sending Simple Data to Antares
    • STM32 (LoRa) Arduino IDE
      • General Prerequisites STM32 (LoRa) Arduino IDE
      • Sending Simple Data to Antares
    • Raspberry Pi
      • GUI (Graphical User Interface)
        • Raspberry GUI General Prerequisites
        • Sending Data Using Node.js
        • Temperature and Humidity Monitoring Using DHT11 Sensor
      • SSH (Secure Shell)
        • Common Raspberry SSH Prerequisites
        • Sending Data Using Node.js
        • Temperature and Humidity Monitoring Using DHT11 Sensor
    • NB-IoT
      • NB-Lynx-7000
        • General Prerequisites NB-Lynx-7000
        • Sending Simple Data to Antares
        • Retrieving GNSS (Global Navigation Satellite System) Data
      • NB-Lynx-95
        • General Prerequisites NB-Lynx-95
        • Sending Simple Data to Antares
    • Android
      • Retrieve data from ANTARES using Android
      • Coding Stuff
    • MIT App Inventor
    • Node-RED
    • Postman
    • MQTT | Push data to Device
    • HTTP | Subscribe and Notify Mechanism
    • PHP Library
    • MQTT | Subscribe LoRa Device
    • LoRaWAN | Downlink Tutorial
    • LoRaWAN Device Register
      • Register Menu
    • GPS TrackerID
  • Data Model
  • Port Configuration
  • API | HTTP
    • Device
    • Data of Device
    • Subscriber
  • API | MQTT
    • Device
    • Subscriber
  • List of Acronyms
  • Relevant Software
Powered by GitBook
On this page
  • Sending Downlink via POSTMAN Software
  • Sending Downlink via MQTT FX Software
  1. Code and library examples

LoRaWAN | Downlink Tutorial

PreviousMQTT | Subscribe LoRa DeviceNextLoRaWAN Device Register

Last updated 8 months ago

LoRaWAN Downlink Tutorial

1. Introduction

In this tutorial, you will use POSTMAN or MQTT FX software to send downlink messages to your LoRaWAN device. The module used in this tutorial is the Arduino LoRa Antares module based on Arduino Pro Mini (ATMEGA328P).

2. Prerequisites

Before you start, make sure you have fulfilled the following conditions:

c. LoRaWAN Library: Download the LoraWAN Library in the Arduino IDE. Click the link below:

*Note: Library is only for LYNX-32 board.

3. Device Configuration

a. Log in to your Antares account console page. Create a device on the application in your account console. If you already have a device you can immediately open the device page that you created earlier. Then click Set LoRa as in the following image:

Then the Set LoRa Device dialogue box will appear as shown below. In the Select LoRa Device Class option, select Class C > ABP Activation > ABP Parameter Inherit > Click Set LoRa.

b.In the Arduino IDE, configure the Arduino Pro or Pro Mini as the board you will be using. Click Tools > Board > Arduino Pro or Pro Mini.

c. In the Arduino IDE, configure the Processor ESP32 dev board as the processor you will use. Click Tools > Processor > ESP32 dev board. *Notes: If using another board, select according to the board used

d. In the Arduino IDE, configure the Port according to the Arduino LoRa Board you are using. Click Tools > Port > COM ....

e. In the Arduino IDE, upload the class C example program from the loraid library via File> Examples> Antares LoRaWAN> send-class-C-ABP. Adjust the access key data and also the device address according to the account in ANTARES. Here is the source code for the example class C file.

#include <lorawan.h>

//ABP Credentials
const char *devAddr = "Lora-Device-Address";
const char *nwkSKey = "Network-Session-Key";
const char *appSKey = "Application-Session-Key";



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

char myStr[50];
byte outStr[255];
byte recvStatus = 0;
int port, channel, freq;
bool newmessage = false;

const sRFM_pins RFM_pins = {
  .CS = 5,
  .RST = 0,
  .DIO0 = 27,
  .DIO1 = 2,
};

void setup() {
  // Setup loraid access
  Serial.begin(115200);
  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 FramePort Tx
  lora.setFramePortTx(5);

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

  // Set TxPower to 15 dBi (max)
  lora.setTxPower(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);
    port = lora.getFramePortTx();
    channel = lora.getChannel();
    freq = lora.getChannelFreq(channel);
    Serial.print(F("fport: "));    Serial.print(port);Serial.print(" ");
    Serial.print(F("Ch: "));    Serial.print(channel);Serial.print(" ");
    Serial.print(F("Freq: "));    Serial.print(freq);Serial.println(" ");

  }

  // Check Lora RX
  lora.update();

  recvStatus = lora.readDataByte(outStr);
  if (recvStatus) {
    newmessage = true;
    int counter = 0;
    port = lora.getFramePortRx();
    channel = lora.getChannelRx();
    freq = lora.getChannelRxFreq(channel);

    for (int i = 0; i < recvStatus; i++)
    {
      if (((outStr[i] >= 32) && (outStr[i] <= 126)) || (outStr[i] == 10) || (outStr[i] == 13))
        counter++;
    }
    if (port != 0)
    {
      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();
      Serial.print(F("fport: "));    Serial.print(port);Serial.print(" ");
      Serial.print(F("Ch: "));    Serial.print(channel);Serial.print(" ");
      Serial.print(F("Freq: "));    Serial.println(freq);Serial.println(" ");
    }
    else
    {
      Serial.print(F("Received Mac Cmd : "));
      for (int i = 0; i < recvStatus; i++)
      {
        Serial.print(outStr[i], HEX); Serial.print(" ");
      }
      Serial.println();
      Serial.print(F("fport: "));    Serial.print(port);Serial.print(" ");
      Serial.print(F("Ch: "));    Serial.print(channel);Serial.print(" ");
      Serial.print(F("Freq: "));    Serial.println(freq);Serial.println(" ");
    }
  }
} 

After uploading the class C example programme on the board used. Make sure the device has sent lora data and arrived at the ANTARES platform. If the data from the board can enter ANTARES, then the next step is to downlink (send a message) to the device via the ANTARES Platform via POSTMAN or MQTT FX.

Sending Downlink via POSTMAN Software

After you have finished configuring the device and the device is confirmed to be able to send data to ANTARES, it's time to try to send a downlink to the device via the ANTARES Platform using POSTMAN software.

To perform the downlink, the POST method is used. To perform this POST method, header and body parameters are required. Firstly, fill in the Header parameters according to the table below: *Notes: Customise the access key and URI address parameters according to your account.

Field

Initial Value

Current Value

access-key

your-access-key

your-access-key

application-name

your app name in ANTARES

your app name in ANTARES

device-name

your device name in ANTARES

your device name in ANTARES

e-mail

Your e-mail

Your e-mail

If filled in, the header will look like this

Then next to the body section. In this body section contains the data you want to send to your LoRa device. Fill in the Body parameter according to what you want to send to the device by following the format below:

Field

Value

Body

If the body parameter has been filled in, it will look like the image below:

Click send to execute POST downlink message to ANTARES. If it has been POSTed, the downlink message will be sent directly to the device via the nearest LoRa gateway. The downlink message can be seen through the serial monitor on the Arduino IDE.

If using an Arduino board, you can use a Baud Rate of 9600 to view the received downlink data. Here is an example of a serial monitor when successfully receiving a downlink:

Sending Downlink via MQTT FX Software

After you have finished configuring the device and the device is confirmed to be able to send data to ANTARES, apart from using POSTMAN, for those of you who are more suitable for using the MQTT protocol, you can try to send a downlink to the device via the ANTARES Platform using MQTT FX software.

In this section, to send data via MQTT FX, you need to configure the broker to the ANTARES Platform as follows:

Host

mqtt.antares.id

Port

1883

For the Client ID section, it can be adjusted to your account access key or other uniqe code. After it is appropriate, it can be saved by pressing the save button. After the broker configuration is appropriate, it can be directly connected to the ANTARES MQTT broker by pressing the Connect button.

If it is connected, it will display a green circle on the top right as shown:

After connecting, the next step is to send a publish to ANTARES to a device registered with ANTARES by inputting the topic and also the content body as follows:

Topic

/oneM2M/req/your-access-key/antares-cse/json

Payload

After the access key data and device address are correct, click the publish button to send the data to ANTARES.

If you successfully enter ANTARES, the ANTARES device will appear as shown below:

If you successfully enter ANTARES, the ANTARES device will appear as shown below:

a. Install the Arduino IDE on your computer. Click if you haven't installed it yet.

b. To find out how to install the ESP32 library Click Tutorial Here

d. To use RESTFUL API based on HTTP protocol, you need to install POSTMAN software. Click if you haven't installed it yet.

e. To use the RESTFUL API based on the MQTT protocol, you need to install the MQTT FX software. Click if you have not installed it yet.

If you have not installed POSTMAN, you can follow the tutorial on the .

{
      "m2m:cin": {
        "con": "{\"type\":\"downlink\", \"data\":\"your-downlink-data\"}"
    }
}
{
  "m2m:rqp": {
    "fr": "your-access-key",
    "to": "/antares-cse/antares-id/your-application-name/your-device-name",
    "op": 1,
    "rqi": 123456,
    "pc": {
      "m2m:cin": {
        "cnf": "message",
        "con": "{\"type\":\"downlink\",\"data\":\"your-downlink-data\"}"
      }
    },
    "ty": 4
  }
}
Arduino IDE Software
ESP32 Board Install Tutorial
POSTMAN Software
MQTT FX Software
POSTMAN Tutorial page
45KB
LoRaWAN-Arduino-Library.rar