lorawan module: White Screen after lora.setDeviceMode(LWOTAA)
-
I try to use the lorawan module. The device starts but crashes (and start again) when trying to set device mode to OTAA.
Can anybody help?
Here's the code
--- cut ---
#include <M5Stack.h>
#include "LoRaWan.h"//LoRa
char buffer[256];
long sentMillis = 0;
long currentMillis = 0;
long interval = 15000;
//byte payload[2];void setup() {
/* Prepare M5STACK */
M5.begin();initlora();
M5.Lcd.println("Started");
}void loop() {
currentMillis = millis();
if (currentMillis - sentMillis > interval) {
sendobject();
}M5.update();
}void initlora() {
lora.init();
delay(1000);
memset(buffer, 0, 256);
lora.getVersion(buffer, 256, 1);
Serial.print(buffer);memset(buffer, 0, 256);
lora.getId(buffer, 256, 1);
Serial.print(buffer);lora.setId(NULL, "aaa", "bbb");
lora.setKey(NULL, NULL, "ccc");M5.Lcd.println("setDeviceMode");
lora.setDeviceMode(LWOTAA);
M5.Lcd.println("setDataRate");
lora.setDataRate(DR5, EU868);lora.setChannel(0, 868.1);
lora.setChannel(1, 868.3);
lora.setChannel(2, 868.5);
lora.setChannel(3, 867.1);
lora.setChannel(4, 867.3);
lora.setChannel(5, 867.5);
lora.setChannel(6, 867.7);
lora.setChannel(7, 867.9);lora.setReceiveWindowFirst(0, 868.1);
lora.setReceiveWindowSecond(869.525, DR3);lora.setPower(14);
lora.setPort(1);
lora.setAdaptiveDataRate(true);
//lora.setDutyCycle(false);
//lora.setJoinDutyCycle(false);
while (!lora.setOTAAJoin(JOIN, 10));
}void sendobject() {
bool result = false;sentMillis = millis();
M5.Lcd.println("Sending");
result = lora.transferPacket("Hello World!", 5);
//result = lora.transferPacket(payload, sizeof(payload), 5);if (result == true) {
M5.Lcd.println("Sent");} else {
M5.Lcd.println("Error");
}
}
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login