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

    LoRa packet loss

    Scheduled Pinned Locked Moved LoPy
    lorapacket
    9 Posts 4 Posters 3.5k 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.
    • F Offline
      finnzc
      last edited by

      Hi again,

      When I'm testing how many LoRa packets the gateway receives from the node (using LoPy to LoPy tutorial), it is incredibly bad. The node sends a packet with message variable i (to track how many packets are received and lost) and it turned out that sending 10 packets/second does not guarantee 1 packet received by gateway when it is listening in the loop with no time.sleep().

      Am I supposed to spam gateway with packets or is my approach wrong?

      PS: Both have antennas installed

      B F 2 Replies Last reply Reply Quote 0
      • B Offline
        bucknall @finnzc
        last edited by

        Hi @finnzc, the transmission time for a LoRa message depends on the size of the payload and a number of other features. If you're trying to send 10 message per second, you're likely trying to send message before the previous one has been sent.

        Could you please paste your script in this thread so I can see what you're trying to do?

        Thanks,

        Alex

        Developer Evangelist - Pycom

        1 Reply Last reply Reply Quote 0
        • F Offline
          finnzc
          last edited by finnzc

          @bucknall
          Here is my code, I also adjusted the time.sleep to 0.5 to send 2 packets per second but the received packets is very little. I use the variable i to calculate the number of lost packet between each received packet.

          Node_A:

          lora = LoRa(mode=LoRa.LORA)
          s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
          
          i = 0
          s.setblocking(False)
          
          while True:
              # send some data
              message = 'Node A: Hello ' + str(i)
              print(message)
              s.send(message)
              i = i + 1
              time.sleep(0.1)
          

          Receiver:

          lora = LoRa(mode=LoRa.LORA, rx_iq=True)
          s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
          s.setblocking(False)
          
          print('Start')
          while True:
              data = s.recv(64)
              if (len(data) > 0):
                  print(data)
          
          B J 2 Replies Last reply Reply Quote 0
          • B Offline
            bucknall @finnzc
            last edited by

            @finnzc You're going to have issues with this because you're going to be sending message over the previous one with this code. Change s.setblocking(False) to s.setblocking(True). This way the code is synchronous and will wait until the previous message has sent before continuing with the code.

            Developer Evangelist - Pycom

            F 1 Reply Last reply Reply Quote 0
            • F Offline
              finnzc @bucknall
              last edited by finnzc

              @bucknall

              I changed to s.setblocking(True) in the sender node but the receiver node still doesn't receive much data... I believe the problem is at the receiver node. Do you have any suggestions where could be the problem? The worst case is that I could have already damaged my board by sending LoRa packets before installing the antennas...

              0_1500544156719_Screenshot from 2017-07-20 10-49-07.png

              This is what I get when I send 2 packets per second with blocking True and the receiver node as above. For every 5 packets received, it outputs the ratio of lost package / received package(5)

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

                How far away are your boards? Indoors or outdoors? What data rate / spreading factor are your using? The RSSI figures are very close to the limits of LoRa.

                Also, remember that the lowest data rates (highest spreading factors) mean that it takes forever to send a packet (nearly 1.5s for the smallest packet using SF 12), and that in some regions (the EU for instance) you are not allowed to send on the same sub-band for 99 times the time it took to send the last packet...

                F 1 Reply Last reply Reply Quote 0
                • F Offline
                  finnzc @jcaron
                  last edited by

                  @jcaron
                  I tested the packet loss both indoor and outdoor, both have loss rate of >95%. I used the default settings so sf = 7 and coding_rate = LoRa.CODING_4_5. I've also tested the loss using less packets per second and the results are similar...

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    jmarcelino @finnzc
                    last edited by jmarcelino

                    @finnzc said in LoRa packet loss:

                    lora = LoRa(mode=LoRa.LORA, rx_iq=True)

                    I don't understand why you set rx_iq=True on the receiving node but then not set tx_iq=True on the sending one ?

                    Since your sending node will have tx_iq=False (the default) I'm surprised you get any packets at all. Not sure what is going on.

                    Can you try removing inversion altogether, based on the simple LoPy to LoPy example? https://docs.pycom.io/chapter/tutorials/lopy/lopy-lopy.html

                    Also try another frequency, for example the one on that example frequency=863000000 if you're in Europe or one appropriate for your region

                    1 Reply Last reply Reply Quote 0
                    • F Offline
                      finnzc @finnzc
                      last edited by

                      @bucknall
                      @jcaron
                      @jmarcelino

                      Guys, mystery solved. It seems like I have already damaged the sender Pycom by sending packets before attaching the antenna to it (improper use...). Now I used another Pycom acting as the sender and there is <1% packet loss. Lesson learned the hard way. Always read all documentation before playing around with the board :/

                      1 Reply Last reply Reply Quote 1

                      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