Problem pairing OTAA Node to nano gateway in US TTN



  • The nano gateway says it is connected...

    I have configured like this :

    config.py

    LORA_FREQUENCY = 915100000
    LORA_DR = "SF7BW125"   # DR_5
    

    nanogateway.py

    RX_PK = {"rxpk": [{"time": "", "tmst": 0,
                       "chan": 0, "rfch": 0,
                       "freq": 915.1, "stat": 1,
                       "modu": "LORA", "datr": "SF7BW125",
                       "codr": "4/5", "rssi": 0,
                       "lsnr": 0, "size": 0,
                       "data": ""}]}
    

    Otaa Node

    lora = LoRa(mode=LoRa.LORAWAN)
    
    
    
    for channel in range(0, 72):
        lora.remove_channel(channel)
    
    lora.add_channel(0, frequency=915100000, dr_min=0, dr_max=4)
    

    I have not been able to make it join... any suggestions or things that i might be missing?



  • you can find the code that is working right now for TTN US here on my GitHub

    I also made a guide on my blog



  • @jmarcelino

    Changed to ABP and now the gateway is receiving traffic...

    thanks... will post my code once i do cleanup :)

    thanks for your help @jmarcelino



  • @iotmaker

    OK I see some issues. Your node code is a bit strange, you don't need to assign the same frequency to three channels, that's only for the EU868 region where the 3 channels are enforced by the spec. Use something like this instead:

    for channel in range(0, 72):
        lora.remove_channel(channel)
    
    lora.add_channel(0, frequency=903900000, dr_min=0, dr_max=4)
    

    and nothing else, no more add_channels or remove_channels after this.

    s.setsockopt(socket.SOL_LORA, socket.SO_DR, 3) is OK

    On the Gateway config change:

    LORA_DR = "SF9BW125" to
    LORA_DR = "SF7BW125"

    Data rate (DR) 3 in the US915 region means SF 7 125Khz (these data rate numbers assignments have different meanings from EU868 region, see the LoRaWAN Regional Parameters specification)

    This meant the gateway was listening for SF9 (SF set by that string) while your node was sending as SF7 (set by SO_DR = 3) and explains why you get nothing.

    If all this still fails try setting up the node as ABP instead of OTAA, sometimes the receive window timings for OTAA are hard to achieve.



  • @jmarcelino this is my node code
    did the change but still no luck...

    from network import LoRa
    import socket
    import binascii
    import struct
    import time
    
    # Initialize LoRa in LORAWAN mode.
    lora = LoRa(mode=LoRa.LORAWAN)
    
    # create an OTA authentication params
    dev_eui = binascii.unhexlify('xxx'.replace(' ',''))
    app_eui = binascii.unhexlify('xxx'.replace(' ',''))
    app_key = binascii.unhexlify('xxx'.replace(' ',''))
    
    
    for index in range(0, 8):
        lora.remove_channel(index)
    
    for index in range(16, 65):
        lora.remove_channel(index)
    
    for index in range(66, 72):
        lora.remove_channel(index)
    
    # set the 3 default channels to the same frequency (must be before sending the OTAA join request)
    lora.add_channel(0, frequency=903900000, dr_min=0, dr_max=3)
    lora.add_channel(1, frequency=903900000, dr_min=0, dr_max=3)
    lora.add_channel(2, frequency=903900000, dr_min=0, dr_max=3)
    
    # join a network using OTAA
    lora.join(activation=LoRa.OTAA, auth=(dev_eui, app_eui, app_key), timeout=0)
    
    # wait until the module has joined the network
    while not lora.has_joined():
        time.sleep(2.5)
        print('Not joined yet...')
    
    
    
    print("passed joined")
    # remove all the non-default channels
    for i in range(3, 16):
        lora.remove_channel(i)
    
    # 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 blocking
    s.setblocking(False)
    
    time.sleep(5.0)
    
    for i in range (200):
        s.send(b'PKT #' + bytes([i]))
        time.sleep(4)
        rx = s.recv(256)
        if rx:
            print(rx)
        time.sleep(6)
    
    

    Mi config.py looks like this

    """ LoPy LoRaWAN Nano Gateway configuration options """
    
    GATEWAY_ID = '70B3D5499BFD0F7A'#
    
    SERVER = 'router.us.thethings.network'
    PORT = 1700
    
    NTP = "pool.ntp.org"
    NTP_PERIOD_S = 3600
    
    WIFI_SSID = 'xxx'
    WIFI_PASS = 'xxxx'
    
    LORA_FREQUENCY = 903900000
    LORA_DR = "SF9BW125"   # DR_3
    
    


  • @iotmaker
    What do you have in your OTAA node code for this?

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

    SO_DR should be 3 instead of 5 for the US915 region.

    Also see the previous thread: https://forum.pycom.io/topic/983/otaa_node-py-error



  • @jmarcelino said in Problem pairing OTAA Node to nano gateway in US TTN:

    903.9

    no luck.. my nano gateway is connected according to TTN but cant see the node..



  • thanks.. i will try to update the frequencies and try again...



  • @iotmaker

    Not sure if this is the problem, but according to the TTN band plan for US915, 915.1Mhz isn't a valid frequency, try 903.9

    I take it you've also changed config.py to SERVER = 'router.us.thethings.network' ?


Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.