-
Notifications
You must be signed in to change notification settings - Fork 12
/
LoRaWAN-Message.ino
52 lines (39 loc) · 1.21 KB
/
LoRaWAN-Message.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <MKRWAN.h>
#include "arduino_secrets.h"
LoRaModem modem;
void setup() {
Serial.begin(115200);
while (!Serial);
// change this to your regional band (eg. US915, AS923, ...)
if (!modem.begin(EU868)) {
Serial.println("Failed to start module");
while (1) {}
};
Serial.print("Your module version is: ");
Serial.println(modem.version());
if (modem.version() != ARDUINO_FW_VERSION) {
Serial.println("Please make sure that the latest modem firmware is installed.");
Serial.println("To update the firmware upload the 'MKRWANFWUpdate_standalone.ino' sketch.");
}
Serial.print("Your device EUI is: ");
Serial.println(modem.deviceEUI());
Serial.println("Connecting...");
int connected = modem.joinOTAA(APP_EUI, APP_KEY);
if (!connected) {
Serial.println("Something went wrong; are you indoor? Move near a window and retry");
while (1) {}
}
delay(5000);
Serial.println("Sending message...");
modem.setPort(3);
modem.beginPacket();
modem.print("HeLoRA world!");
int error = modem.endPacket(true);
if (error > 0) {
Serial.println("Message sent correctly!");
} else {
Serial.println("Error sending message :(");
}
}
void loop() {
}