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 connection to TTN

    Scheduled Pinned Locked Moved LoPy
    19 Posts 5 Posters 7.3k Views 6 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 @gas
      last edited by

      @gas said in OTAA connection to TTN:

      another question how i use the deveui since i have deveui appeui and appkey

      I'm not sure how Objenius works but usually in other LoRaWAN networks it's you who supplies your own unique Dev EUI to the network as part of device registration.

      In the case of the LoPy you read the built-in Dev EUI with:

      from network import LoRa
      import binascii
      lora = LoRa(mode=LoRa.LORAWAN)
      print(binascii.hexlify(lora.mac()).upper().decode('utf-8'))
      

      Some other devices do allow you to change the built-in Dev EUI to something else, but I'm not sure that's possible on the LoPy.

      If the Dev EUI doesn't match what the network expects it may well fail to connect as you describe.

      1 Reply Last reply Reply Quote 0
      • G Offline
        gas
        last edited by

        Thanks for the reply

        when I look at the example I'm using i don't see where the devEUI was defined for the function lora.join
        using this example my device never join...

        from network import LoRa
        import socket
        import time
        import binascii
        lora = LoRa(mode=LoRa.LORAWAN)
        app_eui = binascii.unhexlify('AD A4 DA E3 AC 12 67 6B'.replace(' ',''))
        app_key = binascii.unhexlify('11 B0 28 2A 18 9B 75 B0 B4 D2 D8 C7 FA 38 54 8B'.replace(' ',''))
        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...')
        s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
        s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)
        s.setblocking(False)
        s.send(bytes([0x01, 0x02, 0x03]))
        data = s.recv(64)
        print(data)`

        1 Reply Last reply Reply Quote 0
        • Y Offline
          yahia
          last edited by yahia

          @gas
          Check if your gateway supports downlink messages? I had the same problem with the lorank8 gateway i was using because it was not updated. After the update it works perfectly. OTAA requires downlink to authenticate.

          Try sending a downlink from TTN while in ABP mode to check.

          1 Reply Last reply Reply Quote 0
          • affoltepA Offline
            affoltep
            last edited by

            @jmarcelino Hey - Thanks a lot!. Taking the Dev EUI from the LoPy as you describe and typing it in the application of TTN makes OTAA working like a charm now ;)

            G 1 Reply Last reply Reply Quote 0
            • G Offline
              gas @affoltep
              last edited by

              @affoltep
              I tried adding this
              deveui on th eserverTTN (objenious)
              and even when i do this

              lora.join(activation=LoRa.OTAA, auth=(app_key, app_eui, dev_eui), timeout=0)
              

              still not having success

              1 Reply Last reply Reply Quote 0
              • affoltepA Offline
                affoltep
                last edited by affoltep

                @gas: just define the app_key and the app_eui in your LoPy code (no dev_eui) as shown in the examples. Then set the EUI Dev code in console.thethingsnetwork.org in your application/devices

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

                  @affoltep
                  The problem here is @gas is using Objenius, which is a commercial LoRaWAN network - not the Things Network.

                  Each network has small configuration differences, I'm not sure what Objenius expects.

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    danielm
                    last edited by

                    What is the right format for auth tuple in case of OTAA?

                    auth=(app_eui, app_key)

                    or

                    auth=(app_key, app_eui, dev_eui)

                    1 Reply Last reply Reply Quote 0
                    • affoltepA Offline
                      affoltep
                      last edited by

                      @danielm : auth=(app_eui, app_key) is correct. You cannot define the dev_eui here

                      G 1 Reply Last reply Reply Quote 0
                      • G Offline
                        gas @affoltep
                        last edited by

                        @affoltep
                        hi according to objenious app_key should never be sent when joining it is used to decrypt/crypt the data
                        but dev_eui yes since on the objenious side dashboard ou declare both dev-eui et app_eui
                        i tried all combination no success yet i'll keep you updated

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

                          @gas
                          That is correct, App Key isn't sent, but it's used by LoPy to encrypt the join message which contains the App EUI and Dev EUI.

                          Objenius then uses that same App Key to decrypt the join message at their end and then send a reply also encrypted with that key. It's a "secret" both the module and Objenius knows

                          Everything must match the settings you have on the Objenius dashboard.

                          1 Reply Last reply Reply Quote 0
                          • G Offline
                            gas
                            last edited by

                            Hi again

                            So meanwhile I build Multitech DIY ic880a +Rpi3 using TTN network
                            but still I'm not able to connect to my own gateway i did the declaration of lopy dev eui on TTN and used the app-key app_eui given by TTN
                            I might missing something on the gateway

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

                              @gas
                              TTN is going through per-launch changes and not the easiest thing at the moment...

                              Are you using https://console.thethingsnetwork.org/gateways and do you see you gateway as "connected" there?

                              1 Reply Last reply Reply Quote 0
                              • G Offline
                                gas
                                last edited by

                                yes my gateways is showing connected
                                but i think i figure out the issue at the eeror
                                I see CRC 100% failed
                                i wonder if my Rpi3 is not too close to the multitech board (interferences)

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

                                  If you say ic880a and Multitech together its a bit confusing, they're two different gateway boards. You'll either have a mCard from Multitech or a IC880A from IMST.

                                  But wrt to your problem I'd check all the connections - are the antennas well attached to both the LoPy and the gateway board? - try replacing the cables connecting the Pi to the board, especially the SPI.

                                  1 Reply Last reply Reply Quote 0
                                  • G Offline
                                    gas
                                    last edited by

                                    sorry for the confusion yes it is an ic880a not multitech
                                    yes i'm checking back all the cables again and see if this helps

                                    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