bug: instruction esp_now_send causes ESP8266MOD to crash due to hardware watchdog reset

LozziExEspExp
Posts: 1
Joined: Thu Sep 14, 2023 9:28 am

bug: instruction esp_now_send causes ESP8266MOD to crash due to hardware watchdog reset

Postby LozziExEspExp » Thu Sep 14, 2023 9:34 am

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.

Code: Select all

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <espnow.h>

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;
}

Code: Select all

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���b�r��l⸮nb⸮n�l`�⸮�r�l⸮l�⸮⸮
0

Who is online

Users browsing this forum: No registered users and 6 guests