Vraag

Seeeduino LoraWAN on the KPN network

  • 17 February 2017
  • 17 reacties
  • 2542 keer bekeken

I'm trying to connect a Seeeduino LoraWAN node to the KPN network via the developers portal.
Although I used the settings as given by the portal I do not see it in the portal.
Testing the uplink works, testing the downlink give an error stating no gateway detected.

Is there someone who has used this device or have suggestion?

Thanks in advance,
Jan

17 reacties

Reputatie 3
Badge
Hi Jan,

The only way we can help is when you post your settings part of the sketch.
Which sample sketch did you use, And have you configured your pins correctly for your RF module.

greetings
Bas
Hi Bas,

Here I copied the code, the LoRaWAN library (cpp and h) and I attached a screendump of the device settings as in the Portal. To complete it you will also find a phote of my test set-up.

I hope you can see what I missed.

Best regards,
Jan

This is the code:
#include
char buffer[256];
char DevAddr[] = "14204CD7";
char DevEUI[] = "0059AC0000181CD6";
char AppEUI[] = "";

char NetworkSessionKey[] = "a9cf96069897c4ecc3e01fa9cf3c2941";
char AppSessionKey[] = "5c841b73dd8bfeca2e8b7ea3a884e770";
char AppKey[] = "";

#define LoraDeviceMode LWABP // LWOTA or LWABP
#define LoraDataRate DR0
#define LoraPower 20
#define LoraPort 1
#define LoraADR 1

/*
* AT commands
*
AT?
AT+ID=?
AT+ID=DevAddr, "" // Set new DevAddr
AT+ID=DevEui, "" // Set new DevEui
AT+ID=AppEui, "" // Set new AppEui
AT+RESET
AT+MSG="Data"
AT+PORT=?
AT+PORT=1
AT+ADR=ON / ?
AT+DR=?
AT+DR=0
AT+CH=?
*/

void setup(void)
{
SerialUSB.begin(115200);
while(!SerialUSB);
SerialUSB.println("Setup started");
lora.init();
memset(buffer, 0, 256);
lora.getVersion(buffer, 256, 1);
SerialUSB.println("Version:");
SerialUSB.print(buffer);

SerialUSB.println("DevAddr:");
lora.setDevAddr(DevAddr);

SerialUSB.println("DevEUI:");
lora.setDevEUI(DevEUI);

// SerialUSB.println("AppEUI:");
// SerialUSB.println();
// lora.setAppEUI(AppEUI);

memset(buffer, 0, 256);
lora.getId(buffer, 256, 1);
SerialUSB.print(buffer);

SerialUSB.println("NwkSKey:");
lora.setNwkSKey(NetworkSessionKey);

SerialUSB.println("AppSKey:");
lora.setAppSKey(AppSessionKey);

// SerialUSB.println("AppKey:");
// lora.setAppKey(AppKey);

lora.setDeciveMode(LoraDeviceMode);
lora.setDataRate(DR0, EU868);
lora.setAdaptiveDataRate(LoraADR);

lora.setChannel(0, 868.1);
lora.setChannel(1, 868.3);
lora.setChannel(2, 868.5);

lora.setReceiceWindowFirst(0);
lora.setReceiceWindowSecond(869.5, DR3);

lora.setPower(20);

lora.setPort(LoraPort);

SerialUSB.println("Setup completed");
}

void loop(void)
{
bool result = false;

result = lora.transferPacket("Hello World!", 25);
SerialUSB.print("result is: ");
SerialUSB.println(result);

if(result)
{
short length;
short rssi;
memset(buffer, 0, 256);
length = lora.receivePacket(buffer, 256, &rssi);
if(length)
{
SerialUSB.print("Length is: ");
SerialUSB.println(length);
SerialUSB.print("RSSI is: ");
SerialUSB.println(rssi);
SerialUSB.print("Data is: ");
for(unsigned char i = 0; i < length; i ++)
{
SerialUSB.print("0x");
SerialUSB.print(buffer[i], HEX);
SerialUSB.print(" ");
}
SerialUSB.println();
}
}
delay(10000);
}

