My 1310 board will talk via the LoRA connection when it is connected via the USB to the IDE. However, when tryin to use it standalone - powered via teh USB connection but just from a charger, teh system does not appear to talk. I have commented out all use of the serial connection in the sketch and that has not seemed to make a difference. Is there something I am missing in using the 1310 outside of the IDE environment? The code started from the example LoRASendAndRecieve and was modified to send a message every 50 seconds without having to use the serial input to input the string to send and use only specific channels.
Code Below
#include <MKRWAN.h>
LoRaModem modem;
void setup() {
int status;
//Serial.begin(9600);
//while (!Serial);
delay(2000);
loraSetup();
// if(Serial) Serial.println("--------------------------------");
// if(Serial) Serial.println("- MKR WAN 1310 Channel Masking -");
// if(Serial) Serial.println("--------------------------------");
// Print default channels configuration
// if(Serial) Serial.print("- Default mask: ");
// if(Serial) Serial.println(modem.getChannelMask());
// Disable all channels
// if(Serial) Serial.println("- Disabling all channels...");
for (unsigned int i = 0; i < 72; i++) {
modem.disableChannel(i);
}
// Print current channels configuration
// if(Serial) Serial.print("- Current mask: ");
// if(Serial) Serial.println(modem.getChannelMask());
// Enable US915-928 channels
// LoRaWAN® Regional Parameters and TTN specification: channels 8 to 15 plus 65
modem.sendMask("ff000001f000ffff00020000");
// if(Serial) Serial.println(modem.getChannelMask());
modem.setADR(true);
// if(Serial) Serial.print("- Current mask: ");
// if(Serial) Serial.println(modem.getChannelMask());
// if(Serial) Serial.print("Your module version is: ");
// if(Serial) Serial.println(modem.version());
// if(Serial) Serial.print("Latest module version is: ");
// if(Serial) Serial.println(ARDUINO_FW_VERSION);
if (modem.version() != ARDUINO_FW_VERSION) {
// if(Serial) Serial.println("Please make sure that the latest modem firmware is installed.");
// if(Serial) Serial.println("To update the firmware upload the 'MKRWANFWUpdate_standalone.ino' sketch.");
}
// if(Serial) Serial.print("Your device EUI is: ");
// if(Serial) Serial.println(modem.deviceEUI());
// if(Serial) Serial.println("Connecting...");
int connected = modem.joinOTAA(SECRET_APP_EUI, SECRET_APP_KEY);
if (!connected) {
// if(Serial) Serial.println("Something went wrong; are you indoor? Move near a window and retry");
}
// delay(5000);
}
void loop() {
delay(50000);
String msg = String(millis(),DEC);
// if(Serial) Serial.println();
// if(Serial) Serial.print("Sending: " + msg + " - ");
for (unsigned int i = 0; i < msg.length(); i++) {
// if(Serial) Serial.print(msg[i] >> 4, HEX);
// if(Serial) Serial.print(msg[i] & 0xF, HEX);
// if(Serial) Serial.print(" ");
}
// if(Serial) Serial.println();
int err;
modem.beginPacket();
modem.print(msg);
err = modem.endPacket(true);
if (err > 0) {
// if(Serial) Serial.println("Message sent correctly!");
} else {
// if(Serial) Serial.println("Error sending message :(");
// if(Serial) Serial.println("(you may send a limited amount of messages per minute, depending on the signal strength");
// if(Serial) Serial.println("it may vary from 1 message every couple of seconds to 1 message every minute)");
}
delay(1000);
if (!modem.available()) {
// if(Serial) Serial.println("No downlink message received at this time.");
return;
}
char rcv[64];
int i = 0;
while (modem.available()) {
rcv[i++] = (char)modem.read();
}
// if(Serial) Serial.print("Received: ");
for (unsigned int j = 0; j < i; j++) {
// if(Serial) Serial.print(rcv[j] >> 4, HEX);
// if(Serial) Serial.print(rcv[j] & 0xF, HEX);
// if(Serial) Serial.print(" ");
}
// if(Serial) Serial.println();
}
void loraSetup() {
// Initialize LoRa module with the US915-928 region parameters
if (!modem.begin(US915)) {
// if(Serial) Serial.println("- Failed to start LoRa module!");
while (1);
};
delay(5000);
// Set poll interval to 30 seconds
modem.minPollInterval(60);
}