Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Activation Lopy with TTN network using OTAA method

    Scheduled Pinned Locked Moved LoPy
    lopyotaa
    15 Posts 4 Posters 3.3k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • O Offline
      oorrab @jmarcelino
      last edited by

      @jmarcelino - similar issue, but in AUS

      Failing to connect LoPy1 node to TTN in Australia (Adelaide) with OTAA. New to LoRa and LoPy so have plenty of unknowns :)

      Haven't managed to find a definite LoPy/TTN setup description for AU915 that works, but am attempting to set frequencies/channel-plan as per;
      https://www.thethingsnetwork.org/forum/t/ttn-australian-communities/4068

      os.uname()
      (sysname='LoPy', nodename='LoPy', release='1.17.3.b1', version='v1.8.6-849-83e2f7f on 2018-03-19', machine='LoPy with ESP32', lorawan='1.0.2')

      If I delete all channels and re-add, lora.join with timeout=0 does not return (appears to hang). Deleting extra channels and updating those needed appears to be OK.

      Is there a way of confirming all channel settings?

      Trying to spec a dr_max > 6 (for AU) gives a value error - is this expected, and does it matter for a basic join?

      main.py as follows;

      from network import LoRa
      import socket
      import time
      import binascii
      import pycom
      
      lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.AU915, adr=False, tx_retries=0, device_class=LoRa.CLASS_A)
      
      for i in range(16, 65):
          print("Removing channel:", i)
          lora.remove_channel(i)
      for i in range(66, 72):
          print("Removing channel:", i)
          lora.remove_channel(i)
      
      print("Adding channels...")
      for i in range(8, 16):
          print("Adding channel:", i)
          f = 915200000 + i * 200000
          print("Frequency:", f)
          lora.add_channel(i, frequency=f, dr_min=0, dr_max=3)
      
      print("Adding channel 65")
      f = 917500000
      print("Frequency:", f)
      lora.add_channel(65, frequency=f, dr_min=4, dr_max=4)
      
      for i in range(0, 8):
          print("Adding channel ", i)
          f = 923300000 + i * 600000
          print("Frequency:", f)
          lora.add_channel(i, frequency=f, dr_min=0, dr_max=6)
      
      app_eui = binascii.unhexlify('70B3DAAAAAA0BBA1')
      app_key = binascii.unhexlify('BC1186924E6EAAAAAAAAE995921392C7')
      
      lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0)
      
      while not lora.has_joined():
          time.sleep(2.5)
          print('Not yet joined...')
      

      Also tried the above with the channel removes only (no adds to try the defaults) with no avail.

      Any advice on troubleshooting this further? Have tested on several gateways and driven pretty close so shouldn't have a range issue. Node running with PyCom antenna.

      As an aside - it would be awesome to add a LoRa.AU915.TTN to handle this - looks like the Aus TTN community is fairly well coordinated on this sub-band2 setup. Perhaps a non-issue if there is a solid LoPy-Aus-TTN setup guide somewhere. I'll create one if I can get to the bottom of it!

      J 1 Reply Last reply Reply Quote 0
      • A Offline
        asavvin
        last edited by

        Hi,

        search over the forum. Still unclear if this is possible to use OTAA activation for US915 Lopy with TTN gateway. Does anybody have success?

        1 Reply Last reply Reply Quote 0
        • J Offline
          jimpower @oorrab
          last edited by

          @oorrab said in Activation Lopy with TTN network using OTAA method:

          for i in range(16, 65):
          print("Removing channel:", i)
          lora.remove_channel(i)
          for i in range(66, 72):
          print("Removing channel:", i)
          lora.remove_channel(i)

          print("Adding channels...")
          for i in range(8, 16):
          print("Adding channel:", i)
          f = 915200000 + i * 200000
          print("Frequency:", f)
          lora.add_channel(i, frequency=f, dr_min=0, dr_max=3)

          print("Adding channel 65")
          f = 917500000
          print("Frequency:", f)
          lora.add_channel(65, frequency=f, dr_min=4, dr_max=4)

          for i in range(0, 8):
          print("Adding channel ", i)
          f = 923300000 + i * 600000
          print("Frequency:", f)
          lora.add_channel(i, frequency=f, dr_min=0, dr_max=6)

          I could be wrong but looking at your code adding the channels back in your sub band 2 should be ch 8-15 and they start at 916.8 - 918.2, yours looks like you are starting from 915.2 try adjusting these and let us know your results.

          O 1 Reply Last reply Reply Quote 0
          • A Offline
            asavvin
            last edited by

            I am in US915

            1 Reply Last reply Reply Quote 0
            • O Offline
              oorrab @jimpower
              last edited by

              Thanks for the reply @jimpower

              I put in the print statements (output below) to check the maths/python, but can easily be missing something radio-esque! Indeed, these are spec'd for gateways at;
              https://www.thethingsnetwork.org/forum/t/ttn-australian-communities/4068/9

              The node config should replicate right? Nothing to switch as a node vs gateway?

              AU ISM 915
              Ch# | direc | f/MHz | BW/kHz | data rate
              8 | up | 916.8 | 125 | DR0 - DR3
              9 | up | 917.0 | 125 | DR0 - DR3
              10 | up | 917.2 | 125 | DR0 - DR3
              11 | up | 917.4 | 125 | DR0 - DR3
              12 | up | 917.6 | 125 | DR0 - DR3
              13 | up | 917.8 | 125 | DR0 - DR3
              14 | up | 918.0 | 125 | DR0 - DR3
              15 | up | 918.2 | 125 | DR0 - DR3
              65 | up | 917.5 | 500 | DR4
              0 | down | 923.3 | 500 | DR8 - DR13
              1 | down | 923.9 | 500 | DR8 - DR13
              2 | down | 924.5 | 500 | DR8 - DR13
              3 | down | 925.1 | 500 | DR8 - DR13
              4 | down | 925.7 | 500 | DR8 - DR13
              5 | down | 926.3 | 500 | DR8 - DR13
              6 | down | 926.9 | 500 | DR8 - DR13
              7 | down | 927.5 | 500 | DR8 - DR13

              Adding channels...
              Adding channel: 8
              Frequency: 916800000
              Adding channel: 9
              Frequency: 917000000
              Adding channel: 10
              Frequency: 917200000
              Adding channel: 11
              Frequency: 917400000
              Adding channel: 12
              Frequency: 917600000
              Adding channel: 13
              Frequency: 917800000
              Adding channel: 14
              Frequency: 918000000
              Adding channel: 15
              Frequency: 918200000
              Adding channel 65
              Frequency: 917500000
              Adding channel 0
              Frequency: 923300000
              Adding channel 1
              Frequency: 923900000
              Adding channel 2
              Frequency: 924500000
              Adding channel 3
              Frequency: 925100000
              Adding channel 4
              Frequency: 925700000
              Adding channel 5
              Frequency: 926300000
              Adding channel 6
              Frequency: 926900000
              Adding channel 7
              Frequency: 927500000

              J 1 Reply Last reply Reply Quote 0
              • J Offline
                jimpower @oorrab
                last edited by

                @oorrab I don't use TTN, I deploy my own gateways which operate of frequencies outside of TTN for obvious reasons.

                My node setup "up" channels replicate my Gateway 'RX" channels, if the mote or node is broadcasting on any channels outside of what the gateway is set to listen on then it will fall on deaf ears so to speak.

                1 Reply Last reply Reply Quote 0
                • A Offline
                  asavvin @asavvin
                  last edited by

                  @asavvin said in Activation Lopy with TTN network using OTAA method:

                  Hello!

                  Still unclear for me how I can connect Lopy to TTN network using OTAA method.
                  I was able to get connection only using ABP method w/o problem but OTAA have never worked for me.

                  Please advice.
                  Thank you

                  Finally I was able to get connection Lopy using OTAA with TTN gateway in US915.

                  O 1 Reply Last reply Reply Quote 0
                  • O Offline
                    oorrab @asavvin
                    last edited by

                    Hi @asavvin - could you share your code and firmware version?

                    Might have some differences here in AUS but would be good to know a working baseline and rule out some unknowns.

                    1 Reply Last reply Reply Quote 0
                    • A Offline
                      asavvin
                      last edited by

                      @oorrab
                      Hi

                      I used Pycom Lopy with latest firmware. TTN gateway with original firmware.

                      from network import LoRa
                      import socket
                      import time
                      import struct
                      import binascii

                      lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.US915)

                      dev_eui = binascii.unhexlify('xxxx')
                      app_eui = binascii.unhexlify('xxxx')
                      app_key = binascii.unhexlify('xxxx')

                      for channel in range(0, 72):
                      lora.add_channel(channel, 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, dr=4)

                      wait until the module has joined the network

                      join_wait = 0
                      while True:
                      time.sleep(2.5)
                      if not lora.has_joined():
                      print('Not joined yet...')
                      join_wait += 1
                      if join_wait == 5:
                      lora.join(activation=LoRa.OTAA, auth=(dev_eui, app_eui, app_key), timeout=0, dr=0)
                      join_wait = 0
                      else:
                      break

                      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 blocking

                      s.setblocking(False)

                      time.sleep(5.0)

                      for i in range (200):
                      pkt = b'PKT #' + bytes([i])
                      print('Sending:', pkt)
                      s.send(pkt)
                      time.sleep(4)
                      rx, port = s.recvfrom(256)
                      if rx:
                      print('Received: {}, on port: {}'.format(rx, port))
                      time.sleep(6)

                      O 1 Reply Last reply Reply Quote 0
                      • O Offline
                        oorrab @asavvin
                        last edited by

                        @asavvin interesting you set all the channels to the same frequency. Something for me to try to help narrow this down. Frequencies different in AUS but his may take LoPy complexity out of the equation to make progress....

                        A 1 Reply Last reply Reply Quote 0
                        • A Offline
                          asavvin @oorrab
                          last edited by

                          @oorrab
                          in application log I can see channels actually keep changing starting from 9039...

                          1 Reply Last reply Reply Quote 0

                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                          With your input, this post could be even better 💗

                          Register Login
                          • 1 / 1
                          • First post
                            Last post

                          Pycom on Twitter

                          Pycom