Skip to content

Cannot receive ESP-Now Broadcasts #6174

Closed
@littleyoda

Description

@littleyoda

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • [ ] I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • [ ] If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: tested with D1 Mini and NodeCMU
  • Core Version: 2.5.2
  • Development Env: PlatformIO (espressif8266@2.2.1)
  • Operating System: Ubuntu

Settings in IDE

  • Module: D1 Mini and NodeCMU
  • Flash Mode: DIO
  • Flash Size: 4MB
  • lwip Variant: -DLWIP_OPEN_SRC -DNONOSDK221=1 -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0
  • Reset Method: nodemcu
  • Flash Frequency: 40Mhz
  • CPU Frequency: 160MHz
  • Upload Using: SERIAL
  • Upload Speed: 115200
  • /usr/bin/python /home/XXX/.platformio/packages/tool-esptoolpy/esptool.py --chip esp8266 --port /dev/ttyUSB0" --baud 115200 write_flash 0x0 firmware.bin

Problem Description

Currently the ESP8266 is able to send ESP-Now Broadcast, but is not able to receive ESP-Now Broadcast.

The Problem has been fixed in the ESP8266_NONOS_SDK around Nov 2018.
espressif/ESP8266_NONOS_SDK#8
espressif/ESP8266_NONOS_SDK#134

Apparently this bugfix has not been applied yet.
I tested the program below against the ESP32. The ESP32 is able to receive the Broadcasts send by the ESP8266.

All in all, it is very difficult for an outstanding user to find out which changes from ESP8266_NONOS_SDK have been applied. Even after reading SDK issues (SDK reverted from pre3 to 2.2.1) and Migrate core from NONOS SDK to FreeRTOS SDK

MCVE Sketch

#include <Arduino.h>

#include <ESP8266WiFi.h>
extern "C" {
#include <espnow.h>
#include "user_interface.h"

}

#define WIFI_CHANNEL 1 

byte message[10] = {1,2,3,4,5,6,7,8,9,10};
unsigned long last = 0;

uint8_t broadcastMac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
 

void setup() {
	Serial.begin(115200);
	delay(3000);

	WiFi.softAP("sender", "sendersender", WIFI_CHANNEL, false);
	WiFi.mode(WIFI_AP_STA);

  Serial.println("INIT: " + String(esp_now_init()));
	delay(10);
  Serial.println("Set Self Role: " + String(esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER)));

	// Callback for received messages
	esp_now_register_recv_cb([](uint8_t *mac, uint8_t *data, uint8_t len) {
		Serial.print("[" + String(millis()) + "] Received Message. Len=" + String(len));
	});
	WiFi.printDiag(Serial);
}

void loop() {
  // Send a new message every 5 sec
	if ((last + 5000) < millis()) {
		int ret = esp_now_send(broadcastMac, message, 10);
		last = millis();
		Serial.println("[" + String(millis()) + "] Sending new Message -- Result Code: " + String(ret));
	}
	delay(10);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions