Source: https://mokxi.com/errors/espnow-h-no-such-file-or-directory
Updated: 2026-11-16

Home / Errors
Arduino build error

# fatal error: espnow.h: No such file or directory

ESP-NOW sends small packets between ESP boards with no router. Its header is espnow.h on an ESP8266 and esp_now.h on an ESP32.

Try the fixed sketch in Mokxi See the causes

- Build error
- 2 common causes

The message

## What the Arduino IDE prints

Output window

A sketch written for one fails on the other, and on any board without WiFi.

Mokxi's compiler, clang, words it as 'espnow.h' file not found.

Causes

## The 2 usual causes with the fix

### 1The board is not an ESP8266

espnow.h is the ESP8266 header. Choose an ESP8266 board. In Mokxi, ESP-NOW is simulated between the ESP boards on the canvas.

Broken

Fixed

Mokxi’s build tab says: espnow.h is the ESP8266 core's ESP-NOW

Try this fix in Mokxi

### 2An ESP8266 sketch is built for an ESP32

The ESP32 uses esp_now.h, with an underscore, and a different callback signature. Change the include, then the calls, following the ESP32 ESP-NOW example.

- Replace #include <espnow.h> with #include <esp_now.h> and #include <WiFi.h>.
- Use esp_now_peer_info_t to add a peer, and esp_now_add_peer(&peerInfo).
- Open File, Examples, ESP32, ESPNow in the Arduino IDE for the current calls.

FAQ

## Questions and answers

### Is ESP-NOW the same on ESP32 and ESP8266?

The idea is the same. The header, the callback signatures and the peer calls differ, so code does not carry over unchanged.

### Do I need a router for ESP-NOW?

No. The boards talk to each other directly, as long as they use the same WiFi channel.

### Can I test ESP-NOW in Mokxi?

Yes. Put two ESP boards on the canvas, and the packets one sends reach the other.

Next

## More errors and the longer guide

- fatal error: WiFi.h: No such file or directory
- fatal error: BlynkSimpleEsp8266.h: No such file or directory

The longer guide to this error All Arduino errors
