Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for hard reset through dedicated pin. #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/utility/EspDrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/utility/EspDrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down