This is the serial monitor outpit:
Setup started
Version:
+VER: 2.0.10
DevAddr:
DevEUI:
+ID: DevAddr, 14:20:4C:D7
+ID: DevEui, 00:59:AC:00:00:18:1C:D6
+ID: AppEui, 70:B3:D5:7E:F0:00:35:F3
NwkSKey:
+KEY: NWKSKEY A9 CF 96 06 98 97 C4 EC C3 E0 1F A9 CF 3C 29 41
AppSKey:
+KEY: APPSKEY 5C 84 1B 73 DD 8B FE CA 2E 8B 7E A3 A8 84 E7 70
+MODE: LWABP
+DR: EU868
+DR: DR0
+DR: EU868 DR0 SF12 BW125K
+ADR: ON
+CH: 0,868100000,DR0:DR5
+CH: 1,868300000,DR0:DR5
+CH: 2,868500000,DR0:DR5
+RXWIN1: OFF; 3; 0,868100000; 1,868300000; 2,868500000;
+RXWIN2: 869500000,DR3
+POWER: 20
+PORT: 1
Setup completed
+MSG: Start
+MSG: TX "Hello World!"
+MSG: Done
result is: 1

LoRaWan.cpp:
/*
LoRaWAN.cpp
2013 Copyright (c) Seeed Technology Inc. All right reserved.

Author: Wayne Weng
Date: 2016-10-17

add rgb backlight fucnction @ 2013-10-15

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.1 USA
*/

#include "LoRaWan.h"


LoRaWanClass::LoRaWanClass(void)
{
memset(_buffer, 0, 256);
}

void LoRaWanClass::init(void)
{
SerialLoRa.begin(9600);
}

void LoRaWanClass::getVersion(char *buffer, short length, unsigned char timeout)
{
if(buffer)
{
while(SerialLoRa.available())SerialLoRa.read();
sendCommand("AT+VER=?\r\n");
readBuffer(buffer, length, timeout);
}
}

void LoRaWanClass::getId(char *buffer, short length, unsigned char timeout)
{
if(buffer)
{
while(SerialLoRa.available())SerialLoRa.read();
sendCommand("AT+ID=?\r\n");
readBuffer(buffer, length, timeout);
}
}

void LoRaWanClass::setId(char *DevAddr, char *DevEUI, char *AppEUI)
{
char cmd[64];

if(DevAddr)
{
memset(cmd, 0, 64);
sprintf(cmd, "AT+ID=DevAddr,\"%s\"\r\n", DevAddr);
sendCommand(cmd);
delay(DEFAULT_TIMEWAIT);
}

if(DevEUI)
{
memset(cmd, 0, 64);
sprintf(cmd, "AT+ID=DevEui,\"%s\"\r\n", DevEUI);
sendCommand(cmd);
delay(DEFAULT_TIMEWAIT);
}

if(AppEUI)
{
memset(cmd, 0, 64);
sprintf(cmd, "AT+ID=AppEui,\"%s\"\r\n", AppEUI);
sendCommand(cmd);
delay(DEFAULT_TIMEWAIT);
}
}

void LoRaWanClass::setDevAddr(char *DevAddr)
{
char cmd[64];

if(DevAddr)
{
memset(cmd, 0, 64);
sprintf(cmd, "AT+ID=DevAddr,\"%s\"\r\n", DevAddr);
sendCommand(cmd);
delay(DEFAULT_TIMEWAIT);
}
}

void LoRaWanClass::setDevEUI(char *DevEUI)
{
char cmd[64];

if(DevEUI)
{
memset(cmd, 0, 64);
sprintf(cmd, "AT+ID=DevEui,\"%s\"\r\n", DevEUI);
sendCommand(cmd);
delay(DEFAULT_TIMEWAIT);
}

}

void LoRaWanClass::setAppEUI(char *AppEUI)
{
char cmd[64];

if(AppEUI)
{
memset(cmd, 0, 64);
sprintf(cmd, "AT+ID=AppEui,\"%s\"\r\n", AppEUI);
sendCommand(cmd);
delay(DEFAULT_TIMEWAIT);
}
}

