Issue with LORA-WAN and Loriot LNS (Multitech gateway)



  • Hi everyone I'm here seeking for some help...

    I've been working in a function that connects with a Multitech Lora Gateway and publishes data to Lora LNS using ABP security.

    The function does work, but there is an issue that I couldn't solve yet... When it publishes to the LNS, sometimes the data arrives but sometimes not.

    Here is the LNS log:
    0_1537471665779_LOG_LORIOT.PNG

    There you can see how sometimes the data is published every 5 seconds without any problem, but sometimes there are many lost packets between messages... Something that makes difficult to diagnose the cause is that the ammount of lost packets isn't constant, even when nothing is beeing changed in hardware or software between the publications. (You can see the ammount of lost packets in the number that appears at the right of every "lost_frames" message)

    Here is the code:

    import binascii
    import socket
    import struct
    from time import sleep
    from network import LoRa
    
    lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.US915)
    
    dev_addr = struct.unpack(">l", binascii.unhexlify('00000000'))[0]
    nwk_swkey = binascii.unhexlify('00000000000000000000000000000000')
    app_swkey = binascii.unhexlify('00000000000000000000000000000000')
    
    lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey))
    
    while not lora.has_joined():
        print("Please wait...")
    
    print("Ready to publish data...")
    
    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    s.setsockopt(socket.SOL_LORA, socket.SO_DR, 3)
    
    data = [1,2,3]
    
    while 1:
        s.setblocking(True)
        s.send(bytes(data))
        s.setblocking(False)
        data = s.recv(64)
        sleep(5)
    

    I'm working with LOPY4 and FIPY but the problem is the same in both of them.

    If somebody could give me some help in order to solve this, I would appreciate it.



  • @shp96 That does not seem correct. Your gateway is only listening on channels 48 to 55 and 70...

    Can you show logs of packets received with the associated channel?



  • @jcaron I reduced the los packets to a null ammount by enabling the channels from 0 to 64.

    Thank you so much for your help!

    Here is the code that works without any issue, pubishing every 5 seconds:

    from network import LoRa
    
    lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.US915)
    
    for i in range(0,72):
        lora.remove_channel(i)
    
    for i in range(0,64):
        lora.add_channel(i, frequency=(902300000+(200*i)), dr_min=0, dr_max=3)
    
    import struct
    import binascii
    dev_addr = struct.unpack(">l", binascii.unhexlify('00000000'))[0]
    nwk_swkey = binascii.unhexlify('00000000000000000000000000000000')
    app_swkey = binascii.unhexlify('00000000000000000000000000000000')
    
    lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey))
    
    import socket
    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    s.setsockopt(socket.SOL_LORA, socket.SO_DR, 3)
    
    from time import sleep
    data = [0]
    
    while 1:
        s.setblocking(True)
        s.send(bytes(data))
        s.setblocking(False)
        s.recv(64)
        data[0] = data[0] + 1
        if data[0] > 255:
            data[0] = 0
        print(data)
        sleep(5)
    


  • @shp96 Radio frequencies are shared, so there's always noise from other users of the band, or even collisions with other LoRa frames, so it's quite normal you will be losing packets here and there.

    Actually, if you have many devices, collisions can very quickly cause quite a bit of packet loss.

    The US band has quite a few channels, so you're less likely to encounter the issue, but on the EU channels if LoRa becomes a bit successful collisions will quickly become an issue.



  • @jcaron

    I configured the device to use channels from 48 to 63 with (902 300 000 + 200 * channel) frequencies, 0-3 as data rate range, and the issue became solved. The device has been 5 hours streaming data and lost only 2 packets. (I guess it's something expected in radio communication?)

    Regarding to the radio data, it was correct... But it seems that was only that frame which had a poor signal...

    Here you can see the radio data, with the device in a room next to the gateway:
    0_1537549182390_radio_2.PNG

    Thank you for your time and support.



  • @shp96 Sent a chat message, please read it.



  • @shp96 Even though it's called the 915 MHz band, there's actually no channel at 915 MHz. Also, there's a total of 72 upstream and 8 downstream channels in the US915 band.

    You have selected sub-band 7, which includes channels 48 to 55, 70 (upstream).

    You can probably just remove all other channels. If you want the actual frequencies, they're:

    902 300 000  + 200 * channel
    

    for channels 0-63, with data rates 0-3 and:

    903 000 000 + 1 600 000 * (channel - 64)
    

    for channels 64-71, with data rate 4.

    I certainly hope the radio data you included isn't one of you own frames. You should be getting a much, much better RSSI and SNR at 1.5 meters!



  • @jcaron

    There is a distance of 1.5m between both devices and I'm using a 915MHz antenna connected to the right port. Also tried changing the board, the antenna and it's connector to discard that possible cause.

    Here is the updated code:

    mport binascii
    import socket
    import struct
    from time import sleep
    from network import LoRa
    
    lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.US915)
    
    for i in range(0,3):
        #lora.add_channel(i, frequency=903900000, dr_min=2, dr_max=3)
        #Tried both frequencies: 903900000 and 915000000
        lora.add_channel(i, frequency=915000000, dr_min=2, dr_max=3)
    
    for i in range(3,16):
        lora.remove_channel(i)
    
    
    dev_addr = struct.unpack(">l", binascii.unhexlify('00000000'))[0]
    nwk_swkey = binascii.unhexlify('00000000000000000000000000000000')
    app_swkey = binascii.unhexlify('00000000000000000000000000000000')
    
    lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey))
    
    while not lora.has_joined():
        print("Please wait...")
    
    print("Ready to publish data...")
    
    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    s.setsockopt(socket.SOL_LORA, socket.SO_DR, 3)
    
    data = [1,2,3]
    
    while 1:
        s.setblocking(True)
        s.send(bytes(data))
        s.setblocking(False)
        data = s.recv(64)
        sleep(5)
    

    Here is the Gateway configuration:

    lora": {
                    "netID": "010203",      /* netID for beacon packets */
                    "frequencyBand": "915", /* US="915", EU="868" */
                    "frequencySubBand": 7,  /* Sub-band for US operation, 1-8 */
                    "rx1DatarateOffset": 0, /* Datarate offset for mote rx window 1 sent in join response (0-3) */
                    "rx2Datarate": 12,              /* Datarate for mote rx window 2 sent in join response (7-12) */
                    "maxTxPower": 14,       /* Max Tx power (dBm), -6 to 26 */
                    "frequencyEU": 867500000 /* center freq for extra EU channels (Hz) */
    

    Here you can see the LNS configuration:
    0_1537474430455_lns_config.PNG

    And this are the stats of the received frames:
    0_1537474612959_radio.PNG



  • @shp96 please post your updated code. The gateway should be able to listen on several channels, though (just not all of them). Please post the relevant configuration of the gateway and LNS.

    Also, what antenna do you use? Is it connected to the right port? How far apart are the two devices?

    Can you post the stats associated with the received frames (RSSI and SNR)?



  • Thank you for your response.

    I've done what you said...

    Deleted the unused channels, changed the used frequency of the default channels to the US915 frequency, and even changed the frecuency of all the channels without deleting them... Also verified that the gateway is listening to 915MHz...

    But the problem wasn't solved.



  • @shp96 Please post your code as text (enclosed in ``ˋ).

    What frequencies is your gateway listening on? By default in the US region the LoRaWAN stack will send on any of the allowed channels, while most gateways can only listen on a few channels at a time.

    You just need to remove the unused channels. You should find numerous examples in previous posts on the subject.


 

Pycom on Twitter