Sending sensor data to server using LoRa
-
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
-
@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.
-
@Archana-Kadam Did you find the problem for this one? I have the same problem on line 58
-
@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: -1Please reply as soon as possible. Your help will be appreciable.
-
@archana-kadam
@seb already answered your question:@seb said in Sending sensor data to server using LoRa:
just urequests.py, you also need to patch line 53 to be:
ai = usocket.getaddrinfo(host, port)
-
@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 givenI have attached the code again please check and let us know.
Thank You
-
@archana-kadam
will be good if you show us the real code
in attached - line 23 is simpleresponse.close()
also do not concat data in every loop - you eat memory fastly
changedata +=
todata =
-
@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 givenPlease reply as soon as possible.
-
just urequests.py, you also need to patch line 53 to be:
ai = usocket.getaddrinfo(host, port)
-
@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
-
Did you provide the urequests library file? If not you will need to get this and put it in your projects lib folder