diff --git a/src/utility/EspDrv.cpp b/src/utility/EspDrv.cpp index 76b1a61..b3f406f 100644 --- a/src/utility/EspDrv.cpp +++ b/src/utility/EspDrv.cpp @@ -72,6 +72,14 @@ void EspDrv::wifiDriverInit(Stream *espSerial) LOGDEBUG(F("> wifiDriverInit")); EspDrv::espSerial = espSerial; + +#ifdef WL_HARD_RESET_PIN + // Hard reset the ESP8266 to get it into a defined state + pinMode(WL_HARD_RESET_PIN, OUTPUT); + digitalWrite(WL_HARD_RESET_PIN, LOW); + delay(500); + digitalWrite(WL_HARD_RESET_PIN, HIGH); +#endif bool initOK = false; @@ -115,8 +123,17 @@ void EspDrv::reset() { LOGDEBUG(F("> reset")); +#ifdef WL_HARD_RESET_PIN + // Issue a hard reset + digitalWrite(WL_HARD_RESET_PIN, LOW); + delay(500); + digitalWrite(WL_HARD_RESET_PIN, HIGH); + delay(2500); +#else + // Issue a soft reset sendCmd(F("AT+RST")); delay(3000); +#endif espEmptyBuf(false); // empty dirty characters from the buffer // disable echo of commands diff --git a/src/utility/EspDrv.h b/src/utility/EspDrv.h index 5c782d9..5ffe54a 100644 --- a/src/utility/EspDrv.h +++ b/src/utility/EspDrv.h @@ -25,7 +25,14 @@ along with The Arduino WiFiEsp library. If not, see #include "RingBuffer.h" - +/* + * Pin for ESP8266 hard reset + * Connect this to the ESP8266's CH_PD line (taking care of the voltage + * differential, either through a converter or through a resistor bridge, + * just like you did for the ESP8266's RX line) + * If undefined, we will be relying entirely on soft reset (AT+RST) + */ +//#define WL_HARD_RESET_PIN 10 // Maximum size of a SSID #define WL_SSID_MAX_LENGTH 32