Page 1 of 1

[SOLVED]Issue with sending data to webserver

Posted: Fri Sep 01, 2017 11:19 pm
by rpi_nerd
Murphy's law seems to strike again for me. My current project is simply sending some temperature data to my Pi with my Wemos D1 mini. I finally got everything working smoothly, or so I thought. After an hour or two of running a loop that reads the temp sensors and sends the readings to the webserver, it crashes with this error:

Code: Select all

File "esp8266temptest4.py", line 117, in go
File "esp8266temptest4.py", line 110, in send_data
File "urequests.py", line 104, in post
TypeError: unexpected keyword argument 'crc8'
my function that sends the temperature readings:

Code: Select all

def send_data():
		url = 'http://[webserveripaddress]/php/rsensor.php'
		headers = {'Content-Type': 'application/x-www-form-urlencoded'}
		datas = "data=" + str(basic_temp) + "&" + "data2=" + str(advanced_temp)
		urequests.post(url, data=datas, headers= headers)


Re: Issue with sending data to webserver

Posted: Sat Sep 02, 2017 12:47 am
by fangis
It's funny, I think I had a similar, or the same problem, yesterday when I was trying to use urequests.
From what I have read, it looks like urequests leaves the connection open, it's up to you to close it, or the loop will keep opening sockets until it crashes.
What solves the problem so far to me is something like this:
r = urequests.get(data)
r.close()

Re: Issue with sending data to webserver

Posted: Sat Sep 02, 2017 2:57 am
by rpi_nerd
Thanks for the suggestion, fangus. I'll have to give it a try. It finally crashed again but it now gave me a different error:

Code: Select all

File "esp8266temptest4.py", line 110, in send_data
NameError: local variable referenced before assignment
It's referring to the last line in my function in my OP.

Re: [SOLVED]Issue with sending data to webserver

Posted: Thu Sep 07, 2017 11:49 am
by rpi_nerd
Fangus, your suggestion worked. It's been running for a few days now without any crashes.