Lopy LoRa node cannot receive data

  • Hello everyone. I try to build a Lora network which include:

    1. LoRa application server, network server and gateway bridge(Using chirpstack server)
    2. Gateway(Lopy with latest lorawan-nano-gateway)
    3. A LoRa node(Lopy)

    The version is:
    (sysname='LoPy4', nodename='LoPy4', release='1.20.1', version='v1.11-12f4ce0 on 2019-10-06', machine='LoPy4 with ESP32', lorawan='1.0.2', sigfox='1.0.1', pybytes='1.1.2')

    I config the node as ABP, and the server can receive the data from the node. But when I send downlink data to the node, it seems the node cannot receive it. The gateway log is as followed, seems the gateway send the downlink data to the node, but the node cannot receive the data.

    This is the log from gateway

    This is the code of the node:

    from network import LoRa
    import socket
    import binascii
    import struct
    import time
    import config
    # initialize LoRa in LORAWAN mode.
    # Please pick the region that matches where you are using the device:
    # Asia = LoRa.AS923
    # Australia = LoRa.AU915
    # Europe = LoRa.EU868
    # United States = LoRa.US915
    lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.US915)
    # create an ABP authentication params
    dev_addr = struct.unpack(">l", binascii.unhexlify('01e01348'))[0]
    nwk_swkey = binascii.unhexlify('b1d02316fe3cb431be24f821d260f70e')
    app_swkey = binascii.unhexlify('80f1015d075a2ea4aef97ea4e82cc730')
    # remove all the channels
    for channel in range(0, 72):
    # set all channels to the same frequency (must be before sending the OTAA join request)
    for channel in range(0, 72):
        lora.add_channel(channel, frequency=config.LORA_FREQUENCY, dr_min=0, dr_max=3)
    # join a network using ABP (Activation By Personalization)
    lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey), timeout=0, dr=0)
    # 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, 0)
    # make the socket non-blocking
    for i in range (200):
        pkt = b'PKT #' + str(i)
        print('Sending:', pkt)
        rx, port = s.recvfrom(256)
        if rx:
            print('Received: {}, on port: {}'.format(rx, port))

    Thank you for the help.

  • @jcaron Hi jcaron, I change the node to class C. I also tried class A mode with TTN, that works OK.

  • @Jing-Tu What did you change? Switch the LoPy to class C, or switch the gateyway/server to class A?

    If you have switched to class A, then you can only receive after you send (the opposite of what you wrote).

    If you switched to class C, I personally never tried it, and I don't quite know what the rules are in terms of which channel/data rate the LoPy is supposed to listen (and when).

  • @jcaron said in Lopy LoRa node cannot receive data:

    a Hi jcaron, I added the device type and test it again. I found if I don't put the send statement in the for loop, I can receive the downlink data from server. But if I put the send statement in the for loop. I cannot receive the data anymore. Could you please help me to fix it? Thank you.

  • @Jing-Tu Your gateway log says "Class C". By default the LoPy will be a class A device, receiving data only during the RX windows after an uplink.

    You need to either configure the LoPy as a Class C device, or tell the gateway or network that it is a class A device.

    Also note that in many regions there are limits on how often a device can transmit, and that can severely limit what you can send from a gateway to each device. Don't know the exact rules in the US region though.

Log in to reply

Pycom on Twitter