ESP NOW initialization crashes the program

Hi all,
I wanted to use ESP-NOW for a project with the ESP32 thing, but simply calling esp_now_init() crashes the program and causes the guru meditation error.

I tried running an empty project, and it does not cause this error.

It might be incompatible with one of the peripherals I am using… I am using an I2C port, an SPI port and the ESP-PROG for debugging.

Any idea or reference for limitations for ESP-NOW that could explain this? I was thinking I should just use BLE instead but it looks more complicated to use between 2 ESP32 devices.

my .ini just in case:

[env:esp32thing]

platform = espressif32
board = esp32thing
framework = arduino

; ###############################################################

; ESP32-PROG Environment (remove if uploading directly to ESP32)

; ###############################################################

monitor_speed = 115200  
debug_tool = esp-prog
debug_speed = 12000
debug_init_break = tbreak setup
upload_protocol = esp-prog
upload_port = COM14
 

; board_build.mcu = esp32
; board_build.f_cpu = 240000000L

; ###############################################################

build_flags =

    -DTFT_MOSI=23
    -DTFT_SCLK=18
    -DUSER_SETUP_LOADED=1

    -DST7789_DRIVER=1
    -DTFT_WIDTH=240
    -DTFT_HEIGHT=240

    -DST7789_GREENTAB2=1

    -DTFT_RST=2

    -DTFT_CS=-1

    -DTFT_DC=4

    -DLOAD_GLCD=1

    -DLOAD_FONT2=1

    -DLOAD_FONT4=1

    -DLOAD_FONT6=1

    -DLOAD_FONT7=1

    -DLOAD_FONT8=1
    -DLOAD_FONT8N=1
    -DLOAD_GFXFF=1
    -DSMOOTH_FONT=1
    -DSPI_FREQUENCY=27000000

   

; ###############################################################

; Project Libraries

; ###############################################################

lib_deps = 
    bodmer/TFT_eSPI@^2.3.66
    khoih-prog/ESP32TimerInterrupt@^1.0.3
    pololu/VL53L1X@^1.3.0

Did you make sure to disconnect from regular WiFi first? Otherwise ESP-NOW can’t work.

You should try the above reference sketch from the Arduino-ESP32 to check the functionality, with the matching master sketch.

1 Like

My bad! I should have read the ESP NOW guide first. I hadnt started wifi, so esp now init was probably using an uninitialized pointer somewhere and caused a memory failure. It works now, thanks!