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
  • Install and Create an Application
  • Start Apache on XAMPP
  • Get all Devices on Application with Latest Data
  • Get Data ID on Devices by Limit
  • Store Data to Devices
  1. Code and library examples

PHP Library

PreviousHTTP | Subscribe and Notify MechanismNextMQTT | Subscribe LoRa Device

Last updated 8 months ago

Install and Create an Application

A. Requirements

  • Already installed the sublime application, if you don't have the sublime application please download it at the following link. .

  • Already installed the xampp application, if you don't have the xampp application please download it at the following link. .

B. Steps

  1. Please download the antares php library and save it on your local computer by clicking the button below.

  1. Firstly, register to create an antares account by .

  2. Next, fill in the email, password and name on Antares and click the create account button and wait for the notification.

  3. Next, open the email to verify your Antares account.

  4. After verification is complete, login to the Antares account that you have created

  5. After logging into the Antares account, the next step is to click account, an example is shown in the image below

  6. After clicking the account, the Access Key will appear and then click save access key to proceed to the next step.

  7. Create application, if you have already created an application, ignore it and continue to the next process.

  8. Next, click add to create an application on the Antares platform.

  9. Create device, if you have already created the device you can ignore this process and proceed to the next step.

  10. First create a device name as shown below, in this tutorial the device will be named "sensorSignal". then also select one of the active packages that will be used for the device to be created. In this tutorial using a trial package where the package is only active for seven days. If you have set the device name and selected the package then click +AddFirst create a device name as shown below, in this tutorial the device will be named "sensorSignal". then also select one of the active packages that will be used for the device to be created. In this tutorial using a trial package where the package is only active for seven days. If you have set the device name and selected the package then click +Add

A display of the device that has been created will appear. Data from the device will be entered and displayed in the table provided as shown below.

Start Apache on XAMPP

  1. Next extract the php library that has been downloaded and then copy it to C: \xampp\htdocs, in this tutorial xampp is installed in the C directory.

  1. Next, open xampp then turn on the apache module and wait until the module is green, for example the image as below.

Get all Devices on Application with Latest Data

  1. Open the sublime/visualcode/notepad++ application then drag the example.php and Antares.php that have been copied to the xampp htdocs.

  2. Next, use the script section in example.php and also fill in the variables according to the example below. For other lines, you can comment firs

require_once('./Antares.php');

Antares::init([
  "PLATFORM_URL" => 'https://platform.antares.id:8443', // TODO: Change this to your platform URL
  "ACCESS_KEY" => '{{accesskey}}' // TODO: Change this to your access key
]);
try {
  // RETRIEVE DATA
  echo "============================ Retrieve data =================================\n";
  echo "";
  // get application
  // application name example '/antares-cse/antares-id/example'
  $resp = Antares::getInstance()->get('/antares-cse/antares-id/{{applicationname}}'); // TODO: Change this to your application uri
  if ($resp instanceof AE) {
    echo nl2br("AE: " . $resp->getName() . "\n");
    
    // list all application's devices
    $cntUris = $resp->listContainerUris();
    echo "Containers: " . count($cntUris) . "\n";
    echo "";
    
    foreach ($cntUris as $cntUri) {
      echo "  " . $cntUri . "\n";
      echo "";

      // get device
      $cnt = Antares::getInstance()->get($cntUri);
      echo "    " . $cnt->getName() . "\n";
      echo "";

      try {
        // get latest data
        $la = $cnt->getLatestContentInstace();
        echo "      [$la->ct]:$la->rn $la->con\n";
        echo "";
      } catch (Exception $e) {
        echo "      last data: " . $e->getMessage() . "\n";
        echo "";
      }
    }
  }
} catch (Exception $e) {
  echo($e->getMessage());
}
  1. The next step is to open http://localhost/antares-php/example.php (according to the storage folder in htdocs) in the browser, then the following results will appear:

