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

    Lopy LoRa node cannot receive data

    Scheduled Pinned Locked Moved Issues & Bugs
    5 Posts 2 Posters 253 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.
    • J Offline
      Jing Tu
      last edited by

      Hello everyone. I try to build a Lora network which include:

      1. LoRa application server, network server and gateway bridge(Using chirpstack server)
      2. Gateway(Lopy with latest lorawan-nano-gateway)
      3. A LoRa node(Lopy)

      The version is:
      (sysname='LoPy4', nodename='LoPy4', release='1.20.1', version='v1.11-12f4ce0 on 2019-10-06', machine='LoPy4 with ESP32', lorawan='1.0.2', sigfox='1.0.1', pybytes='1.1.2')

      I config the node as ABP, and the server can receive the data from the node. But when I send downlink data to the node, it seems the node cannot receive it. The gateway log is as followed, seems the gateway send the downlink data to the node, but the node cannot receive the data.

      This is the log from gateway
      Untitled.png

      This is the code of the node:

      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.US915)
      
      # create an ABP authentication params
      dev_addr = struct.unpack(">l", binascii.unhexlify('01e01348'))[0]
      nwk_swkey = binascii.unhexlify('b1d02316fe3cb431be24f821d260f70e')
      app_swkey = binascii.unhexlify('80f1015d075a2ea4aef97ea4e82cc730')
      
      # remove all the channels
      for channel in range(0, 72):
          lora.remove_channel(channel)
      
      # set all channels to the same frequency (must be before sending the OTAA join request)
      for channel in range(0, 72):
          lora.add_channel(channel, frequency=config.LORA_FREQUENCY, dr_min=0, dr_max=3)
      
      # join a network using ABP (Activation By Personalization)
      lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey), timeout=0, dr=0)
      
      # 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 non-blocking
      s.setblocking(False)
      
      for i in range (200):
          pkt = b'PKT #' + str(i)
          print('Sending:', pkt)
          s.send(pkt)
          s.setblocking(False)
          time.sleep(4)
          rx, port = s.recvfrom(256)
          print(rx)
          if rx:
              print('Received: {}, on port: {}'.format(rx, port))
          time.sleep(6)
      

      Thank you for the help.

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jcaron @Jing Tu
        last edited by

        @Jing-Tu Your gateway log says "Class C". By default the LoPy will be a class A device, receiving data only during the RX windows after an uplink.

        You need to either configure the LoPy as a Class C device, or tell the gateway or network that it is a class A device.

        Also note that in many regions there are limits on how often a device can transmit, and that can severely limit what you can send from a gateway to each device. Don't know the exact rules in the US region though.

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

          @jcaron said in Lopy LoRa node cannot receive data:

          a Hi jcaron, I added the device type and test it again. I found if I don't put the send statement in the for loop, I can receive the downlink data from server. But if I put the send statement in the for loop. I cannot receive the data anymore. Could you please help me to fix it? Thank you.

          J 1 Reply Last reply Reply Quote 0
          • J Offline
            jcaron @Jing Tu
            last edited by

            @Jing-Tu What did you change? Switch the LoPy to class C, or switch the gateyway/server to class A?

            If you have switched to class A, then you can only receive after you send (the opposite of what you wrote).

            If you switched to class C, I personally never tried it, and I don't quite know what the rules are in terms of which channel/data rate the LoPy is supposed to listen (and when).

            J 1 Reply Last reply Reply Quote 0
            • J Offline
              Jing Tu @jcaron
              last edited by

              @jcaron Hi jcaron, I change the node to class C. I also tried class A mode with TTN, that works OK.

              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