Restart ESP8266 from code
Posted: Fri Jan 08, 2016 12:10 pm
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?
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?