Lopy to Lopy communication over LoRa hangs on send

  • 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)
    while True:
        print("Sending Ping")
        print("Ping Sent")

    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.

  • @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?

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

  • 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.

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


    I originally had the region set in the constructor:

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

    That had the same behavior.

  • @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.

  • @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.

  • @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?

  • @dmcwright What region is your LoPy set to?

  • @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.

Log in to reply

Pycom on Twitter