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 Ping-Pong Example

    Scheduled Pinned Locked Moved Comments & Feedback
    lopylorarssiantenna
    4 Posts 2 Posters 1.7k 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.
    • B Offline
      Burgeh
      last edited by Burgeh

      Greetings,

      I have a question regarding the LoPy to LoPy Ping-Pong example code which uses raw lora to communicate. I am currently using this code for my receiving node.

      from network import LoRa
      import socket
      import time
      import pycom
      
      
      #NODE A
      
      # 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.LORA, region=LoRa.US915, tx_power = 10)
      s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
      s.setblocking(False)
      
      pycom.heartbeat(False)
      pycom.rgbled(0x007f00) # green
      
      #TX_power is the value that is set on this chip not received.
      while True:
          if s.recv(64) == b'Ping':
              print("Sending pong")
              data = lora.stats()
              print("Stats %s" % data)
              pycom.rgbled(0x0000ff) # blue
              time.sleep(.5)
              pycom.rgbled(0x00ff00) # green
      

      and then this for my sending...

      from network import LoRa
      import socket
      import time
      import pycom
      #NODE B
      
      # 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.LORA, region=LoRa.US915)
      s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
      s.setblocking(False)
      
      pycom.heartbeat(False)
      pycom.rgbled(0x007f00) # green
      
      while True:
          s.send('Ping')
          time.sleep(5)
          pycom.rgbled(0x0000ff) # blue
          time.sleep(1)
          pycom.rgbled(0x00ff00) # green
      

      I use an antenna for both LoPys, I get messages and data received just fine when they're right next to each other and when there up to 5m away. However, randomly my receiving drops out, it stops getting messages. If I restart the sending lopy then it works again, if I restart the receiving it does not. At close distance (right next to one another) I'm getting around -30dBm for the RSSI, which seems bad due to their proximity. Any suggestions? I've had it work for over 3 hours and stop and I've had it stop after 3 minutes.

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

        @burgeh The ping pong sample code is just for demonstration and not very robust. In my test I always had to start lopy_b fist to get it running.
        As of receiving levels: In my desktop test (~1m apart) I had levels about -20db. Besides that, it heavily depends on antenna cables and antennas. The u.fl is not made for frequent plugs and is sensitive to moving. Even for testing you attach xxpy and the antenna to a case or a piece of metal sheet, such that the pigtail cable with the u.fl plug does not move or is further bent.

        B 1 Reply Last reply Reply Quote 0
        • B Offline
          Burgeh @robert-hh
          last edited by

          @robert-hh Besides improve the antenna and perhaps making an enclosure to ensure components don't move, what would you suggest to help boost robustness? Sending the same data multiple times? Increasing SF?

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

            @burgeh As said, I did not investigate the ping-pong example further. I just used it to check, whether the devices work at all. Using the TTN gateway software was more reliable. At least messages form the node to the gateway arrive all the time. You may have a look at the non-TTN gateway example https://github.com/pycom/pycom-libraries/tree/master/examples/loraNanoGateway
            That one is a litte bit more elaborate and may be a better starting point. I tried it too, and it worked. The code of interest is in the respective main.py files.

            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