Cannot join using OTAA.

  • Hi,

    I am trying to establish a LoRa communication. I am a beginner.

    First of all, the GitHub code is different than the webpage tutorial. I am not sure which one to follow. I tried both.

    The problem was mentioned in another topic around 4 years ago. But sadly, it seems like the issue still persists.

    I have 1 LoPy and 1 LoPy4. I am using LoPy as end node, and LoPy4 as a gateway. I registered both to TTN. The gateway receives uplink messages but my device can never join.

    How can I debug this further?

  • Hi @robert-hh,

    I tried, sadly still no success. Here is what I see in my TTN gateway activity. It does not allow me to put a picture so I am adding as a code:

    Receive uplink message        JoinEUI: something       DevEUI: something        Data rate: SF7BW125

    The output of node LoPy as follows:

    Not yet joined...

    Here is my code on node:

    """ OTAA Node example compatible with the LoPy Nano Gateway """
    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.EU868)
    # create an OTA authentication params
    dev_eui = binascii.unhexlify('something')
    app_eui = binascii.unhexlify('something')
    app_key = binascii.unhexlify('something')
    # set the 3 default channels to the same frequency (must be before sending the OTAA join request)
    lora.add_channel(0, frequency=config.LORA_FREQUENCY, dr_min=0, dr_max=5)
    lora.add_channel(1, frequency=config.LORA_FREQUENCY, dr_min=0, dr_max=5)
    lora.add_channel(2, frequency=config.LORA_FREQUENCY, dr_min=0, dr_max=5)
    # join a network using OTAA
    lora.join(activation=LoRa.OTAA, auth=(dev_eui, app_eui, app_key), timeout=0, dr=config.LORA_NODE_DR)
    # wait until the module has joined the network
    while not lora.has_joined():
        print('Not joined yet...')
    # remove all the non-default channels
    for i in range(3, 16):
    # 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, config.LORA_NODE_DR)
    # make the socket non-blocking
    for i in range (200):
        pkt = b'PKT #' + bytes([i])
        print('Sending:', pkt)
        rx, port = s.recvfrom(256)
        if rx:
            print('Received: {}, on port: {}'.format(rx, port))

  • @hakan-kayan You could switch the devices. The Lopy works better as gateway. Since it has no SPIRAM, timing is more reliable.

Log in to reply

Pycom on Twitter