Pages: [1]   Go Down
Author Topic: Software Reset with WiFi Shield  (Read 509 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, guys

I would like to be able to reset my Arduino WiFi Shield when the connection is dropped. I am currently using an Arduino R3 board. I have used the below procedure this works in resetting to the beginning of code however the WiFi Shield does not want to connect again after this code is run and I must re-upload the sketch

I call the function softReset when connection fails, this restarts arduino to beginning of sketch
Quote
void softReset(){
asm volatile ("  jmp 0");
}

then I use http://arduino.cc/en/Tutorial/EEPROMClear , to clear memory (1024 because arduino has this much eeprom http://arduino.cc/en/Main/arduinoBoardUno
Quote
for (int i = 0; i < 1024; i++)
    EEPROM.write(i, 0);
Logged

Offline Offline
Full Member
***
Karma: 4
Posts: 187
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try this

void(* resetFunc) (void) = 0

call
resetFunc();

Software reset not reliable in arduino case. You can also do it by WDT
Logged

From Idea To Invention

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 64
Posts: 2100
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Also, don't destroy your eeprom cos your wifi disconnected.

Code:
for (int i = 0; i < 1024; i++){
  if( EEPROM.read(i) != 0 ){
    EEPROM.write(i, 0);
  }
}

I'm not sure if EEPROM.write does this automatically, but it would be worth checking.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the help but,

Unfortunately the above reset function does not work. The code will reset and go back to the beginning on the program however, it will not reconnect to the WiFi network once the Arduino gets to that line of code. 
Logged

Offline Offline
Full Member
***
Karma: 4
Posts: 187
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Without seeing your code it's really difficult to help you. smiley-cool

Did you call WiFi.disconnect() before calling the reset function.
Logged

From Idea To Invention

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Jumping to address 0 does not do a hardware reset. Even if you did a hardware reset using the watchdog timer that will almost certainly not reset the WiFi shield.
Logged

Pages: [1]   Go Up
Jump to: