-->
Page 1 of 2

Restart ESP8266 from code

PostPosted: Fri Jan 08, 2016 12:10 pm
by dhovden
Building an app which uses the MySQL connector to send various measured data to a MySQL database. Works well but at times the MySQL connection goes away and refuses to return, the only way to get it back is a hard reset of the ESP8266 (in the form of an AdaFruit Huzzah).

Now, I would like to detect this in software and issue a restart from the code. This is what I'm using now to restart:

void soft_reset() {
pinMode(0,OUTPUT);
digitalWrite(0,1);
pinMode(2,OUTPUT);
digitalWrite(2,1);

ESP.restart();
}

But it doesn't work, at least not completely. The ESP8266 stops, sends some weird characters to the serial monitor but that's it: no restart.

Setting GPIO0 and 2 high, read that at https://github.com/esp8266/Arduino/issues/793, not sure if it's correct.

Anyway, does anyone know a way to restart the ESP8266 from code that actually works? Or am I just missing something?

Re: Restart ESP8266 from code

PostPosted: Fri Jan 08, 2016 5:50 pm
by martinayotte
ESP.reset() is working fine for me ...

But maybe you should look at the real solution with your MySQL server with the ESP.
Are you doing some kind of TCPClient to the server ? you can probably add a timeout there...

Re: Restart ESP8266 from code

PostPosted: Sat Jan 09, 2016 6:06 am
by Barnabybear
Hi, I would bet that for some reason GPIO 2 it not high when the restart takes place and the ESP is trying to boot into the wrong mode.

Re: Restart ESP8266 from code

PostPosted: Wed Aug 10, 2016 2:54 pm
by paulfer
martinayotte wrote:ESP.reset() is working fine for me ...

But maybe you should look at the real solution with your MySQL server with the ESP.
Are you doing some kind of TCPClient to the server ? you can probably add a timeout there...


I found this...https://github.com/esp8266/Arduino/issues/1722

You need to manually restart after flashing via serial.

Then it works. For me at least.