ESP_NOW protocol

In this code I am trying to send data over the esp_now protocol, I faced problem in this my code, I have data size (arr) equal to 297, the problem is when I received the data more than 173 the data in receiver side are not correct values in addition to I could not receive all the 297 values I am just receiver 175 values. Why?

#include <esp_now.h>
#include <WiFi.h>

// REPLACE WITH YOUR RECEIVER MAC Address
uint8_t broadcastAddress[] = {X,X,X,X,X,X};
esp_now_peer_info_t peerInfo;

// callback when data is sent
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
  Serial.print("\r\nLast Packet Send Status:\t");
  Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" :
  "Delivery Fail");
  }

 int arr[]={
};

void setup() {
  // Init Serial Monitor
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  // Init ESP-NOW
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }
  esp_now_register_send_cb(OnDataSent);
  // Register peer
  memcpy(peerInfo.peer_addr, broadcastAddress, 6);
  peerInfo.channel = 0;
  peerInfo.encrypt = false;
  // Add peer
  if (esp_now_add_peer(&peerInfo) != ESP_OK) {
    Serial.println("Failed to add peer");
    return;
  }

      esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &arr[i], sizeof(int));  
 if (result == ESP_OK) {
    Serial.println("Sent with success");
  }
  else {
    Serial.println("Error sending the data");
}}
}
void loop() {}

ESP-NOW allows a maximum of 250 bytes per message if uncrypted and less if you want to use encryption.

This means you have to divide your data into two parts and use one byte to indicate if this part is part 1 or part 2

best regards Stefan

??
add serial debug-output to your code and post the results as a code-section

I added the output of receiver side:

What is the purpose of sending the contents of the array ?

I have some processing on it in the receiver side.

Does the contents of the array ever change ?

Why can't you do the processing on the first ESP32 ?

@UKHeliBob ,My project requires sending and receiving .My problem I can not receive the same and all the sending data.

When you are starting out, it is a serious mistake to ignore return values from functions.

Consider checking whether the data were successfully transmitted.

// Send message via ESP-NOW
  esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));
   
  if (result == ESP_OK) {
    Serial.println("Sent with success");
  }
  else {
    Serial.println("Error sending the data");
  }
   

The is the output of sender:

Sent with success
Sent with success
Sent with success
Sent with success
Sent with success
Sent with success
Sent with success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success
Sent with success

Last Packet Send Status:	Delivery Success

Last Packet Send Status:	Delivery Success

Last Packet Send Status:	Delivery Success

Last Packet Send Status:	Delivery Success

Last Packet Send Status:	Delivery Success

Last Packet Send Status:	Delivery Success

Last Packet Send Status:	Delivery Success

Last Packet Send Status:	Delivery Success

Does that look right to you? It certainly does not, to me.

What do you think is the solution? I'm looking for a solution, so I asked.

More information is needed.

It appears to me that you have hardly begun to debug the process. Slow things down so that you can examine what happens, in both receiver and transmitter, at every step. Put in Serial.prints() to see values of interesting variables.

Have you successfully run one of the tutorial examples that is close to what you want in the end?

Yes, put the tutorial examples used struct and send just one packet I don't need to use it

Start with a two way example in order to understand the acknowledge process.

Please DO NOT modify your original post, especially the code, because that makes the discussion impossible for others to follow.

After revising code, post that separately.

This problem happened just when send 5 , when send 250 bytes every thing is ok

You have still not explained why you want to send the whole array to a second ESP32. What is the source of the data in the array after it has been initially defined ? What causes it to change ?

No idea but I just wonder why you change the type of your data in the esp_now_send function.

It just an array!

If it is an array with 297 values that never change then why are you transmitting it to another ESP32 ?