• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESPNOW: Peer Interface is invalid

Q&A Forum › Category: ESP32 › ESPNOW: Peer Interface is invalid
0 Vote Up Vote Down
Leo Eyck asked 5 years ago

Hi,

I’ve been trying work thru the ESP-NOW two way Communication tutorial as set out via your em titled “ESP-NOW, Wi-Fi Communication, New ESP32-CAM Boards, and More [RNT Recap]”.
However despite many checks both hardware and code I keep getting the following error(s).

ESPNOW: Peer interface is invalid

Failed to add pair.

So far I’ve been unable to work out what this actually means and where to look for the solution. The error message does have a prefix “E(154)”, but this can change at different attempts (even without having changed anything)

Is it possible to get more info on what might be causing this? I’ve tried other (more simplified code setups) but keep getting the same error even with different hardware. I’m at a loss to know where to look next.

Is there a simple setup that allows me to test and diagnose this issue.

Thanks and regards,

Leo

  • ESP-NOW Two-Way Communication Between ESP32 Boards
  • Getting Started with ESP-NOW (ESP32 with Arduino IDE)
  • Getting Started with ESP-NOW (ESP8266 NodeMCU with Arduino IDE)
27 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi Leo.

You can try the default ESP-NOW example.

In your Arduino IDE, go to File > Examples> ESP32 > ESPNow> Basic

And upload the “Master” example to one board and the “Slave” example to the other.

See if you can get them working with these examples.

Also, make sure that you have your ESP32 boards add-on updated.

Regards,
Sara

0 Vote Up Vote Down
Leo Eyck answered 5 years ago

Thanks Sara.
After posting this question I continued to look for possible answers and wondered whether I didn’t have the library ESP-Now loaded in my IDE. After much looking I found library with a simple sample sketch which after installing allowed me to test the function successfully. The library in question was WifiEspNow. 
However even with this I’m still getting the ‘peer interface is invalid’ error compiling the RNT sketch.
Will keep working on it – can’t see any typo errors. 
PS: not sure what you mean by ‘ESP32 boards add-on updated’
Thanks again.
Regards,
Leo
 

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi.
I don’t understand why you’re having that issue. I’ve searched for a while and didn’t find any solution.
Having the ESP32 board add-on updated: go to Tools > Board > Boards Manager and search for ESP32.
Make sure you have the latest version installed. In my case, I have 1.04.

Regards,
Sara
 

0 Vote Up Vote Down
Steph answered 5 years ago

Assuming you have added the following URL in the Additional Boards Manager URL field of Preferences panel:

https://dl.espressif.com/dl/package_esp32_index.json


This field can of course contain other URLs, but they must be comma-separated.

0 Vote Up Vote Down
Leo Eyck answered 5 years ago

Thanks Sara and Stephane.
I looked up the ESP32 Basic examples and they work successfully. 
I than took up the suggestions you each suggested and resulted in a large download of esp32 related boards. 
At this stage I’ve been unable to retest the RNT ESP_Now tutorial due to time constraints but hope to do so soon. I’ll let you know how I go.
FYI, I hoping to be able to move away from using LoRa as a communication tool. Saves another component/element. Although LoRa has been working great for me on a number of projects.
Thanks again to you both.
Regards,
Leo
 

0 Vote Up Vote Down
Steph answered 5 years ago

As a matter of fact, I’m about to explore LoRa technology.
I have plans to set up a LoRaWAN gateway to allow my modules to communicate.
But I feel a little lost at the moment… I’m new to the field of electronics and microcontrollers!
But I’m passionate about it, and super-motivated.
Also, like you, I’m very interested in the ESP-Now protocol…

0 Vote Up Vote Down
Leo Eyck answered 5 years ago

Thanks for sharing that Stephane.
I use Lora and esp32s to monitor workshop doorway status remotely and water tank levels. These are each separate sets but I can see a possibility  of making them communicate in a LoRaWan gateway setup, having multiple Tx and a single monitoring Rx. 
While I had a background in Electronics and Computing (going as far back as when disk were still running with hydraulic and memory was in magnetic cores) I too  have felt somewhat little lost in this area. However it’s very satisfying and challenging – and great when you get a successfully completed project.
Good luck with your projects and enjoy.

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi Leo.
Then, let me know if you got our tutorial working.
Regards,
Sara

0 Vote Up Vote Down
Leo Eyck answered 5 years ago

Will do Sara.

0 Vote Up Vote Down
Leo Eyck answered 5 years ago