void LoRaWanClass::setKey(char *NwkSKey, char *AppSKey, char *AppKey)
{
char cmd[64];

if(NwkSKey)
{
memset(cmd, 0, 64);
sprintf(cmd, "AT+KEY=NWKSKEY,\"%s\"\r\n", NwkSKey);
sendCommand(cmd);
#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);
}

if(AppSKey)
{
memset(cmd, 0, 64);
sprintf(cmd, "AT+KEY=APPSKEY,\"%s\"\r\n", AppSKey);
sendCommand(cmd);

#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);
}

if(AppKey)
{
memset(cmd, 0, 64);
sprintf(cmd, "AT+KEY= APPKEY,\"%s\"\r\n", AppKey);
sendCommand(cmd);
#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);
}
}

void LoRaWanClass::setNwkSKey(char *NwkSKey)
{
char cmd[64];

if(NwkSKey)
{
memset(cmd, 0, 64);
sprintf(cmd, "AT+KEY=NWKSKEY,\"%s\"\r\n", NwkSKey);
sendCommand(cmd);
#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);
}

}

void LoRaWanClass::setAppSKey(char *AppSKey)
{
char cmd[64];

if(AppSKey)
{
memset(cmd, 0, 64);
sprintf(cmd, "AT+KEY=APPSKEY,\"%s\"\r\n", AppSKey);
sendCommand(cmd);

#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);
}

}

void LoRaWanClass::setAppKey(char *AppKey)
{
char cmd[64];

if(AppKey)
{
memset(cmd, 0, 64);
sprintf(cmd, "AT+KEY= APPKEY,\"%s\"\r\n", AppKey);
sendCommand(cmd);
#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);
}
}

void LoRaWanClass::setDataRate(_data_rate_t dataRate, _physical_type_t physicalType)
{
char cmd[32];

if(physicalType == EU434)sendCommand("AT+DR=EU433\r\n");
else if(physicalType == EU868)sendCommand("AT+DR=EU868\r\n");
else if(physicalType == US915)sendCommand("AT+DR=US915\r\n");
else if(physicalType == AU920)sendCommand("AT+DR=AU920\r\n");
#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);

memset(cmd, 0, 32);
sprintf(cmd, "AT+DR=%d\r\n", dataRate);
sendCommand(cmd);
#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);
}

void LoRaWanClass::setPower(short power)
{
char cmd[32];

memset(cmd, 0, 32);
sprintf(cmd, "AT+POWER=%d\r\n", power);
sendCommand(cmd);
#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);
}

void LoRaWanClass::setPort(unsigned char port)
{
char cmd[32];

memset(cmd, 0, 32);
sprintf(cmd, "AT+PORT=%d\r\n", port);
sendCommand(cmd);
#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);
}

void LoRaWanClass::setAdaptiveDataRate(bool command)
{
if(command)sendCommand("AT+ADR=ON\r\n");
else sendCommand("AT+ADR=OFF\r\n");
#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);
}

void LoRaWanClass::setChannel(unsigned char channel, float frequency)
{
char cmd[32];

if(channel > 16) channel = 16;

memset(cmd, 0, 32);
sprintf(cmd, "AT+CH=%d,%d.%d\r\n", channel, (short)frequency, short(frequency * 10) % 10);
sendCommand(cmd);
#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);
}

void LoRaWanClass::setChannel(unsigned char channel, float frequency, _data_rate_t dataRata)
{
char cmd[32];

if(channel > 16) channel = 16;

memset(cmd, 0, 32);
sprintf(cmd, "AT+CH=%d,%d.%d,%d\r\n", channel, (short)frequency, short(frequency * 10) % 10, dataRata);
sendCommand(cmd);
#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);
}

void LoRaWanClass::setChannel(unsigned char channel, float frequency, _data_rate_t dataRataMin, _data_rate_t dataRataMax)
{
char cmd[32];

if(channel > 16) channel = 16;

memset(cmd, 0, 32);
sprintf(cmd, "AT+CH=%d,%d.%d,%d,%d\r\n", channel, (short)frequency, short(frequency * 10) % 10, dataRataMin, dataRataMax);
sendCommand(cmd);
#if _DEBUG_SERIAL_
loraDebugPrint(DEFAULT_DEBUGTIME);
#endif
delay(DEFAULT_TIMEWAIT);
}

