esp8266 / esp8266/Arduino

instruction `esp_now_send` causes ESP8266MOD to crash due to hardware watchdog reset

Open
#8,989 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

### Basic Infos

- [x] This issue complies with the [issue POLICY doc](https://github.com/esp8266/Arduino/blob/master/POLICY.md).
- [x] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [x] I have tested that the issue is present in current master branch (aka latest git).
- [x] I have searched the issue tracker for a similar issue.
- [x] If there is a stack dump, I have decoded it.
- [x] I have filled out all fields below.

#### Platform

- Hardware: [ESP8266MOD]
- Core Version: [Release 3.1.2 - Mar20]
- Development Env: [Arduino IDE]
- Operating System: [Windows]

### Settings in IDE

- Module: [Wemos D1 R2]
- Flash Mode: [qio|dio|other]
- Flash Size: [4MB]
- lwip Variant: [v2 Lower Memory]
- Reset Method: [ck|nodemcu]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz]
- Upload Using: [SERIAL]
- Upload Speed: [921600]

### Problem Description

Using instruction `esp_now_send` causes ESP8266MOD to crash due to hardware watchdog reset.
I also found a workaround for that, that is to setup the GPIO16 as OUTPUT during setup (i.e. `pinMode(16, OUTPUT)` ), but I don't realize why this happens and how this could be related to `esp_now_send` instruction.

### [MCVE](https://stackoverflow.com/help/mcve) Sketch
```
#include
#include
#include

uint8_t targetAddr[] = {0x8C, 0xAA, 0xB5, 0xB5, 0x90, 0x60};

byte myData = 1;
int cnt = 0;

void OnDataSent(uint8_t *mac, uint8_t sendStatus)
{
if (sendStatus == 0) {
Serial.println("Delivery success");
}
else {
Serial.println("Delivery fail");
}
}

void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
if (esp_now_init() != 0) {
Serial.println("Error initializing ESP-NOW");
return;
}
esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER);
esp_now_register_send_cb(OnDataSent);
esp_now_add_peer(targetAddr, ESP_NOW_ROLE_SLAVE, 1, NULL, 0);
}

void loop()
{
if (cnt % 10000 == 0) {
Serial.println(cnt);
esp_now_send(targetAddr, (uint8_t *) &myData, sizeof(myData));
}
cnt += 1;
}
```
### Debug Messages

```

ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 3424, room 16
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8
tail 0
chksum 0x2b
csum 0x2b
v00042e70
~ld
⸮⸮n⸮r⸮⸮n|⸮ l ⸮ l`b brl⸮nb⸮n l`⸮rl⸮l⸮ ⸮
0

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.