Hi Sara,
 
I’m afraid I’m still getting the same error after implementing your and Stephane’s suggestions. It’s not the hardware itself as I’ve used 3 different ESP vroom 32 boards. Also they work successfully in other projects as well as the basic examples without this error.
I’ve posted the error below, but it’s unlikely to be much help. I’m continuing to diagnose it further in the hope of finding the answer or a clue to one.
The program/sketch I’m using (with MAC addr changes) is the one included in the ‘Getting started with ESP-NOW (ESP32 with Arduino IDE). To find the mac addrs I used the sketch included.
TX error code:
18:55:24.035 -> load:0x3fff0018,len:4
18:55:24.035 -> load:0x3fff001c,len:952
18:55:24.035 -> load:0x40078000,len:6084
18:55:24.035 -> load:0x40080000,len:7936
18:55:24.035 -> entry 0x40080310
18:55:24.373 -> E (140) ESPNOW: Peer interface is invalid
18:55:24.373 -> Failed to add peer
18:55:24.373 -> Error sending the data
18:55:26.357 -> Error sending the data
18:55:28.373 -> Error sending the data
etc.
The Rx looks fine, it just sits there after start up  – no errors. To make sure it not stalled or going into hiding I’ve added a msg in the esp-now initialization to says it’s initializing, and that prints out fine. (not getting the ‘error initializing ESP-NOW msg).
I’ll keep working on it as I get time.
Thanks for your help thus far.
Regards,
Leo

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi Leo.
I have no idea why you’re getting that error.
Can you show me the line where you insert the peer mac address?

0 Vote Up Vote Down
Leo Eyck answered 5 years ago

Hi Sara,
The code is:
#include <esp_now.h>
#include <WiFi.h>
// REPLACE WITH YOUR RECEIVER MAC Address
uint8_t broadcastAddress[] = {0xB4, 0xE6, 0x2D, 0xEE, 0x61, 0x41};

// Structure example to send data
// Must match the receiver structure
typedef struct struct_message {
char a[32];
int b;
float c;
String d;
bool e;
} struct_message;
etc….
The mac address listed is for the receiver module I’m using.
The mac address is the only code I’ve changed (as required) of the tutorial code. Also the mac address was obtained as per the sketch in the tutorial. I believe it’s correct as it’s the same as obtained by the Basic examples you suggested and which work successfully.
Regards,
Leo

0 Vote Up Vote Down
Leo Eyck answered 5 years ago

Hi Sara,
 
I’ve done a bit more testing (without much success), but here are some results to compare.
First I’ve got results for the Examples, ESP32, ESPNow, MultiSlave, MAstyer/Slave test which was successful.
Result of Testing Sketch: Examples, ESP32, ESPNow, MultiSlave, Master & Slave
 
Master Monitor result:
 
11:03:11.724 -> Found 4 devices
11:03:11.771 -> 1: Slave:B4:E6:2D:EA:11:DD [B4:E6:2D:EA:11:DE] (-18)
11:03:11.771 -> 2: Slave:B4:E6:2D:EE:61:41 [B4:E6:2D:EE:61:42] (-19)
11:03:11.771 -> 2 Slave(s) found, processing..
11:03:11.771 -> Processing: B4:E6:2D:EA:11:DE Status: Already Paired
11:03:11.771 -> Processing: B4:E6:2D:EE:61:42 Status: Already Paired
11:03:11.817 -> Sending: 54
11:03:11.817 -> Send Status: Success
11:03:11.817 -> Last Packet Sent to: b4:e6:2d:ea:11:de
11:03:11.817 -> Last Packet Send Status: Delivery Success
11:03:11.864 -> Send Status: Success
11:03:11.911 -> Last Packet Sent to: b4:e6:2d:ee:61:42
11:03:11.911 -> Last Packet Send Status: Delivery Success
11:03:15.568 ->
Slave 1 Monitor result:
 
11:30:04.524 -> ets Jun  8 2016 00:22:57
11:30:04.524 ->
11:30:04.524 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
11:30:04.524 -> configsip: 0, SPIWP:0xee
11:30:04.524 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
11:30:04.524 -> mode:DIO, clock div:1
11:30:04.524 -> load:0x3fff0018,len:4
11:30:04.524 -> load:0x3fff001c,len:952
11:30:04.524 -> load:0x40078000,len:6084
11:30:04.524 -> load:0x40080000,len:7936
11:30:04.524 -> entry 0x40080310
11:30:04.759 -> ESPNow/Basic/Slave Example
11:30:04.853 -> AP Config Success. Broadcasting with AP: Slave:B4:E6:2D:EA:11:DD
11:30:04.853 -> AP MAC: B4:E6:2D:EA:11:DE
11:30:04.853 -> ESPNow Init Success
 
