SOLVED: ESP32 esp-now data transfer is pausing

I am working with esp-now. I simply want a nonstop continuous stream of bytes being transferred from one esp32 to another. For my test, I am trying to send a 1 and then a 0, and repeating.

When I monitor the receiver, it appears to receive these bytes as intended, but then pauses for a moment, then continues to receive as intended, then pauses again... repeating.

I put together the code below from snippets of online tutorials.
What can I change in the code to make the stream non-stop? Or should I use a different method than esp-now?

Thank you for your assistance.

SENDER

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


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

uint8_t data = 0;

void setup() {

  WiFi.mode(WIFI_STA);

  if (esp_now_init() != ESP_OK) {
    return;
  }

  // Register peer
  esp_now_peer_info_t peerInfo;
  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;
  }

}


void loop() {

  data++;

  esp_now_send(broadcastAddress, &data, 1);

  data--;

  esp_now_send(broadcastAddress, &data, 1);

}

RECEIVER

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


uint8_t data;


void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {
  memcpy(&data, incomingData, 1);

}


void setup() {

  Serial.begin(115200);

  WiFi.mode(WIFI_STA);

  if (esp_now_init() != ESP_OK) {
    return;
  }

  esp_now_register_recv_cb(OnDataRecv);

}


void loop() {

  Serial.println(data);

}

Visit https://esp32.com/ and ask the fellows who made espnow.

It appears the pause is being caused by the serial monitor connection. If I remove that, the data streams continuously between the two esp32's.

Thanks for letting us know.

The ESP32 has the ability to print to the serial monitor using log.

Such as this

log_i( "TimeSpentOnTasks: %d", EndTime );

There are varuious log_x depending on your logging setting in the IDE. You do not set up Serial in setup to use log printing.

more info ESP32 API: API Reference - ESP32 - — ESP-IDF Programming Guide latest documentation, search for log_i or log_d

Odd. I havent seen serial.print have such a symptom. I had same issue, it would count off (my own sketch, not the examples) "1, 2, 3,...... 10, 11"