I am following basic tutorial to connect an end device to the things network via gateway but I have problems connecting to the things network.
The basic Arduino sketch which runs on the Arduino MKR 1310 board seems to be not able to connect to the network.
I have a Raspberry Pi HaT from Dragino which is connected to the network. I can see it online on the ttn server but the end node does not connect.
I have created an end application and registered a device there. I have kept all ‘00’ for the Appeui part and registered a device manually on TTN.
When I try with following code, the device is not connecting. Any suggestion will be helpful as a new to lorawan and TTN network
int connected = modem.joinOTAA(appeui, appkey);
if(!connected) {
Serial.println(“Something went wrong, you are not connected”);
}
Forum search will show that some libs/implementations have a problem with this - try all zero’s ending in 1 or use a generator (search again) to create a valid code number that doesnt tread on other peoples number.
Which firmware/lib for the MKR 1301 (family isnt the best for a learner to start with acording to some…)
/*
Send and receive data from a LoRaWAN network
This sketch demonstrates how to send and receive data with the MKR WAN 1300/1310 board.
This example code is in the public domain.
*/
#include <MKRWAN.h>
#include "arduino_secrets.h"
String appeui = APP_EUI;
String appkey = APP_KEY;
LoRaModem modem;
void setup() {
Serial.begin(9600);
while(!Serial);
if(!modem.begin(IN865)){
Serial.println("Could not start the device");
}
Serial.print("Your module version is ");
Serial.println(modem.version());
Serial.print("Your device EUI is ");
Serial.println(modem.deviceEUI());
int connected = modem.joinOTAA(appeui, appkey);
if(!connected) {
Serial.println("Something went wrong, you are not connected");
}
modem.minPollInterval(60);
}
void loop() {
Serial.println();
String msg = "Starting LoRa";
Serial.println();
int err;
modem.beginPacket();
modem.print(msg);
err = modem.endPacket(true);
if(err > 0){
Serial.println("Message sent correctly!");
}
else
{
Serial.println("Error sending message");
}
Serial.println();
delay(10000);
}
Though, I have to say that I registered the end device manually and could be that I might selected some wrong value for firmware version and other stuff but it should work btw.
As you will no doubt be aware from following the tutorial to create the gateway, you have a Single Channel Packet Forwarder which is disruptive to the network and are not suitable or welcome for connection to TTN.
And that is the reason your MKR WAN won’t / can’t / could one day connect - it is using 8 channels and you have only one.
Please disconnect it immediately. You can read more here:
Okay, thanks for your quick response.
I have disconnected the Gateway and the node. So my journey to LoRa world will stop for the moment. It stopped some years ago when I started. Because there is also not a gateway around me where I can connect.
I will see if I can do something out of this expensive HaT, which took a lot of time for me for learning and configuration and end up being a full stop journey.
I’d expect the MKR WAN to cost far more than the Dragino HAT.
You can still use them to talk to each other offline from a LoRaWAN network with the correct libraries, but that is off-topic for this TTI funded forum.