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

    Cannot join using OTAA.

    Scheduled Pinned Locked Moved LoPy
    3 Posts 2 Posters 34 Views 2 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.
    • H Offline
      hakan kayan
      last edited by

      Hi,

      I am trying to establish a LoRa communication. I am a beginner.

      First of all, the GitHub code is different than the webpage tutorial. I am not sure which one to follow. I tried both.

      The problem was mentioned in another topic around 4 years ago. But sadly, it seems like the issue still persists.

      I have 1 LoPy and 1 LoPy4. I am using LoPy as end node, and LoPy4 as a gateway. I registered both to TTN. The gateway receives uplink messages but my device can never join.

      How can I debug this further?

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @hakan kayan
        last edited by

        @hakan-kayan You could switch the devices. The Lopy works better as gateway. Since it has no SPIRAM, timing is more reliable.

        H 1 Reply Last reply Reply Quote 0
        • H Offline
          hakan kayan @robert-hh
          last edited by

          Hi @robert-hh,

          I tried, sadly still no success. Here is what I see in my TTN gateway activity. It does not allow me to put a picture so I am adding as a code:

          Receive uplink message        JoinEUI: something       DevEUI: something        Data rate: SF7BW125
          

          The output of node LoPy as follows:

          Not yet joined...
          

          Here is my code on node:

          """ OTAA Node example compatible with the LoPy Nano Gateway """
          
          from network import LoRa
          import socket
          import binascii
          import struct
          import time
          import config
          
          # initialize LoRa in LORAWAN mode.
          # Please pick the region that matches where you are using the device:
          # Asia = LoRa.AS923
          # Australia = LoRa.AU915
          # Europe = LoRa.EU868
          # United States = LoRa.US915
          lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.EU868)
          
          # create an OTA authentication params
          dev_eui = binascii.unhexlify('something')
          app_eui = binascii.unhexlify('something')
          app_key = binascii.unhexlify('something')
          
          # set the 3 default channels to the same frequency (must be before sending the OTAA join request)
          lora.add_channel(0, frequency=config.LORA_FREQUENCY, dr_min=0, dr_max=5)
          lora.add_channel(1, frequency=config.LORA_FREQUENCY, dr_min=0, dr_max=5)
          lora.add_channel(2, frequency=config.LORA_FREQUENCY, dr_min=0, dr_max=5)
          
          # join a network using OTAA
          lora.join(activation=LoRa.OTAA, auth=(dev_eui, app_eui, app_key), timeout=0, dr=config.LORA_NODE_DR)
          
          # wait until the module has joined the network
          while not lora.has_joined():
              time.sleep(2.5)
              print('Not joined yet...')
          
          # 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, config.LORA_NODE_DR)
          
          # make the socket non-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)
          
          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