Get Data ID on Devices by Limit

  1. Open the sublime/visualcode/notepad++ application then drag the example.php and Antares.php that have been copied to the xampp htdocs.

  2. Next, use the script section in example.php and also fill in the variables according to the example below. For other lines, you can comment first

    require_once('./Antares.php');
    
    Antares::init([
      "PLATFORM_URL" => 'https://platform.antares.id:8443', // TODO: Change this to your platform URL
      "ACCESS_KEY" => '{{accesskey}}' // TODO: Change this to your access key
    ]);
    try {
      // DISCOVERY LIMIT AND OFFSET
      echo "\n\n";
      echo "";
      echo "============================ Discovery =================================\n";
      echo "";
      // application name & device name example '/antares-cse/antares-id/example/example'
      $cnt = Antares::getInstance()->get('/antares-cse/antares-id/{{applicationame}}/{{devicename}}'); // TODO: Change this to your container uri
      $first10 = $cnt->listContentInstanceUris(10);
      
      // print first10
      foreach ($first10 as $uri) {
        echo $uri . "\n";
        echo "";
      }
      echo "==============================\n";
      echo "";
      $next10 = $cnt->listContentInstanceUris(10, count($first10));
      // print next10
      foreach ($next10 as $uri) {
        echo $uri . "\n";
        echo "";
      }
      
      $inc = 1;
      echo "==============================\n";
      echo "";
      $next10 = $cnt->listContentInstanceUris(10, count($first10) * $inc++ + count($next10));
      // print next10
      foreach ($next10 as $uri) {
        echo $uri . "\n";
        echo "";
      }
    
      echo "==============================\n";
      echo "";
      $next10 = $cnt->listContentInstanceUris(10, count($first10) * $inc++ + count($next10));
      // print next10
      foreach ($next10 as $uri) {
        echo $uri . "\n";
        echo "";
      }
      
      
      echo "==============================\n";
      echo "";
      $next10 = $cnt->listContentInstanceUris(10, count($first10) * $inc++ + count($next10));
      // print next10
      foreach ($next10 as $uri) {
        echo $uri . "\n";
        echo "";
      }
    } catch (Exception $e) {
      echo($e->getMessage());
    }
  3. The next step is to open http://localhost/antares-php/example.php (according to the storage folder in htdocs) in the browser, then the following results will appear:

Store Data to Devices

  1. Open the sublime/visualcode/notepad++ application then drag the example.php and Antares.php that have been copied to the xampp htdocs.

  2. Next, use the script section in example.php and also fill in the variables according to the example below. For other lines, you can comment first

    require_once('./Antares.php');
    
    Antares::init([
      "PLATFORM_URL" => 'https://platform.antares.id:8443', // TODO: Change this to your platform URL
      "ACCESS_KEY" => '{{accesskey}}' // TODO: Change this to your access key
    ]);
    try {
      // STORE DATA
      echo "\n\n";
      echo "============================ Insert data =================================\n";
      echo "";
      try {
        // application name & device name example '/antares-cse/antares-id/example/example'
        $cnt = Antares::getInstance()->get('/antares-cse/antares-id/{{applicationame}}/{{devicename}}'); // TODO: Change this to your container uri
        $lastCin = $cnt->getLatestContentInstace();
        echo "Last CIN: [$lastCin->ct]:$lastCin->rn $lastCin->con\n";
        echo "";
      } catch (Exception $e) {
        echo "Last CIN: " . $e->getMessage() . "\n";
        echo "";
      }
      try {
        $cnt->insertContentInstance('{"help":2.0}', 'application/json');
        $lastCin = $cnt->getLatestContentInstace();
        echo "Current Last CIN: [$lastCin->ct]:$lastCin->rn $lastCin->con\n";
        echo "";
      } catch (Exception $e) {
        echo "Inserting CIN: " . $e->getMessage() . "\n";
        echo "";
      }
    } catch (Exception $e) {
      echo($e->getMessage());
    }
  3. The next step is to open http://localhost/antares-php/example.php (according to the storage folder in htdocs) in the browser, then the following results will appear:

Follow this tutorial
Follow this tutorial
clicking register now
5KB
antares-php-master.zip
archive