Why my code works (ESP NOW)? According to documentation it shouldn't

kwit98
Posts: 2
Joined: Sun Jul 16, 2023 8:00 pm

Why my code works (ESP NOW)? According to documentation it shouldn't

Postby kwit98 » Sun Jul 16, 2023 8:35 pm

Hi, i made code involving two way esp now communitation and after reading documentation I'm pretty confused - what i wrote shouldn't work.

Documentation declares that maximum amount of bytes hold in struct that is sended as message is 250 bytes. I have made message that contains 60 int:

Code: Select all

typedef struct struct_message {
  int message[60];
} struct_message; 
On one esp i'm holding variables in eeprom and i'm sending it to second one that displays it on serial monitor. (I'm sending 4 arrays containing 14 elements each, that's why I'm receveing/printing only 56 messages).

Code: Select all

for (int i = 0; i < 14*4; i++) Serial.printf("mess[%i]: %i | ", i, incomingBuff.message[i]);

Serial monitor result:
mess[0]: 101 | mess[1]: 0 | mess[2]: 70 | mess[3]: 210 | mess[4]: 280 | mess[5]: 210 | mess[6]: 210 | mess[7]: 220 | mess[8]: 280 | mess[9]: 280 | mess[10]: 280 | mess[11]: 280 | mess[12]: 210 | mess[13]: 140 | mess[14]: 0 | mess[15]: 0 | mess[16]: 0 | mess[17]: 0 | mess[18]: 0 | mess[19]: 0 | mess[20]: 0 | mess[21]: 50 | mess[22]: 140 | mess[23]: 140 | mess[24]: 140 | mess[25]: 50 | mess[26]: 0 | mess[27]: 0 | mess[28]: 0 | mess[29]: 0 | mess[30]: 0 | mess[31]: 0 | mess[32]: 0 | mess[33]: 0 | mess[34]: 0 | mess[35]: 50 | mess[36]: 140 | mess[37]: 140 | mess[38]: 140 | mess[39]: 50 | mess[40]: 0 | mess[41]: 0 | mess[42]: 0 | mess[43]: 0 | mess[44]: 0 | mess[45]: 0 | mess[46]: 0 | mess[47]: 0 | mess[48]: 50 | mess[49]: 140 | mess[50]: 140 | mess[51]: 140 | mess[52]: 50 | mess[53]: 0 | mess[54]: 0 | mess[55]: 0 |
All informations are correct, why? Message can hold 250 bytes, each int is built of 32 bytes, that would give 7 ints maximum. I'm using arduino IDE, but even int8 shouldn't fit there (250/8 = 31).

What magic is happening behind scene? I can't find any information about it in documentation

//Im using two ESP-32, both are set to two way communication with defined broadcast adresses.

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Why my code works (ESP NOW)? According to documentation it shouldn't

Postby ESP_Sprite » Mon Jul 17, 2023 2:20 am

kwit98 wrote:
Sun Jul 16, 2023 8:35 pm
All informations are correct, why? Message can hold 250 bytes, each int is built of 32 bytes, that would give 7 ints maximum. I'm using arduino IDE, but even int8 shouldn't fit there (250/8 = 31).
An int is 32 bits not bytes. 32 bits is 4 bytes, so a message can contain (250/4=)62 ints.

kwit98
Posts: 2
Joined: Sun Jul 16, 2023 8:00 pm

Re: Why my code works (ESP NOW)? According to documentation it shouldn't

Postby kwit98 » Thu Jul 20, 2023 10:07 pm

Thanks and sorry for such dumb question

bruceg
Posts: 1
Joined: Tue Nov 12, 2024 3:58 am

Re: Why my code works (ESP NOW)? According to documentation it shouldn't

Postby bruceg » Tue Nov 12, 2024 4:01 am

Version 2 changed the packet payload limit from 250 to 1490.

bye.

Who is online

Users browsing this forum: No registered users and 25 guests