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

    Sending ASCII from lopy4

    Scheduled Pinned Locked Moved LoPy
    7 Posts 2 Posters 538 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.
    • P Offline
      phusy012
      last edited by robert-hh

      Hi,

      I am trying to send the ascii from the lopy4 to the gateway. First the ascii.txt will be converted to the binary bits and then divided into the lora packets and the packets will be sent with delayed time. If any one of you have completed similar task or have any idea, I would appreciate your help. I am new to the micropython codings.

      I have also tried to program the following code;

      import binascii
      import struct
      
      ascii = 'SIGN.txt'
      with open(ascii, 'rb') as f:
          content = f.read()
          data = binascii.hexlify(content)
      print(binascii.hexlify(content))
      print(content)
      print(data)
      
      l = len(data)
      print (l)
      hex_string = binascii.unhexlify(data)
      print (hex_string)
      print (len (hex_string))
      
      for l in range (0, l, 10):
          package = data[1:l+10]
          print (package) 
      

      Your help will be highly appreciated.

      Thank you

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

        @phusy012 Assuming that what you call "gateway" is not a TTN gateway, you can get some hints from the Lora-Lora example in the documentation: https://docs.pycom.io/tutorials/lora/module-module/
        Also, for transmission you do not have to convert your data to a hex_string. That only doubles the data size and transmission time = air time, which is limited in LoRa.

        P 1 Reply Last reply Reply Quote 0
        • P Offline
          phusy012 @robert-hh
          last edited by phusy012

          @robert-hh and any other experts

          Hi,

          Thank you for the response.

          The "gateway" I meant was my own Lora Built in Server. I am using the RAK831 Pilot Gateway and I have developed my own Built in Server.

          I took note of having no need to convert ascii to hex and wrote the new program code attached below;
          1.JPG

          When I run the program on the Lopy4 board, it though sends some part of the ascii (I confirm since I receive some data in the node applications device data of LoRa Built in Server) but comes with the following error attached below:
          2.JPG

          I tried to browse for error nature and reasons but could not get the clear picture. Please advise and will appreciate your help in advance.

          Thank you

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

            @phusy012 After a few packets there is an overflow in sending. You should set s.setblocking(True), to ensure, that the next transmission is not requested before the previous has been completed.

            P 1 Reply Last reply Reply Quote 0
            • P Offline
              phusy012 @robert-hh
              last edited by

              @robert-hh
              Hi. Thank you for the comment. I set the s.setblocking(True) and could see the lora built-in server receiving the packets. But after some time, some packets are lost in the middle while the others are received continuously. I also tried to put the lopy into sleep for some seconds in a loop to enable the delay between two packets but even then some packets are lost in the middle (could see from the device data in application section of the lora builtin server).

              for l in range (0, l, 20):
              package = content[l:l+20]
              print(package)
              s.send(package)
              sleep(10)

              Wondering what could have gone wrong in this.

              Will appreciate your advice again.

              Thank you

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

                @phusy012 Assuming that you node and server are close-by, packet loss due to poor reception is unlikely. So it might still be, that the channel configuration of node and server do not match, and sometimes the node uses channels at which the server does not listen.

                1 Reply Last reply Reply Quote 0
                • P Offline
                  phusy012
                  last edited by phusy012

                  This post is deleted!
                  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