UDP: ESP32 to ESP32 Wireless Data Share within one netwrk - UDP
Two ESPs on one Wifi Network , Open Packet share without IP Address.
ESP NOW skips too many packets, if walls are involved. UDP is best if you have secure personal network
PS:
1) UDP Listen Procedure needs to come before first Broadcast Command
Code:
#include "WiFi.h"
#include "AsyncUDP.h"
const char * ssid = "******";
const char * password = "********";
int myPort = 40000;
AsyncUDP udp;
void setup() {
Serial.begin(115200);
Serial.println("");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (!WL_CONNECTED) {delay(1000);}
if(udp.listen(myPort)) {
udp.onPacket([](AsyncUDPPacket packet) {
Serial.write(packet.data(), packet.length()); Serial.println();
char* tmpStr = (char*) malloc(packet.length() + 1);
memcpy(tmpStr, packet.data(), packet.length());
tmpStr[packet.length()] = '\0';
String testString = String(tmpStr) + 1234;
free(tmpStr);
Serial.println(testString);
});
}
}
void loop() {
String temp1 = "Hello World" + 123;
udp.broadcastTo(temp1.c_str(), myPort);
delay(2000);
}
00:00 - Intro
00:20 - Topics & Introduction
03:00 - Minimal Code
05:35 - ESP32 Communicating
07:20 - Saving Data received into Variable
12:30 - Sending String instead of Quoted text
15:23 - Custom Port
Видео UDP: ESP32 to ESP32 Wireless Data Share within one netwrk - UDP канала 545sytes
ESP NOW skips too many packets, if walls are involved. UDP is best if you have secure personal network
PS:
1) UDP Listen Procedure needs to come before first Broadcast Command
Code:
#include "WiFi.h"
#include "AsyncUDP.h"
const char * ssid = "******";
const char * password = "********";
int myPort = 40000;
AsyncUDP udp;
void setup() {
Serial.begin(115200);
Serial.println("");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (!WL_CONNECTED) {delay(1000);}
if(udp.listen(myPort)) {
udp.onPacket([](AsyncUDPPacket packet) {
Serial.write(packet.data(), packet.length()); Serial.println();
char* tmpStr = (char*) malloc(packet.length() + 1);
memcpy(tmpStr, packet.data(), packet.length());
tmpStr[packet.length()] = '\0';
String testString = String(tmpStr) + 1234;
free(tmpStr);
Serial.println(testString);
});
}
}
void loop() {
String temp1 = "Hello World" + 123;
udp.broadcastTo(temp1.c_str(), myPort);
delay(2000);
}
00:00 - Intro
00:20 - Topics & Introduction
03:00 - Minimal Code
05:35 - ESP32 Communicating
07:20 - Saving Data received into Variable
12:30 - Sending String instead of Quoted text
15:23 - Custom Port
Видео UDP: ESP32 to ESP32 Wireless Data Share within one netwrk - UDP канала 545sytes
Комментарии отсутствуют
Информация о видео
9 июня 2022 г. 20:09:44
00:18:58
Другие видео канала