Mengirim Data Sederhana ke Antares
LoRaWAN Class
Prasyarat Umum STM32 (LoRa) Arduino IDE


Gambar Form berisi Parameter Set LoRa Class A. 
Gambar Form berisi Parameter Set LoRa Class C.

Gambar Halaman Console Antares Setelah berhasil Set LoRa.

Gambar Device Manager pada Windows. 
Gambar Menu Tools pada Arduino IDE 
Gambar Icon Verify dan Upload pada Arduino IDE. 
Gambar Halaman Arduino IDE Setelah Upload Berhasil. 
Gambar Icon Serial Monitor pada Arduino IDE. 
Gambar Serial Monitor

Gambar Halaman Console Antares Ketika Data Berhasil Diterima.
Prasyarat
Prasyarat Umum STM32 (LoRa) Arduino IDELangkah Kerja
1. Jalankan Aplikasi Arduino IDE
2. membuka Contoh Program
#include <lorawan.h>
//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 = 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];
char outStr[255];
byte recvStatus = 0;
int channel;
#if defined(ARDUINO_ESP32_DEV)
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
};
#elif defined(ARDUINO_B_L072Z_LRWAN1)
const sRFM_pins RFM_pins = {
.CS = PA15, //STM32L0 to NSS
.RST = PC0, //STM32L0 to RST
.DIO0 = PB4, //STM32L0 to DIO0
.DIO1 = PB1, //STM32L0 to DIO1
};
#else
#error *** ONLY SUPPORTS LYNX32 AND B-L072Z-LRWAN1 ***
#endif
void setup() {
#if defined(ARDUINO_B_L072Z_LRWAN1)
SPI.setMOSI(PA7);
SPI.setMISO(PA6);
SPI.setSCLK(PB3);
SPI.begin();
#elif !defined(ARDUINO_ESP32_DEV)
#error *** ONLY SUPPORTS LYNX32 AND B-L072Z-LRWAN1 ***
#endif
// 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);
}
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();
}
}3. Set LoRaWAN Parameter di Antares



4. Set LoRaWAN Parameter pada Kode Program

5. Compile dan Upload Program






5. Periksa Data di Antares

Last updated