Connecting LORA-WAN to LoPy (Please Help)


We are having trouble connecting our node (LoPy) to the gateway (Raspberry Pi + Dragino Hat). Our gateway is connected and being seen on the things network, but our node is never seen (but there is a green indicator).

We were able to send a message to the gateway ONE time and our node was finally being seen, but we’re having difficulty duplicating how we were able to get a message.

We set up our node and gateway exactly in the links below (we are located in the US):

GateWay (Dragino Hat and raspberry pi 3):

Node (LoPy 1):

Any help is appreciated.

Do you have the code you used on your LoPy? It sounds like the single channel setting hasn’t been setup correctly.

The Raspberry Pi single channel code - - is no longer supported for The Things Network.

That configuration definitely does not support OTAA because it doesn’t support downlinks.

from network import LoRa 
import struct 
import binascii 
import socket 
freq = 902300000

# Initialize LoRa in LORAWAN mode. 
lora = LoRa(mode=LoRa.LORAWAN)

#Setup the single channel for connection to the gateway 
for channel in range(0, 72): 
for chan in range(0, 8): 
   lora.add_channel(chan,  frequency=freq,  dr_min=0,  dr_max=3) 

#Device Address 
dev_addr = struct.unpack(">l", binascii.unhexlify('2602122D'))[0] 
#Network Session Key 
nwk_swkey = binascii.unhexlify('XXXX') 
#App Session Key 
app_swkey = binascii.unhexlify('XXXX') 

lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey)) 

# create a LoRa socket 
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) 

# set the LoRaWAN data rate 
s.setsockopt(socket.SOL_LORA, socket.SO_DR, 3) 

# make the socket non-blocking 

Taken straight from the “LoPy to Single Channel Gateway” tutorial.

Just a tip, I’d remove the nwk and app key from the post as they’re meant to be kept secret :wink:

Where do you get the freq being 902300000 from? From what I can see US Single channel gateways should be on 903900000

1 Like

Honestly, that was just straight from the code as well. Can you share where you read that frequency should be 903900000? I will try setting this within the code, but just wanted to understand/read up more on this.

And thanks for the tip, went back and removed the keys.

It was in LoPy’s documentation for single channel gateways.

It’ll depend on the frequency of your raspberry pi gateway setting. Do you have a screenshot of the log from it?

I was using a Pi and a Dragino as my first gateway and found that only certain packets got through. However, the pi gateway showed a log message when it received a packet and forwarded it to the Lorawan network.

I think you can set the Pycom to use US frequencies by specifying the region. .e.g mine was specified as follows:
lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.EU868)

I don’t know if you have only sent through part of your program, but mine concludes with …

# make the socket blocking
# (waits for the data to be sent and for the 2 receive windows to expire)
# send some data
s.send(bytes([0x01, 0x02, 0x03]))

It’s only when the socket send method is called, does anything actually happen on the network.