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

    Problem joining TTN in Australia with OTAA using a LoPy 4

    Scheduled Pinned Locked Moved LoPy
    lopy4ttnjoinotaa
    15 Posts 5 Posters 4.0k Views 5 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.
    • R Offline
      rskoniec
      last edited by rskoniec

      Add import time and try:

      while not lora.has_joined():
          time.sleep(2.5)
          print("attempt...")
      

      instead of:

      while not lora.has_joined():
          print("attempt...")
          time.sleep(2.5)
      

      Source: https://docs.pycom.io/chapter/firmwareapi/pycom/network/lora.html

      The machine is working as good as it's code.

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jojo @jmarcelino
        last edited by

        @jmarcelino

        Hi Jose,

        I just did that, now the os.uname() returns:

        (sysname='LoPy4', nodename='LoPy4', release='1.16.0.b1', version='v1.8.6-849-055728a on 2018-02-13', machine='LoPy4 with ESP32', lorawan='1.0.0', sigfox='1.0.1')
        

        And lora.frequency() still returns 868000000 instead of 915000000. So I guess the region is still not right.

        J 1 Reply Last reply Reply Quote 0
        • J Offline
          jojo @rskoniec
          last edited by jojo

          @rskoniec

          That's right, I forgot to add the import time in the sample code, but that's not the issue here since the code is stuck at the join and does not reach the while loop :)

          I'll edit the code in the original post.

          Also the order of the 2 statements in the loop does not really matter.

          R 1 Reply Last reply Reply Quote 0
          • J Offline
            jmarcelino @jojo
            last edited by jmarcelino

            Hi @jojo,

            OK, I'm not sure why it's still on 868Mhz but fortunately you can use the new region setting functions!

            You can now initialise lora with

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

            and it'll be set to the (also newly supported) Australian AU915 frequency map!
            (you'll still need to disable channels if you gateway only supports 8 out of the 72)

            This is also saved with lora.nvram_save() and nvram_restore()

            J R philwilkinsonP 4 Replies Last reply Reply Quote 0
            • J Offline
              jojo @jmarcelino
              last edited by

              @jmarcelino

              Thanks for that! I'll try that first thing tomorrow morning and let you know how it goes :).

              1 Reply Last reply Reply Quote 1
              • R Offline
                rskoniec @jojo
                last edited by

                @jojo I thought so, but I was not able to try this myself. :)

                The machine is working as good as it's code.

                1 Reply Last reply Reply Quote 0
                • R Offline
                  rskoniec @jmarcelino
                  last edited by

                  @jmarcelino Btw, is there a new version 1.16.0.b1? I couldn't find any info about it on forum.

                  The machine is working as good as it's code.

                  sebS 1 Reply Last reply Reply Quote 0
                  • sebS Offline
                    seb @rskoniec
                    last edited by

                    @rskoniec An announcement about it is coming momentarily

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      jojo @jmarcelino
                      last edited by

                      @jmarcelino

                      Good morning!

                      I can confirm it works very well! Thanks Pycom for your awesome work!

                      Here is the code I use to join TTN in Australia, in case someone else face the same issue:

                      from network import LoRa
                      import binascii
                      import socket
                      import time
                      
                      lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.AU915, adr=False, tx_retries=0, device_class=LoRa.CLASS_A)
                      # credentials
                      APP_EUI = 'XXXXX'
                      APP_KEY = 'YYYYYYYY'
                      
                      # remove some channels
                      for i in range(16, 65):
                          lora.remove_channel(i)
                      for i in range(66, 72):
                          lora.remove_channel(i)
                      
                      # create an OTA authentication params
                      app_eui = binascii.unhexlify(APP_EUI.replace(' ',''))
                      app_key = binascii.unhexlify(APP_KEY.replace(' ',''))
                      
                      print("Joining")
                      # join a network using OTAA if not previously done
                      lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0)
                      

                      Cheers,

                      Johan

                      1 Reply Last reply Reply Quote 0
                      • philwilkinsonP Offline
                        philwilkinson @jmarcelino
                        last edited by

                        @jmarcelino said in Problem joining TTN in Australia with OTAA using a LoPy 4:

                        You can now initialise lora with
                        lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.AU915)
                        and it'll be set to the (also newly supported) Australian AU915 frequency map!
                        (you'll still need to disable channels if you gateway only supports 8 out of the 72)
                        This is also saved with lora.nvram_save() and nvram_restore()

                        @jmarcelino I note your response to @jojo 's question mentioned the need to disable channels.

                        "(you'll still need to disable channels if you gateway only supports 8 out of the 72)
                        This is also saved with lora.nvram_save() and nvram_restore()"

                        I have run the adjusted code :

                        for i in range(16, 65):
                        lora.remove_channel(i)
                        for i in range(66, 72):
                        lora.remove_channel(i)

                        and the LoPy connects OK.

                        Is this an issue with the gateway or are the full set of AU915 frequencies not covered by all gateways?
                        The previous firmware for the LoPy ran fine with the same gateway.
                        thanks in advance for any advice, Jose
                        Phil

                        J 1 Reply Last reply Reply Quote 0
                        • J Offline
                          jmarcelino @philwilkinson
                          last edited by jmarcelino

                          @philwilkinson
                          You almost always need to disable channels in US915 and AU915 because most commercial gateways only support listening on 8 channels out of the possible 72.

                          In terms of TTN they have done this decision for you, see the subchannel map they propose: https://github.com/TheThingsNetwork/gateway-conf/blob/master/AU-global_conf.json

                          916.8, 917.0, 917.2, 917.4, 917.6, 917.8, 918.0, 918.2

                          But this is only true to TTN, other networks may use a different subset.

                          We plan to document this better in the near future.

                          philwilkinsonP 1 Reply Last reply Reply Quote 0
                          • philwilkinsonP Offline
                            philwilkinson @jmarcelino
                            last edited by

                            @jmarcelino thanks for the clear explanation.
                            It would be really useful if you could put this small section of code on the Getting Started section of Pycom's LoPy documentation for those who are connecting to TTN; the most popular LoRa network in Australia/New Zealand region. I will try and post something in The Things Network Australia Community page too.

                            If you would prefer, I can raise it through GitHub, but I suspect your ability to change the Pycom documentation is much quicker!
                            thanks again for your help Jose.
                            Also, I really enjoyed your talk on The Things Network conference

                            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