Hi everyone,
I have setup a esp-now network using Adafruit ESP8266. From one sender I Broadcast 1 byte at a time every second. All my 5 slaves receive this byte with a jitter of ~80 Micro second.
But when I look at how long it takes the sender to pass that 1 byte to the receivers, i have a fixed delay of 800 Micro second and a jitter of up to 5 milli second. Where does this 5 milli second jitter come from?
Thanks in advance!
**Sender Code:**
```
#include <ESP8266WiFi.h>
#include <espnow.h>
uint8_t broadcastAddress0[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
#define REF_PIN 5
byte data;
void OnDataSent(uint8_t *mac_addr, uint8_t sendStatus) {
Serial.print("Last Packet Send Status: ");
if (sendStatus == 0){
Serial.println("Delivery success");
}
else{
Serial.println("Delivery fail");
}
}
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(REF_PIN, OUTPUT);
Serial.begin(115200);
WiFi.mode(WIFI_STA);
if (esp_now_init() != 0) {
Serial.println("Error initializing ESP-NOW");
return;
}
esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER);
esp_now_register_send_cb(OnDataSent);
esp_now_add_peer(broadcastAddress0, ESP_NOW_ROLE_SLAVE, 1, NULL, 0);
}
void loop() {
if (Serial.available() > 0) {
data = Serial.read();
digitalWrite(REF_PIN, !digitalRead(REF_PIN));
esp_now_send(broadcastAddress0, (uint8_t *) &data, sizeof(data));
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
}
```
**Receiver Code:**
```
#include <ESP8266WiFi.h>
#include <espnow.h>
// ***this example is tested for both ESP8266 and adafruit esp8266***
uint8_t data;
#define REF_PIN 5
void OnDataRecv(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
digitalWrite(REF_PIN, !digitalRead(REF_PIN));
data = incomingData[0];
uint8_t cmd[] = {
0xAB,
(uint8_t)data,
0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB,
0xAB, 0xAB, 0xAB, 0xAB
};
Serial.write(cmd, sizeof(cmd));
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(REF_PIN, OUTPUT);
Serial.begin(115200);
WiFi.mode(WIFI_STA);
if (esp_now_init() != 0) {
Serial.println("Error initializing ESP-NOW");
return;
}
esp_now_set_self_role(ESP_NOW_ROLE_SLAVE);
esp_now_register_recv_cb(OnDataRecv);
}
void loop() {
}
```
ESP now broadcast latency
-
salman2135
- Posts: 4
- Joined: Thu Nov 28, 2024 1:45 pm
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- ESP32-S31
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- ESP32-S31 中文讨论版
- 喵伴 中文讨论版
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: No registered users and 1 guest
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.
Information
Espressif ESP32 ... Available now!