Quantcast
Channel: The Things Network - Latest posts
Viewing all articles
Browse latest Browse all 115657

LoRaWAN shield for Arduino UNO?

$
0
0

Hey @veldman it seems I got the LoRa-LMIC-1.51 working now. However it feels a bit as a shady solution. I explain the steps I took to make it work.

I compared the Arduino program of the LoRa-LMIC-1.51 with the Aruino program of the arduino-lmic-v1.5, which was already working for me. First of all re-downloaded and re-installed the LoRa-LMIC-1.51 library. I again added the device Addres:

unsigned char DevAddr[4] = { 0x02, 0xD1, 0xE5, 0x20 };

Changed the pin settings to be the same as the default settings of the lmic-v1.5 code.

lmic_pinmap pins = {
.nss = 10, // Connected to pin D10
.rxtx = 7, // For placeholder only, Do not connected on RFM92/RFM95
.rst = 9, // Needed on RFM92/RFM95? (probably not)
.dio = {2, 5, 6}, // Specify pin numbers for DIO0, 1, 2
// connected to D2, D5, D6
};

To be sure I soldered a wire from reset on the Dragino shield. Consequently I wired the wire from reset to the digital pin 9 of the Arduino (Mega).

I tried the code like this but still no packages on the TTN API. As the gateway I have seemed to receive the packages and could forward them, I thought perhaps the device address (DevAddr/DEVADDR) was not transmitted correctly. Thus I compared the two codes on this particular part. I copied the style of the lmic-v1.5 to the LMIC-v1.51 code and added the following line of code:

unsigned char DevAddr[4] = { 0x02, 0xD1, 0xE5, 0x20 };
static const u4_t DEVADDR = 0x02D1E520;

Then changed the following line:

LMIC_setSession (0x1, msbf4_read(DevAddr), (uint8_t*)NwkSkey, (uint8_t*)AppSkey);

To:

LMIC_setSession (0x1, DEVADDR, (uint8_t*)NwkSkey, (uint8_t*)AppSkey);

Tried the code again and it worked! I can now see data in the TTN API. Furthermore I tried to figure out why this worked, so I added some debug lines in the setup:

Serial.print("LMIC 1.51 DevAddr: ");
Serial.println(msbf4_read(DevAddr), HEX);
Serial.print("LMIC 1.5 DEVADDR: ");
Serial.println(DEVADDR, HEX);

Result:

IC 1.51 DevAddr: FFFFE520
lmic-v1.5 DEVADDR: 2D1E520

As you can see the msbf4_read() function doesn't seem to work properly (for me). Perhaps @platenspeler could explain what is going on? Furthermore @niels, did you change this part as well to get your code working?

As I said before this seems as a bit of shady solution but it works for now. Hopefully platenspeler or niels can elaborate on this.


Viewing all articles
Browse latest Browse all 115657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>