ESP-NOW: invalid conversion in esp_now_register_recv_cb

  • ESP32 core 3.x

You may see

error: invalid conversion from 'void (*)(const uint8_t*, const uint8_t*, int)
to 'esp_now_recv_cb_t'

Why it happens

  • In core 3.x the receive function gets an esp_now_recv_info_t instead of only the sender's address.

How to fix it

  1. Change the function to void onReceive(const esp_now_recv_info_t *info, const uint8_t *data, int len).
  2. Use info->src_addr where the code used mac.
  3. Or install ESP32 core 2.0.17.

It worked if: Verify passes and the second board receives.

Seen in a real run (some lines are close variants of it). Produced with Arduino CLI 1.5.1 and ESP32 core 3.1.3. Sources: Espressif: ESP-NOW.

Didn't help? Search another error or ask us.