bool LoRaWanClass::transferPacket(char *buffer, unsigned char timeout)
{
unsigned char length = strlen(buffer);

while(SerialLoRa.available())SerialLoRa.read();

sendCommand("AT+MSG=\"");
for(unsigned char i = 0; i < length; i ++)SerialLoRa.write(buffer[i]);
sendCommand("\"\r\n");

memset(_buffer, 0, BEFFER_LENGTH_MAX);
readBuffer(_buffer, BEFFER_LENGTH_MAX, timeout);
#if _DEBUG_SERIAL_
SerialUSB.print(_buffer);
#endif
if(strstr(_buffer, "+MSG: Done"))return true;
return false;
}

bool LoRaWanClass::transferPacket(unsigned char *buffer, unsigned char length, unsigned char timeout)
{
char temp[2] = {0};

while(SerialLoRa.available())SerialLoRa.read();

sendCommand("AT+MSGHEX=\"");
for(unsigned char i = 0; i < length; i ++)
{
sprintf(temp,"%02x", buffer[i]);
SerialLoRa.write(temp);
}
sendCommand("\"\r\n");

memset(_buffer, 0, BEFFER_LENGTH_MAX);
readBuffer(_buffer, BEFFER_LENGTH_MAX, timeout);
#if _DEBUG_SERIAL_
SerialUSB.print(_buffer);
#endif
if(strstr(_buffer, "+MSGHEX: Done"))return true;
return false;
}

bool LoRaWanClass::transferPacketWithConfirmed(char *buffer, unsigned char timeout)
{
unsigned char length = strlen(buffer);

while(SerialLoRa.available())SerialLoRa.read();

sendCommand("AT+CMSG=\"");
for(unsigned char i = 0; i < length; i ++)SerialLoRa.write(buffer[i]);
sendCommand("\"\r\n");

memset(_buffer, 0, BEFFER_LENGTH_MAX);
readBuffer(_buffer, BEFFER_LENGTH_MAX, timeout);
#if _DEBUG_SERIAL_
SerialUSB.print(_buffer);
#endif
if(strstr(_buffer, "+CMSG: ACK Received"))return true;
return false;
}

bool LoRaWanClass::transferPacketWithConfirmed(unsigned char *buffer, unsigned char length, unsigned char timeout)
{
char temp[2] = {0};

while(SerialLoRa.available())SerialLoRa.read();

sendCommand("AT+CMSGHEX=\"");
for(unsigned char i = 0; i < length; i ++)
{
sprintf(temp,"%02x", buffer[i]);
SerialLoRa.write(temp);
}
sendCommand("\"\r\n");
#if _DEBUG_SERIAL_
SerialUSB.print(_buffer);
#endif
memset(_buffer, 0, BEFFER_LENGTH_MAX);
readBuffer(_buffer, BEFFER_LENGTH_MAX, timeout);

if(strstr(_buffer, "+CMSGHEX: ACK Received"))return true;
return false;
}

