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
  • Prerequisites
  • Follow These Steps
  • 1. Launch the Arduino IDE application
  • 2. Opening Sample Programme
  • 3.Set LoRaWAN Parameters in Antares
  • 4. Set LoRaWAN Parameters in Programme Code
  • 5. Compile and Upload Program
  • 6. Setup POSTMAN Software
  • 7. Sending Downlink Messages
  • 8. Check Data in Antares
  • 9. View Downlink Messages
  1. Code and library examples
  2. ESP32 (LoRa)
  3. Project Simple Lynx-32 LoRa Antares

Downlink Data Displayed on OLED

PreviousUplink DHT11 Data and Display on OLED DisplayNextDHT 11 Uplink Data and Downlink Data displayed on OLED

Last updated 8 months ago


In this project, you will use the Antares Workshop Shield on the Lynx-32 Antares Development Board module. In this Antares Workshop Shield, there are temperature, humidity (DHT11), relay, LED and push button sensors. You will send a downlink message then displayed on the OLED display. The process of sending this downlink uses POSTMAN software which performs HIT API downlink to the Antares Platform.

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.

The additional materials specific to this project are as follows.

  1. Shield Workshop Antares

  2. SSD1306 0.96inch 128x64 pixel OLED module based on I2C.

  1. OLED display library. This documentation uses Adafruit_SSD1306 version 2.5.7.

If you have not installed the Adafruit_SSD1306 library version 2.5.7, you can follow the steps in the following link.

Adafruit SSD1306

  1. Postman Software.

If you have not installed POSTMAN Software you can follow the steps in the following link.

Postman Installation

Follow These Steps

1. Launch the Arduino IDE application

2. Opening Sample Programme

You can open the programme code in the Arduino IDE via File > Examples > Antares LoRaWAN > Lynx32-Simple-Project > Class A > DOWNLINK_OLED_CLASS_A.

Here is the programme code of the DOWNLINK_OLED_CLASS_A example.

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <lorawan.h>

// OLED Initialitation
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

//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);
  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);

  // OLED initialization
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // OLED initialization with address 0x3C
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.display();
  delay(2000);
}

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]));
      }
      // Show on OLED
      display.clearDisplay();
      display.setTextSize(1);
      display.setTextColor(SSD1306_WHITE);
      display.setCursor(0, 0);
      display.println("Received String : ");
      display.println((char*)outStr);
      display.display();
    }
    else
    {
      Serial.print(F("Received Hex : "));
      for (int i = 0; i < recvStatus; i++)
      {
        Serial.print(outStr[i], HEX); Serial.print(" ");
      }

      display.clearDisplay();
      display.setTextSize(1);
      display.setTextColor(SSD1306_WHITE);
      display.setCursor(0, 0);
      display.println("Received Hex : ");
      for (int i = 0; i < recvStatus; i++) {
        display.print(outStr[i] < 16 ? "0" : "");
        display.print(outStr[i], HEX);
        display.print(" ");
      }
      display.display();
    }
    Serial.println();
  }

}

You can open the programme code in the Arduino IDE via File > Examples > Antares LoRaWAN > Lynx32-Simple-Project > Class C > DOWNLINK_OLED_CLASS_C.

Here is the programme code of the DOWNLINK_OLED_CLASS_C example.

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <lorawan.h>

// OLED Initialitation
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

//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);
  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);

  // OLED initialization
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // OLED initialization with address 0x3C
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.display();
  delay(2000);
}

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]));
      }
      // Show on OLED
      display.clearDisplay();
      display.setTextSize(1);
      display.setTextColor(SSD1306_WHITE);
      display.setCursor(0, 0);
      display.println("Received String : ");
      display.println((char*)outStr);
      display.display();
    }
    else
    {
      Serial.print(F("Received Hex : "));
      for (int i = 0; i < recvStatus; i++)
      {
        Serial.print(outStr[i], HEX); Serial.print(" ");
      }

      display.clearDisplay();
      display.setTextSize(1);
      display.setTextColor(SSD1306_WHITE);
      display.setCursor(0, 0);
      display.println("Received Hex : ");
      for (int i = 0; i < recvStatus; i++) {
        display.print(outStr[i] < 16 ? "0" : "");
        display.print(outStr[i], HEX);
        display.print(" ");
      }
      display.display();
    }
    Serial.println();
  }

}

3.Set LoRaWAN Parameters in Antares

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

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

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.

Don't forget to save (copy) the Network Session Key and Application Session Key parameters before clicking Set LoRa to facilitate the next process.

Make sure your antares account has an active LoRa package.

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

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.

Don't forget to save (copy) the Network Session Key and Application Session Key parameters before clicking Set LoRa to facilitate the next process.

Make sure your antares account has an active LoRa package.

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.

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

The *devAddr parameter that has been generated by Antares can be seen on the device page after completing the LoRa Set.

The parameters *nwkSKey and *appSKey are obtained during Set LoRa in the previous step.

Jika anda lupa menyimpan *nwkSkey dan *appSKey pada langkah sebelumnya maka lihat accesskey pada akun antares anda kemudian ikuti format berikut.

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

5. Compile and Upload Program

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

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).

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.

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.

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.

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

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

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

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.

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

Methode

POST

URL

https://platform.antares.id:8443/~/antares-cse/antares-id/your-application-name/your-device-name

Customise your-application-name and your-device-name to the names registered to your Antares account.

Request Header

Key

Value

X-M2M-Origin

your-access-key

Content-Type

application/json;ty=4

Accept

application/json

Customise your-access-key with your Antares account access key.

The result is as shown in the following image.

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

Request Body

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

Default Downlink Port is port 10.

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

If you are using a Custom Downlink Port then fill the "fport" field with an integer number other than 0.

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.

Customise the contents of the "data" field according to the downlink command you want to send.

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 the string "test" as the 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.

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

8. Check Data in Antares

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.

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.

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.

In LoRaWAN Class A, the downlink message will be received by Lynx-32 after Lynx-32 performs an uplink.

In LoRaWAN Class C, downlink messages will be received by Lynx-32 at any time.

The received downlink message is also displayed on the OLED as shown below.

General Prerequisites ESP32 LoRa
Image of Development Board Lynx-32 and Shield Workshop Antares.
Image of 0.96-inch SSD1306 Oled Module.
Image of the Antares Console Page for LoRa Set.
The Form image contains the LoRa Class A Parameter Set.
The Form image contains the LoRa Class C Parameter Set.
Figure Antares Console Page After successful LoRa Set
Device Manager image on Windows.
Image of the Tools Menu in the Arduino IDE.
Image of the Verify and Upload Icon in the Arduino IDE.
Arduino IDE page image after successful upload.
Image of the Serial Monitor Icon in the Arduino IDE.
Set the serial baud rate to 115200 and select BothNL & CR. The result will look like the following image.
Image of end-point and header settings in POSTMAN software.
Image of the contents of the payload request body in the POSTMAN software.
Image of downlink message content in POSTMAN software.
Downlink API hit response image in POSTMAN software.
Downlink data image on the Antares device console page.
Image of the downlink message received on the Serial Monitor.
Image of the downlink message displayed on the OLED display.