The use of the ESP8266 in the world of IoT

User avatar
By IsaiasDg
#36111 Hi everyone,
I'm having an unusual issue with the ESP module working as web client and I have looked in some places, and I still haven't found answer. The issue is the following: the ESP is working as web client, sending and reading data from a database hosted in a web server. The module works fine for hours, sometimes only minutes,and there's a moment the module no longer has communication with server. Firstly, I thought it was wifi connection issue, but module remains connected to wifi after lost communication with server. I have been debugging module searching for any issue, but nothing. It seems the issue is in the loop() function where I'm reading data from database almost every second. I'm using ARDUINO/ESP8266 IDE 1.6.7.
Any idea what's happening?

Thanks in advance
User avatar
By kenn
#36196
IsaiasDg wrote: It seems the issue is in the loop() function where I'm reading data from database almost every second.
Any idea what's happening?


Sounds like you're simply working it too hard. If one response hangs for over a second... how are you handling that in the code?

You could try putting in a trap around the request; if the request fails X times in a row, then stop and start the connection.
User avatar
By IsaiasDg
#36198
kenn wrote:
IsaiasDg wrote: It seems the issue is in the loop() function where I'm reading data from database almost every second.
Any idea what's happening?


Sounds like you're simply working it too hard. If one response hangs for over a second... how are you handling that in the code?

You could try putting in a trap around the request; if the request fails X times in a row, then stop and start the connection.

Hi kenn,

Let me explain you how the program works:
in the loop() function, I'm connecting the client (esp) to server, then client sends a request to server and after that the client reads the response from server and checks if buffer has data or is empty, if client is empty this stops and the loop executes again. Next, the module analyzes the response and then identifies a portion of it to execute a function, that's all. This process takes around 1 sec. I tried to put a trap, like you said (if the request fails X times...etc) but the issue is that the loop() function doesn't execute anymore, therefore the trap doesn't work, it's for that reason that I think the issue is in the loop function. When I reset the esp, this works again for a moment, like I mentioned. Any idea?

Thanks,
Isaiasdg
User avatar
By kenn
#36282
IsaiasDg wrote:Hi kenn,

Let me explain you how the program works:
in the loop() function, I'm connecting the client (esp) to server, then client sends a request to server and after that the client reads the response from server and checks if buffer has data or is empty, if client is empty this stops and the loop executes again. Next, the module analyzes the response and then identifies a portion of it to execute a function, that's all. This process takes around 1 sec. I tried to put a trap, like you said (if the request fails X times...etc) but the issue is that the loop() function doesn't execute anymore, therefore the trap doesn't work, it's for that reason that I think the issue is in the loop function. When I reset the esp, this works again for a moment, like I mentioned. Any idea?


Sorry, no further ideas.... except maybe to wrap the call to loop() itself, or wrap everything inside loop, that would catch any failure in the loop, which assumes that all failures would throw out something catchable...