short LoRaWanClass::receivePacket(char *buffer, short length, short *rssi)
{
char *ptr;
short number = 0;

ptr = strstr(_buffer, "RSSI ");
if(ptr)*rssi = atoi(ptr + 5);
else *rssi = -255;

ptr = strstr(_buffer, "RX: \"");
if(ptr)
{
ptr += 5;
for(short i = 0; ; i ++)
{
char temp[2] = {0};
unsigned char tmp, result = 0;

temp[0] = *(ptr + i * 3);
temp[1] = *(ptr + i * 3 + 1);

for(unsigned char j = 0; j < 2; j ++)
{
if((temp[j] >= '0') && (temp[j] = 'A') && (temp[j] = 'a') && (temp[j]
Hi bas,

I see that not all of the cpp has been copied in.

Do you need it?
Reputatie 3
Badge
Hi Jan,

Did you tried it with the keys in Hex format? Like 0x..
Hi Bas,
according to the manual the only way is via the Hex chars:

Change LoRaWAN related AES-128 KEY. If wrong key is used, your LoRaWAN modem will be rejected
by LoRaWAN server. Contact server administrator to know what key should use. All KEYs are
unreadable for security, the one who forgets his KEY need rewrite with a new key.
Format:
Change network session key (NWKSKEY)
AT+KEY=NWKSKEY, “16 bytes length key”
eg: AT+KEY=NWKSKEY, "2B7E151628AED2A6ABF7158809CF4F3C"
eg: AT+KEY=NWKSKEY, "2B 7E 15 16 28 AE D2 A6 AB F7 15 88 09 CF 4F 3C"
Return:
+KEY: NWKSKEY 2B 7E 15 16 28 AE D2 A6 AB F7 15 88 09 CF 4F 3C
Change application session key (APPSKEY)
AT+KEY=APPSKEY, “16 bytes length key”
eg: AT+KEY=APPSKEY, "2B7E151628AED2A6ABF7158809CF4F3C"
eg: AT+KEY= APPSKEY, "2B 7E 15 16 28 AE D2 A6 AB F7 15 88 09 CF 4F 3C"
Return:
+KEY: APPSKEY 2B 7E 15 16 28 AE D2 A6 AB F7 15 88 09 CF 4F 3C

and:

Use to check the ID of the LoRaWAN module, or change the ID.
Read ID Format:
AT+ID // Read all, DevAddr(ABP), DevEui(OTAA), AppEui(OTAA)
AT+ID? // Read all
AT+ID=? // Read all
AT+ID=DevAddr // Read DevAddr
AT+ID=DevEui // Read DevEui
AT+ID=AppEui // Read AppEui
AT+ID=DevAddr, "new devaddr" // Set new DevAddr
AT+ID=DevEui, "new deveui" // Set new DevEui
AT+ID=AppEui, "new appeui" // Set new AppEui
Return:
+ID: DevAddr, xx:xx:xx:xx
+ID: DevEui4, xx:xx:xx:xx:xx:xx:xx:xx
+ID: AppEui5, xx:xx:xx:xx:xx:xx:xx:xx
Change end device address (DEVADDR)
AT+ID=DevAddr, “4 bytes length hex identifier”
eg: AT+ID=DevAddr, "01234567"
eg: AT+ID=DEVADDR, "01 23 45 67"
Return:
+ID: DevAddr, 01:23:45:67
Change device extended unique identifier (DEVEUI)
AT+ID= DevEui, “8 bytes length hex identifier (64bit)”
eg: AT+ID=DevEui, "0123456789ABCDEF"
eg: AT+ID=DEVEUI, "01 23 45 67 89 AB CD EF"
Return:
+ID: DevEui, 01:23:45:67:89:AB:CD:EF
Reputatie 3
Badge
For ABP you only need 3 keys. Try to remove the Dev EUI.
With the device address and appskey and netskey is should work.
Also on the place where you define your datapacket with "Hello World!" I see ,25. I think this is the packet length. I count twelve.
DevEUI removed, reset to factory defaults and dtatapacket lenght adapted.

Unfortunately not seen by the network.
I'm lost.....
Reputatie 3
Badge
What antenna are you using? Do you have reception?
I'm using an 868Mc antenna (see photo).

From the LoraWAN specification I understood that it only receives data after a transmit and that the the device has to be recognised by a basestation to enable a downlink message.
Or is there an other way to see if it receives messages?

Rgds,
Jan
Reputatie 3
Badge
Hello Jan,

When we test "new" hardware we are using our own private gateway. On this gateway we can see if the node is correctly configured. If it works we change the keys for other networks (KPN, TTN).

Downlink messages are indeed send shortly after there was an uplink. I think that the reason for this is that the network knows from what gateway to send the message. Otherwise your message will be sent from the entire network (entire country)

Have you tested your node outside?

gr
Bas
Hi Bas,

I tested it upstairs. I have a house that is mainly made of wood, with some brick walls so I expected it to work.


I did run a test outside (see photo) but the device is still not seen.
I see the LED of the RF module blink when transmitting.
Reputatie 3
Badge
Did you managed to get it up and running in the meantime?
Hi Bas,

unfortunately not.
I contacted both Seedstudio and RisingRF and got some support, but it seems to me that the module is not transmitting.
As an alternative I used a Raspberry Pi with an Draguino hat to set up a TTN gateway (packetforwarder) and here I see an othe LoraWAN device sending but from my device I do not see anything.
So I have a kind of a test environment and my next step will be to see if I can detect RF transmissions by uing a kind of Grid Dipper.
I didn't anticipate to need so much time in setting up a LoraWAN evaluation.
Hello @jawove,

I bought a seeeduino LoRaWan, and got it running with the developer portal.

Please note that it can take some minutes for the message to appear in the kpn lora developer portal.

The code is in this pastebin: https://pastebin.com/WFcCKfCG
Or below:
```
#include \LoRaWan.h/

unsigned char data[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA,};
char buffer[256];

char DevEUI[] = "XX XX XX XX XX XX XX XX";
char DevAddr[] = "XX XX XX XX";
char AppEUI[] = "";

char NetworkSessionKey[] = "XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX";
char AppSessionKey[] = "XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX";
char AppKey[] = "XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX";

void setup(void)
{
SerialUSB.begin(115200);
while(!SerialUSB);

lora.init();

memset(buffer, 0, 256);
lora.getVersion(buffer, 256, 1);
SerialUSB.print(buffer);

memset(buffer, 0, 256);
lora.getId(buffer, 256, 1);
SerialUSB.print(buffer);

lora.setKey(NetworkSessionKey, AppSessionKey, AppKey);

lora.setId(DevAddr,DevEUI, AppEUI);

lora.setDeciveMode(LWABP);
lora.setDataRate(DR0, EU868);
lora.setAdaptiveDataRate(1);

lora.setChannel(0, 868.1);
lora.setChannel(1, 868.3);
lora.setChannel(2, 868.5);

lora.setReceiceWindowFirst(0);
lora.setReceiceWindowSecond(869.5, DR3);

lora.setPower(20);

lora.setPort(1);

SerialUSB.println("Setup completed");
}

void loop(void)
{
bool result = false;

result = lora.transferPacket("Hello World!", 12);

if(result)
{
short length;
short rssi;

memset(buffer, 0, 256);
length = lora.receivePacket(buffer, 256, &rssi);

if(length)
{
SerialUSB.print("Length is: ");
SerialUSB.println(length);
SerialUSB.print("RSSI is: ");
SerialUSB.println(rssi);
SerialUSB.print("Data is: ");
for(unsigned char i = 0; i < length; i ++)
{
SerialUSB.print("0x");
SerialUSB.print(buffer[i], HEX);
SerialUSB.print(" ");
}
SerialUSB.println();
}
}
delay(100000);
}
```
Reputatie 7
Badge +6
Hi @szijlmans,

Welcome to our LoRa Forum! :D
I want to thank you for sharing your code. I think Bas and a lot of other users can use this code as an example. If you have other tips and tricks, please feel free to share them on this forum.

And @jawove, it's been a while that you had the problem with connecting a Seeeduino LoraWAN node to the KPN network. I am wondering if you have made any progress?
Hi Rick,

Yes, I succeeded in setting up this device. For me the code as provided which szijlmans did not work and it took me a lot of effort to find out why.
These were my findings:
- the documentation provided for the radiopart was different from the firmware version in it, but the guys from RHF did sent a newer version (3.1) just to find out that there is a setting for private and public networks.
Unfortunately the libraries didn't include these so I had to modify the libraries and add a new command to set this 'network bit'.
After this I was able to set this network bit and now it works perfectly and reliable with the KPN network.

I must admit that the KPN LoraWAN coverage is very good in comparison with TTN or Sigfox, last weekend I even had coverage in a very rural environment.
Next step will be sending data downlink.
Best regards,
Jan
Reputatie 7
Badge +6
Hi jawove,

Great to hear to you succeeded in setting up the device. :D
It was a bumpy road, but fortunately it worked out.

I want to thank you for sharing your findings. I'm certain that a lot of other users can use these findings for their own LoRa devices.

In addition, I am also very pleased to hear that the coverage is so good. If i can help you with anything else, you now know where to find me 😉

Reageer