0

I'm using an ESP8266 (NodeMCU v3). I want to set a PIN high if a soft wdt reset occurs (not expecting one). Is there a way I can do that?

Can I attach something on TX pin of the board and watch for crash dump? Maybe another Arduino?

3
  • Only after a crash? After normal reboot, the pin start LOW?
    – user31481
    Commented Feb 7, 2018 at 16:26
  • Look this link: megunolink.com/articles/…
    – user31481
    Commented Feb 7, 2018 at 16:34
  • @LookAlterno that's a very useful article and program but it's pretty architecture specific. I don't think there is any way to use it with ESP8266 without an almost complete rewrite of the code.
    – per1234
    Commented Feb 7, 2018 at 22:03

2 Answers 2

1

The ESP provides a reset reason API, which lets you differentiate between a crash and a normal reset:

extern "C" {
  #include "user_interface.h"
}

const char * const RST_REASONS[] =
{
  "REASON_DEFAULT_RST",
  "REASON_WDT_RST",
  "REASON_EXCEPTION_RST",
  "REASON_SOFT_WDT_RST",
  "REASON_SOFT_RESTART",
  "REASON_DEEP_SLEEP_AWAKE",
  "REASON_EXT_SYS_RST"
};

// .. in setup():

const rst_info * resetInfo = system_get_rst_info(); //populate reset info
String diag = String(RST_REASONS[resetInfo->reason]); // turn enum index to string

if(diag == "REASON_SOFT_WDT_RST") digitalWrite(TX, HIGH);// check string, take action
0

The ESP8266 should hold the pin LOW when it is active, letting it go high then signals that the program has crashed.

2
  • 1
    Can you elaborate on the matter? I need something like that for a project.
    – user31481
    Commented Feb 9, 2018 at 21:33
  • It sounds like the idea is to drive the pin low when operating properly, but rely on the WDT-triggered reset making it a high impedance input which can be overridden by an external pullup resistor. Commented Feb 11, 2018 at 3:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.