Pages: [1]   Go Down
Author Topic: Retry 10 sec later if network fail to connect to router  (Read 454 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry if this question have already been ask but i didn't find the awnser. The problem is that if we lost the electricity, the router take more time to boot then the arduino so it fail to make a connection and i need to do a manual reset for it. Is therr a way or a command to reset the arduino if network fail to initialyse?

Thanks in advance
Mike
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Better to check for successful initialisation and retry until it succeeds.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49310
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How to test for successful connection depends on whether you are using an Ethernet shield or a WiFi shield.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I use the ethernetshiel. I use the
Code:
ethernet.begin(mac, ip);
in the void setup. And i use
Code:
if(ethernet.begin(mac) == o)
could i put there a reset sketche and if so, how to??

Thanks
Logged

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 114
Posts: 4257
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No need to reset the Arduino.  If the connection fails just keep trying until it succeeds as has been suggested.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know what you mean but it's in the void setup, how could you loop it in the void setup? Could i initialise the ethernet from the void loop??
Logged

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 114
Posts: 4257
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

While (test for connection fails);
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49310
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
how could you loop it in the void setup?
Just like you would "loop it" in the loop() function.

Code:
while(Ethernet.begin(mac, IP) == 0)
{
   // do nothing
}
Logged

Pages: [1]   Go Up
Jump to: