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 to Lopy communication over LoRa hangs on send

    Scheduled Pinned Locked Moved LoPy
    10 Posts 4 Posters 762 Views 4 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.
    • D Offline
      dmcwright
      last edited by

      Hello everyone!

      I'm new to the PyCom devices and I'm working my way through the tutorials. However, when I run the lopy to lopy communication over LoRa example codes, the sending LoPy4 (lopy-B code) never completes the sending line. I've added a few prints to confirm the situation. Here is the code on lopy-b:

      from network import LoRa
      import socket
      import time
      
      lora = LoRa(mode=LoRa.LORA, frequency=905000000)
      s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
      s.setblocking(False)
      
      while True:
          print("Sending Ping")
          s.send("Ping")
          print("Ping Sent")
          time.sleep(5)
      

      The code results in "Sending Ping" being printed and nothing else.

      The details of the unit are below:

      (sysname='LoPy4', nodename='LoPy4', release='1.18.2', version='v1.8.6-849-743b7e7 on 2019-01-21', machine='LoPy4 with ESP32', lorawan='1.0.2', sigfox='1.0.1', pybytes='0.9.6')
      

      I appreciate any help for a newbie! Thanks.

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

        @dmcwright Hey! A fellow newbie here too. I was wondering why your code didn't work so I tested it myself on my LoPy and it shows an error of Frequency being out of range.
        Also, when I remove the frequency parameter, your code seems to work perfectly fine.

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

          @dmcwright What region is your LoPy set to?

          D 1 Reply Last reply Reply Quote 0
          • D Offline
            dmcwright @jcaron
            last edited by

            @jcaron Thanks for reaching out. I'm not sure how to check the region it is set to currently. Any advice on the best way to find out the current setting?

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

              @dmcwright I believe you can use the pycom-fwtool-cli command line firmware update tool to do so, see the `lpwan --lora_region' option.

              It may be possible through the firmware updater GUI as well. Don't know if there's a way to get it via micropython directly.

              D 1 Reply Last reply Reply Quote 0
              • D Offline
                dmcwright @sarthak04
                last edited by

                @sarthak04 Thanks for the suggestion. I removed the frequency setting and the behavior was the same. More than likely, you're in a different region than I'm in and that's what caused your frequency out of range running my code. I'm in the US.

                1 Reply Last reply Reply Quote 0
                • D Offline
                  dmcwright @jcaron
                  last edited by

                  @jcaron Thanks for the links. I ran this code and the result was:

                  LORA REGION=US915
                  

                  I originally had the region set in the constructor:

                  lora = LoRa(mode=LoRa.LORA, region=LoRa.US915)
                  

                  That had the same behavior.

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

                    I'm still having this issue. I've tried using the other frequency bands to setup the LoRa constructor and it had the same result. I'm not 100% sure how to do a full reset of the device and start again, but I used the erase_fs option of the pycom-fwtool-cli tool and tried the same code again. It behaved the same way.
                    Am I misunderstanding the operation of the socket, here? The send command for a "non-blocking" socket doesn't require any response from a receiver, correct? The example code should just keep sending the ping every 5 seconds, right?

                    If anyone has any other ideas I could try, I'd be very grateful.

                    1 Reply Last reply Reply Quote 0
                    • K Offline
                      kps
                      last edited by

                      Hi,
                      try adding region followed by frequency spot within the region . it will work.

                      D 1 Reply Last reply Reply Quote 0
                      • D Offline
                        dmcwright @kps
                        last edited by

                        @kps Thanks for the help. It 'almost' worked. It sent the first "ping" successfully, then printed "sending ping" and was never heard from again. If I use the reset button on the LoPy4 to get back to REPL and try to run the same code again from Atom, then the code won't send even that one ping. However, if I power-cycle the unit and run the same code from Atom again, then it completes the send command successfully exactly once before it hangs on the second send. Could this behavior be a clue? Why does the "hard" reset matter?

                        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