Slave 2 Monitor result:
 
11:31:19.180 -> ets Jun  8 2016 00:22:57
11:31:19.180 ->
11:31:19.180 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
11:31:19.180 -> configsip: 0, SPIWP:0xee
11:31:19.180 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
11:31:19.180 -> mode:DIO, clock div:1
11:31:19.180 -> load:0x3fff0018,len:4
11:31:19.180 -> load:0x3fff001c,len:952
11:31:19.180 -> load:0x40078000,len:6084
11:31:19.180 -> load:0x40080000,len:7936
11:31:19.180 -> entry 0x40080310
11:31:19.414 -> ESPNow/Basic/Slave Example
11:31:19.508 -> AP Config Success. Broadcasting with AP: Slave:B4:E6:2D:EE:61:41
11:31:19.508 -> AP MAC: B4:E6:2D:EE:61:42
11:31:19.508 -> ESPNow Init Success
As you can see there are 2 MAC addresses for each module (not quite sure what that’s about). I don’t believe they have anything to do with my problem though as no combination of these addresses works successfully.
I’ve also included the result of the MAC address finder included with the tutorial. This sketch however show up only one of the MAC addresses for each of the modules.
The MAC ADDR results using:
 
#include “WiFi.h”
 
void setup(){
  Serial.begin(115200);
  WiFi.mode(WIFI_MODE_STA);
  Serial.println(WiFi.macAddress());
}
 
void loop(){
 
}
 
As per tutorial.
 
Master monitor results:
 
11:45:21.777 -> ets Jun  8 2016 00:22:57
11:45:21.777 ->
11:45:21.777 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
11:45:21.777 -> configsip: 0, SPIWP:0xee
11:45:21.777 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
11:45:21.777 -> mode:DIO, clock div:1
11:45:21.777 -> load:0x3fff0018,len:4
11:45:21.777 -> load:0x3fff001c,len:952
11:45:21.777 -> load:0x40078000,len:6084
11:45:21.777 -> load:0x40080000,len:7936
11:45:21.777 -> entry 0x40080310
11:45:22.105 -> B4:E6:2D:EE:6C:A1
Slave 1 monitor results:
 
11:48:01.307 -> ets Jun  8 2016 00:22:57
11:48:01.354 ->
11:48:01.354 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
11:48:01.354 -> configsip: 0, SPIWP:0xee
11:48:01.354 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
11:48:01.354 -> mode:DIO, clock div:1
11:48:01.354 -> load:0x3fff0018,len:4
11:48:01.354 -> load:0x3fff001c,len:952
11:48:01.354 -> load:0x40078000,len:6084
11:48:01.354 -> load:0x40080000,len:7936
11:48:01.354 -> entry 0x40080310
11:48:01.635 -> B4:E6:2D:EA:11:DD
Slave 2 monitor results:
 
11:49:22.994 -> ets Jun  8 2016 00:22:57
11:49:22.994 ->
11:49:22.994 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
11:49:22.994 -> configsip: 0, SPIWP:0xee
11:49:22.994 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
11:49:22.994 -> mode:DIO, clock div:1
11:49:22.994 -> load:0x3fff0018,len:4
11:49:22.994 -> load:0x3fff001c,len:952
11:49:22.994 -> load:0x40078000,len:6084
11:49:22.994 -> load:0x40080000,len:7936
11:49:23.042 -> entry 0x40080310
11:49:23.323 -> B4:E6:2D:EE:61:41
 
I’m sort of stumped as to where to look next given that I have not been able to find out what the error ‘ ESPNOW: Peer interface is invalid’ actually means. I’d be surprised if it’s MAC Address related; I would expect just a ‘unable to pair’ or ‘pairing unsuccessful’ msg.
Do you know if the tutorial will work as is with an ESP8266, that would allow me to try whether it’s module type related. I’m currently using modules which have the WiFi ESP-Vroom-32 processor and which have been working well for every other project using RNT and other code.
Thanks and regards,
Leo

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi Leo.
I’m sorry, but I can’t find any explanation for your results. That’s indeed a very weird issue.
If you try the broadcast MAC address, what do you get?

