I'm using an example sketch file for connecting ArduinoCloud - the connection is lost after about one day. there are connection retries but they all fail. I tried to downgrade the ESP S3 Firmware version to previos version and install again latest version, but it didin't help.
I tried adding a board reset upon cloud discconection but this doesn't recover the connection.
Any idea?
Adding the code - as you can see, it is the same code as in the arduino cloud connection example. About once a day I'm getting disconnected from the cloud and I get prints over the terminal for connection retries.
__________________________________________________________
#include "thingProperties.h"
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
// Your code here
}
The current workaround, is to reset the board on network discconnection by disconnection handler, I plan to add also a timer to do the reset only after 60 seconds of connection loss:
Are you determining that this happened from the messages that are printed by the board in Serial Monitor? If so, please post the full and exact text of those messages in a forum reply here (along with the information already requested by @Delta_G). It might be that the specific details provided by the Serial Monitor messages might help us to better understand the problem.
Thanks for your feedback, I don't have the terminal logs as the board is currentelly plugged in to power supply and not to a PC, the problem is that thess diconnections happen after more than 20 hours, so I need to connect the board to the PC for a long period of time...
I will try to provide a capture soon...
It might be a DHCP timeout,
many routers have a default of 24 hours which happens to be 1 day
Check your router and if DHCP lease is set to max 1 day, change it to 1 hour.
Then you know if it was the cause.
I think they would be useful. To start with, they will tell us whether the problem is with the connection to the Wi-Fi access point (as has been hypothesized by the other helpers), or only with the connection to the Arduino Cloud server.
If you need to gather serial output produced over a long period of time, you might find that the Arduino Cloud Editor Serial Monitor is not well suited for the task. In that case, you can use a standalone terminal emulator application that has the capability to save the received data to a file. I can recommend the free open source PuTTY for this purpose:
Hi @ptillisch, thanks for the good advice.
I have connected a secureCRT terminal and I captured a very interesting log sessionArduinoR4.log (88.7 KB)
It looks like that device is disconnected from the WiFI router without any reason (it is located in a good distance from the router and I have other 27 clients connected without any issues):
Connection to "HomeV" lost.
Attempting reconnection
WiFi.status(): 0
Current WiFi Firmware: 0.4.1
Connection to "HomeV" failed
Retrying in "500" milliseconds
Connected to "HomeV"
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to iot.arduino.cc:8883 Error: -2
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to iot.arduino.cc:8883 Error: -2 ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to iot.arduino.cc:8883 Error: -2 Connection to "HomeV" lost. Attempting reconnection WiFi.status(): 0 Current WiFi Firmware: 99.99.99
Connection to "HomeV" failed
Retrying in "500" milliseconds
Connection to "HomeV" failed
Retrying in "500" milliseconds
Connection to "HomeV" failed
Retrying in "500" milliseconds
Connection to "HomeV" failed
Retrying in "500" milliseconds
Connection to "HomeV" failed
Retrying in "500" milliseconds
Connection to "HomeV" failed
Retrying in "500" milliseconds...
During this time when I try to ping the Arduino R4 I get unstable ping replies:
Pinging 192.168.0.203 with 32 bytes of data:
Reply from 192.168.0.203: bytes=32 time=66ms TTL=255
Reply from 192.168.0.203: bytes=32 time=72ms TTL=255
Request timed out.
Reply from 192.168.0.203: bytes=32 time=149ms TTL=255
Request timed out.
Reply from 192.168.0.203: bytes=32 time=267ms TTL=255
Reply from 192.168.0.203: bytes=32 time=87ms TTL=255
Reply from 192.168.0.203: bytes=32 time=99ms TTL=255
Reply from 192.168.0.203: bytes=32 time=126ms TTL=255
Reply from 192.168.0.203: bytes=32 time=219ms TTL=255
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.0.203: bytes=32 time=129ms TTL=255
Request timed out.
Reply from 192.168.0.203: bytes=32 time=39ms TTL=255
Reply from 192.168.0.203: bytes=32 time=49ms TTL=255
Reply from 192.168.0.203: bytes=32 time=57ms TTL=255
After a long while I pressed the reset button on the board, but it didn't help:
ArduinoIoTCloudTCP::begin could not initialize secure element.
***** Arduino IoT Cloud - configuration info *****
Device ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
MQTT Broker: iot.arduino.cc:8883
WiFi.status(): 0 Current WiFi Firmware: 99.99.99
Connection to "HomeV" failed
Retrying in "500" milliseconds
Connection to "HomeV" failed
Retrying in "500" milliseconds
Connection to "HomeV" failed
Retrying in "500" milliseconds
Connection to "HomeV" failed
Retrying in "500" milliseconds
Connection to "HomeV" failed
Retrying in "500" milliseconds
Connection to "HomeV" failed
Retrying in "500" milliseconds
It was only after the second reboot that the reconnection was successful:
***** Arduino IoT Cloud - configuration info *****
Device ID: 0b3d0a66-13f6-44c4-8fa4-1592730097d0
MQTT Broker: iot.arduino.cc:8883
WiFi.status(): 0
Current WiFi Firmware: 0.4.1
Connected to "HomeV"
Connected to Arduino IoT Cloud
Thing ID: 6da65c2e-2edf-46d2-b186-be7792441e9a
It is strange but sometimes I get Current WiFi Firmware: 99.99.99 , I can't explain why...
Hi @SurferTim, I can't see why the disconnections happen when examining the router logs. Furthermore I do think that the "bad" WiFi Firmware version is an indication that there is something wrong in the system - so I have added the code below to loop()
This ugly workaround is rebooting the board and this is the only workaround that I could find that really works for me...
I have also tried using a second Arduino Uno R4 WiFi board, and it happes on it too. So this problem is not related to a specific defective board and I assume that others my suffer from it.
No, the disconnection is from the WiFi router, I can expect that there are disconnections and in some cases the reconnection that is triggered in the code is working.
But my problem is that about once a day the system gets into a situation that the reconnection is not able to restore and continues retrying endlessly.
When this happens, I noticed that the WiFi FW version is :99.99.99 (probably default initial value or garbage received and masked in code to max possible value) and the only way to recover is a board reset.
I assume that there is a bug in the WiFi driver init process that sometimes fails to reload or re-init the WiFi SW driver code.
It could be the firmware. Hopefully somebody with a really good router can troubleshoot this.
I had problems years ago with the ethernet shield. Every day it would disconnect. Users here told me the ethernet shield was "just a toy". Come to find out it was because I was not calling "Ethernet.maintain()", which causes the shield to renew it's DHCP lease. I could watch on my router the second the lease expired, I was no longer able to connect.
Edit: Have you considered trying a static network config? This function is available in the WiFiS3 library. Use an IP outside the DHCP range. Some routers don't allow static IPs in the DHCP range.
/* Change IP configuration settings disabling the DHCP client
*
* param local_ip: Static IP configuration
* param dns_server: IP configuration for DNS server 1
* param gateway: Static gateway configuration
* param subnet: Static Subnet mask
*/
void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);
Hi @SurferTim, yes I also tried using static IP and adjusted my router configuration to support that, unfortunately it didn't help,
My problem is not related to DHCP.