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 sensor data to server using LoRa

    Scheduled Pinned Locked Moved MicroPython
    lorafipypysense
    11 Posts 6 Posters 2.2k Views 6 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.
    • A Offline
      Archana Kadam
      last edited by

      Hello,

      We are trying to send data from fipy to sever using urequests, but getting an error. We are running code in atom.

      import urequests
      response = urequests.get("http://localhost/server.php?data="+msg)
      response.close()

      Error Message:
      Traceback (most recent call last):
      File "<stdin>", line 12, in <module>
      ImportError: no module named 'urequests'

      Thank you

      1 Reply Last reply Reply Quote 0
      • sebS Offline
        seb
        last edited by

        Did you provide the urequests library file? If not you will need to get this and put it in your projects lib folder

        A 1 Reply Last reply Reply Quote 0
        • A Offline
          Archana Kadam @seb
          last edited by

          @seb
          https://github.com/micropython/micropython-lib/tree/master/urequests
          We have used file from above link , whether we need to put only urequest.py file in lib folder or we need to copy the entire folder into the lib.

          Thank you

          sebS 1 Reply Last reply Reply Quote 0
          • sebS Offline
            seb @Archana Kadam
            last edited by

            @archana-kadam

            just urequests.py, you also need to patch line 53 to be:

                ai = usocket.getaddrinfo(host, port)
            
            A 1 Reply Last reply Reply Quote 0
            • A Offline
              Archana Kadam @seb
              last edited by

              @seb
              Hello,

              We have included urequest.py file into lib folder and trying to send the sensor reading to server using attached code, but getting below error and im attaching the code file.0_1523702658240_light.py

              Traceback (most recent call last):
              File "<stdin>", line 23, in <module>
              File "urequests.py", line 53, in request
              TypeError: function takes 2 positional arguments but 4 were given

              Please reply as soon as possible.

              L 1 Reply Last reply Reply Quote 0
              • L Offline
                livius @Archana Kadam
                last edited by livius

                @archana-kadam
                will be good if you show us the real code
                in attached - line 23 is simple response.close()

                also do not concat data in every loop - you eat memory fastly
                change data += to data =

                think about people first, then computers

                A 1 Reply Last reply Reply Quote 0
                • A Offline
                  Archana Kadam @livius
                  last edited by

                  @livius
                  Hello,

                  Previously shared code was only the actual code where we are getting error, error saying that two places where error exists i,e line 23 and File "urequests.py", line 53, in request. May be line 23 error is not at response.close(), it is at, response = urequests.request("GET","http://localhost/ksn/server.php?data="+ str(data))

                  Traceback (most recent call last):
                  File "<stdin>", line 23, in <module>
                  File "urequests.py", line 53, in request
                  TypeError: function takes 2 positional arguments but 4 were given

                  I have attached the code again please check and let us know.

                  Thank You

                  S 1 Reply Last reply Reply Quote 0
                  • S Offline
                    Sympatron @Archana Kadam
                    last edited by

                    @archana-kadam
                    @seb already answered your question:

                    @seb said in Sending sensor data to server using LoRa:

                    @archana-kadam

                    just urequests.py, you also need to patch line 53 to be:

                        ai = usocket.getaddrinfo(host, port)
                    
                    A 1 Reply Last reply Reply Quote 0
                    • A Offline
                      Archana Kadam @Sympatron
                      last edited by Archana Kadam

                      @sympatron
                      Hello,

                      We have already included the urequests.py file in lib folder as well as changed the line 53 to
                      ai = usocket.getaddrinfo(host, port)

                      But still getting the below error with the same code which is shared previously.

                      Traceback (most recent call last):
                      File "<stdin>", line 47, in <module>
                      File "urequests.py", line 100, in request
                      File "urequests.py", line 58, in request
                      OSError: -1

                      Please reply as soon as possible. Your help will be appreciable.

                      L 1 Reply Last reply Reply Quote 0
                      • L Offline
                        Lonefish @Archana Kadam
                        last edited by

                        @Archana-Kadam Did you find the problem for this one? I have the same problem on line 58

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

                          @Lonefish Do you actually have a valid IP connection between the FiPy and the server? The topic of the subject talks about LoRa, but you can't perform HTTP requests over LoRa, you need to go through a gateway for that.

                          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