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

    otaa_node.py error

    Scheduled Pinned Locked Moved LoPy
    otaa
    11 Posts 2 Posters 3.4k Views 3 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.
    • J Offline
      jmarcelino
      last edited by jmarcelino

      DR (data rate) 5 is only defined in the 868Mhz (EU) region, for others you must use 4 - that's part of the LoRaWAN specification. I guess you're not in the Europe/868Mhz LoRa region?

      If so make sure the frequency in add_channel is actually valid for you! 868100000 as it stands won't be. It has to match what's set to LORA_FREQUENCY in config.py

      Finally change nanogateway.py, where it says "freq": 868.1 should also match your LORA_FREQUENCY but in MHz (divide by 1 000 000)

      1 Reply Last reply Reply Quote 0
      • T Offline
        tcottle
        last edited by

        Thanks - I'm in the US but did change the frequency to 915000000.

        Is this line in config.py going to be a problem "LORA_DR = "SF7BW125" # DR_5" ?

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

          @tcottle
          It's OK, the DR matching SF7 BW125 for you is 3 but since the configuration is given in full there's no problem.

          1 Reply Last reply Reply Quote 0
          • T Offline
            tcottle
            last edited by

            Thanks - Now I have a new problem. My LoPy OTAA node will not join the gateway. The gateway is using the lorawan-nano-gatewate code

            Both LoPys have been updated to the latest firmware
            (sysname='LoPy', nodename='LoPy', release='1.6.10.b1', version='v1.8.6-556-g989d5ac9 on 2017-03-30', machine='LoPy with ESP32', lorawan='1.0.0')

            I've made the changes that you recommended and changed the frequency to 903900000 since that was the first channel listed for the US TTN Frequencies

            The gateway is seen by the TTN and the gateway ID is 70b3d5499ec07fab. It is logging no traffic

            Here is my config (with the WiFi stuff deleted)

            GATEWAY_ID = '70B3D5499EC07FAB'
            SERVER = 'router.us.thethings.network'
            PORT = 1700

            NTP = "pool.ntp.org"
            NTP_PERIOD_S = 3600

            WIFI_SSID =
            WIFI_PASS =

            LORA_FREQUENCY = 903900000
            LORA_DR = "SF7BW125" # DR_5

            and the change to the nanogateway file

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

            Here is the OTAA code snippet

            dev_eui = binascii.unhexlify('70 B3 D5 7E 49 9D AA 5D'.replace(' ',''))
            app_eui = binascii.unhexlify('70 B3 D5 7E F0 00 43 EE'.replace(' ',''))
            app_key = binascii.unhexlify('A5 10 AA 99 35 C9 B3 7D E1 4E 3D 0B 81 1E E6 90'.replace(' ',''))

            lora.add_channel(0, frequency=903900000, dr_min=0, dr_max=4)
            lora.add_channel(1, frequency=903900000, dr_min=0, dr_max=4)
            lora.add_channel(2, frequency=903900000, dr_min=0, dr_max=4)

            and a screenshot of how I have the application configured

            alt text

            I just made up values for Application ID and Device ID

            I suspect that the radio is misconfigured but I am at a loss why

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

              @tcottle

              TTN has been going up and down like a rollercoaster in the past few days - and when working also delivering OTAA replies almost at the last ms.

              You might have better luck with ABP instead of OTAA for now. Give it a try. Just needs similar changes to the ABP script https://github.com/pycom/pycom-libraries/blob/master/examples/lorawan-nano-gateway/abp_node.py

              and of course changing the device to ABP is the TTN console (which will generate your dev_addr, nwk_swkey and app app_swkey)

              1 Reply Last reply Reply Quote 0
              • T Offline
                tcottle
                last edited by

                Thanks!
                I setup a new device using ABP activation and ttn-handler-us-west as the handler. Entered the keys into adp_node.py

                I was getting this error: OSError: [Errno 95] EOPNOTSUPP
                until I changed the value in s.setsockopt(socket.SOL_LORA, socket.SO_DR, 4) from 5 to 4

                It doesn't throw any errors or messages but it doesn't show up in the TTN network either

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

                  @tcottle
                  can you try 3 instead of 4?

                  T 1 Reply Last reply Reply Quote 0
                  • T Offline
                    tcottle @jmarcelino
                    last edited by

                    @jmarcelino Limited success(!)
                    The device is now seen and both the gateway and application see data. Most was missed though. I only received packets 2,8,81,86,101,105,110, 151, 170, 181 and 200

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

                      @tcottle
                      Ha! Makes sense to me now, thanks for doing that. US 915 has many more channels it's not enough to just overwrite the three.

                      Remove the the 3 existing calls to lora.add_channel() and try

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

                      That should remove all the existing channels and leave you with just one.

                      T 1 Reply Last reply Reply Quote 2
                      • T Offline
                        tcottle @jmarcelino
                        last edited by

                        @jmarcelino that worked!!! The application is receiving all packets. The GW is missing a few - odd. Thanks a 10^6 for all of your help. I owe you a beer but you will have to come to Colorado to collect :-)

                        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