ESP8266 不在网络中发送和接收数据

ESP8266 send & recieve data without being in a network

我想让两个 NodeMCU ESP8266 相互通信,但我不希望它们在一个网络中。我在想发射器可以一直广播数据包,而接收器可以使用混杂模式捕获和读取数据包。如何做到这一点?

编辑: 如果使用 ESP8266 无法做到这一点,是否有芯片可以做到这一点(可能是 Raspberry PI 和 NodeMCU 或其他东西)。

ESP 是 Wi-Fi 设备。 Wi-Fi 需要网络才能建立 link-level 连接。

但您可以轻松地在两个节点之间创建一个 ad-hoc 网络:以 AP 模式启动一个,另一个以客户端模式启动,连接到该 AP。

例如:

// "Server"
#include <ESP8266WiFi.h>
void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(IPAddress(192,168,4,1), IPAddress(192,168,4,1), IPAddress(255,255,255,0));
  WiFi.softAP("my_ssid", "password");
}
// "Client"
#include <ESP8266WiFi.h>
void setup() {
  Serial.begin(115200);
  WiFi.begin("my_ssid", "password");
}

然后使用您最喜欢的协议(UDP、MQTT 等)来广播消息 (UDP example)。您可以通过发送到 IP 255.255.255.255 使用 UDP 进行广播。

请注意,Arduino-related 问题有专门的网站:https://arduino.stackexchange.com/

如果你只是想在 ESP8266 设备之间进行通信,我建议你 ESP-NOW 试一试。

Espressif says

ESP-NOW is yet another protocol developed by Espressif, which enables multiple devices to communicate with one another without using Wi-Fi. The protocol is similar to the low-power 2.4GHz wireless connectivity that is often deployed in wireless mouses. So, the pairing between devices is needed prior to their communication. After the pairing is done, the connection is safe and peer-to-peer, with no handshake being required.

这里有一个入门教程https://randomnerdtutorials.com/esp-now-esp8266-nodemcu-arduino-ide/

Nordic nRF24 系列可轻松实现点对点无线传输。

https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF24-series