Skip to content

Unable to send data with esp now #10895

Closed
@Gabriele-Cano

Description

@Gabriele-Cano

Board

ESP32-C3 Custom PCB

Device Description

It's a custom PCB that I made, it's connected via I2C to MC3419 (accelerometer) and MAX17055 (battery fuel gauge). Then with "PWM" it's connected to AL1783 (led driver), and with a mosfet for running a buzzer.

Hardware Configuration

18 and 19 are for USB data

#define LED_R_PIN 0
#define LED_G_PIN 1
#define LED_B_PIN 4

#define SDA_PIN 5
#define SCL_PIN 6

#define ACCEL_INT_PIN 9

#define BUZZER 2
#define BATTERY_PIN 3 (to check if it's charging)

Version

latest master (checkout manually)

IDE Name

VSCode, PlatformIO

Operating System

Ubuntu 24.04.1 LTS

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

Changing baud rate to 921600 (upload log)

Description

Not sure about PSRAM

I'm having a problem with ESP Now, it seems that my ESPs are able to receive data but not the send. I know that because I tried to use another ESP32 (from Waveshare) and they both received the data sent by the last one.

Both ESPs have the same code i wrote here. When i run the code (I checked that the other esp was turned on) the output is
Data sent
Send Status: Fail

and so on for ever.

I tried to change code but nothing seems to be working

Sketch

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

uint8_t peerAddress[] = {0xD8, 0x3B, 0xDA, 0xE3, 0x1C, 0xCC}; // Replace with your peer's MAC

void onDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
  Serial.print("Send Status: ");
  Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Success" : "Fail");
}

void onDataRecv(const uint8_t *mac, const uint8_t *data, int len) {
  Serial.print("Data received: ");
  Serial.write(data, len);
  Serial.println();
}

void setup() {
  Serial.begin(115200);
  
  WiFi.mode(WIFI_STA);
  Serial.println(WiFi.macAddress());
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }
  esp_now_register_send_cb(onDataSent);
  esp_now_register_recv_cb(onDataRecv);

  esp_now_peer_info_t peerInfo = {};
  memcpy(peerInfo.peer_addr, peerAddress, 6);
  peerInfo.channel = 0;
  peerInfo.encrypt = false;
  if (esp_now_add_peer(&peerInfo) != ESP_OK) {
    Serial.println("Failed to add peer");
    return;
  }
}

void loop() {
  const char *message = "Hello ESP-NOW";
  esp_err_t result = esp_now_send(peerAddress, (uint8_t *)message, strlen(message));
  if (result == ESP_OK) {
    Serial.println("Data sent");
  } else {
    Serial.println("Send Error");
  }
  delay(2000);
}

Debug Message

Not sure on how to do that with PlatformIO (The program doesn't crash)

Other Steps to Reproduce

I tried another OS with macOS Ventura I think, but the problem remains the same.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions