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

    lopy4 set to send on one frequency, but gateway receives the packet on a different frequency

    Scheduled Pinned Locked Moved LoPy
    5 Posts 2 Posters 383 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.
    • K Offline
      kylecjo
      last edited by

      Hi,

      I have a dual channel gateway only receives on the 902.3 and 903.1 frequencies. When I attempt to send using only 902.3, my gateway does not receive anything. But when I use 903.1, my TTN console shows that the packet was received at 902.3. Does anyone have any idea what's going on?

      My code modified from https://github.com/pycom/pycom-libraries/blob/master/examples/lorawan-regional-examples/main_US915.py

      rom network import LoRa
      import socket
      import binascii
      import struct
      import time
      
      # 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('xxxxx'))[0]
      nwk_swkey = binascii.unhexlify('xxxxx')
      app_swkey = binascii.unhexlify('xxxx')
      
      # 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, 8):
          lora.add_channel(channel, frequency=903100000, 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))
      
      # 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, 3)
      
      # make the socket non-blocking
      s.setblocking(False)
      
      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)
      
      

      My TTN console output:

      Screen Shot 2019-03-26 at 2.31.19 PM.png

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

        @kylecjo Can you share details of your gateway? Are you sure its configuration/reporting is correct?

        K 1 Reply Last reply Reply Quote 1
        • K Offline
          kylecjo @jcaron
          last edited by

          @jcaron I'm using a raspberry pi with a Dragino LoRa/GPS Hat as a gateway. I used this code to use the device as a dual channel gateway on 902.3 and 903.1 frequencies.

          I have tested the gateway with other LoRa devices and the console reports as receiving on the correct frequencies.

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

            @kylecjo Are you sure this setup supports 2 frequencies at the same time? I always thought the SX1276 could support only one frequency at a time, and I don't see anything in the data sheet that says otherwise, did I miss that?

            The documentation is unclear, but it seems to indicate you actually need two SX1272 or SX1276 (or a combination of the two) to support two frequencies.

            Looking quickly through the code, it seems to be using two different pins (pin_nss and pin_nss2 in the config file) to select one of two chips, what did you set there? The HAT you linked to has a single NSS input for the LoRa chip.

            If you only have one, it's only listening on one channel and possibly getting confused on what chip is listening on what channel and incorrectly reporting to the LNS.

            1 Reply Last reply Reply Quote 2
            • K Offline
              kylecjo
              last edited by

              I switched the code on the gateway to the single channel version and TTN shows an output as intended. You are probably correct about the chip getting confused about which channel it is listening on. Thank you!

              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