uint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

ESP-NOW works with ESP8266, but there are some minor differences in the code. We’ll publish a tutorials for ESP-NOW with ESP8266 soon. Meanwhile, I have out of ideas of what might be causing that issue :/
Regards,
Sara

0 Vote Up Vote Down
Leo Eyck answered 5 years ago

Hi Sara,
I tried the broadcast MAC as one of the first attempts to fix this in case the problem was MAC addr related. Same error. Sorry I didn’t mention it before.
Thanks for trying though.
PS: Is there any clear/simple explanation of what the error means? I’ve been unable to find it. Does the error present before or after the attempting to connect to the Slave, ie. is it internal to the Master or the result of interaction between the Master and Slave? That might help to pin it down for further diagnostic work.
 
Thanks again for your help,
Regards,
Leo
 

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi Leo.
I saw something in a portuguese blog about this issue. I’m not sure if it work, but we can try.
It suggests that we cut this line from the setup()

  esp_now_peer_info_t peerInfo;

And past it before the loop() and before the setup().
 

0 Vote Up Vote Down
Leo Eyck answered 5 years ago

Thanks Sara, I’ll give it a go.

0 Vote Up Vote Down
Leo Eyck answered 5 years ago

Hi Sara,
BINGO!
Looks like you found the answer.
I placed a copy of the relevant line just before the setup() and commented out the original.
I’m now getting the following results from the Master:

22:00:04.517 -> Last Packet Send Status: Delivery Success
22:00:06.508 -> Sent with success
22:00:06.508 ->
22:00:06.508 -> Last Packet Send Status: Delivery Success
22:00:08.505 -> Sent with success
22:00:08.505 ->
22:00:08.505 -> Last Packet Send Status: Delivery Success
And from the Slave:
22:02:10.514 -> Bytes received: 56
22:02:10.514 -> Char: THIS IS A CHAR
22:02:10.514 -> Int: 17
22:02:10.514 -> Float: 1.20
22:02:10.514 -> String: 4⸮⸮
22:02:10.514 -> Bool: 0
Well done! 
If you have more info on the reason why this is so that would be icing on the cake.
Thanks and regards,
Leo
 

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi Leo.
I’m glad that it is finally working.
However, I’m not quite sure why. What I’ve read is that it needs to be copied before the setup() to make the peerInfo a global variable. But, I don’t know why it didn’t work for you, but works for me and for other people too.
Anyway, then I’ll try to investigate this subject further and update our code if needed.
Regards,
Sara
 

0 Vote Up Vote Down
Leo Eyck answered 5 years ago

Great Sara.
A bit confusing that’s for sure. However it’s also a learning opportunity and I find I learn more when things go wrong then when they go right. I look forward to the results of your investigation if you find anything.
Thanks heaps for your help and efforts, I really appreciate it.
 
Regards,
Leo

0 Vote Up Vote Down
Edo Ceder answered 5 years ago

Hi Leo, Sara,

Thank you both for being so persistent. I just downloaded the sample from the course and ran into the same problem, and the solution of making the peerInfo a global variable did the trick for me as well.
Best regards,
Edo

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi Edo.
Thanks for sharing that. It seems that we’ll need to update that part of the course.
Regards,
Sara

0 Vote Up Vote Down
Steve answered 3 years ago

Dear Sara, Your detective work saved me again! I was having the same problem (Feb 2022) with your (and others’) ESP-NOW example sketches, until I moved that line 

esp_now_peer_info_t peerInfo;

out of the Setup function to make it global. All good now.
This is a gentle reminder to edit your example code in your ESP-NOW tutorials, Thanks!!

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
Thanks for the reminder.
I just updated the esp-now sketches.
Regards,
Sara

0 Vote Up Vote Down
Jop answered 2 years ago

Hi Leo and Sara,

Here also I like to express my gratitude to your both for being so persistent in finding this “bug”. It saved me lots of hours and prevented me getting crazy.
I experienced now with a sketch I wrote years ago (and was working ok) also such an error:

E (7056) ESPNOW: Peer interface is invalid

Just by Google I found your conversation. I moved this declaration of peerInfo and it worked!

So never remove such pearls from internet – diamonds are for ever!

Thanks a lot,

   Jop

     

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Thanks.
That’s great! I’m glad this was useful.
Regards,
Sara
 

0 Vote Up Vote Down
Leo Eyck answered 2 years ago

Ditto,
 
Regards,
Leo

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.