当前位置: 首页 > news >正文

武安网站建设价格百度客服电话人工服务

武安网站建设价格,百度客服电话人工服务,dreamweaver下载安装,提供网站制作价格ESP32 Arduino EspNow点对点双向通讯✨本案例分别采用esp32和esp32C3之间点对点单播无线通讯方式。 🌿esp32开发板 🌾esp32c3开发板 🔧所需库(需要自行导入到Arduino IDE library文件夹中,无法在IDE 管理库界面搜索下载到该库)&am…

ESP32 Arduino EspNow点对点双向通讯


✨本案例分别采用esp32esp32C3之间点对点单播无线通讯方式。

  • 🌿esp32开发板
    在这里插入图片描述
  • 🌾esp32c3开发板
    在这里插入图片描述
  • 🔧所需库(需要自行导入到Arduino IDE library文件夹中,无法在IDE 管理库界面搜索下载到该库):WifiEspNow库
    – 📍库下载地址GitHub:https://github.com/yoursunny/WifiEspNow

✨本案例实现的是单播通讯方式。

  • 🎬通讯效果
    在这里插入图片描述

⚡数据长度可以根据使用需求自定义修改变量msg数组接收长度。需要注意的是数据长度限制: 250

🛠搭建环境说明

先烧录程序,通过串口打印的本机MAC地址信息记录下来,同理,记下两个设备的MAC地址,然后将获取的对方的MAC地址填写入代码当中。(A 设备使用 B 设备的MAC, B 设备使用 A 设备的MAC地址)

🚩ESP8266只支持单播。ESP32支持单播和组播。

  • 📑单播、广播、多播(组播)的概念和区别:

一台机器和一台机器通信这是单播;一台机器发出的数据包能被多台机器收到这就叫组播,一个机器发送,多台机器接收,但是又不同于广播;一台机器发出的数据包能被一个网段的机器收到这叫广播.多播又叫组播
可以说广播是多播的特例,多播就是给一组特定的主机(多播组)发送数据.

  • 📍参考:《单播、广播、多播(组播)的概念和区别》

📝程序代码

  • 🎉程序都是一样,区别:只是里面定义的存放MAC地址的数组为对方的MAC地址。
/*** @file** EspNowUnicast.ino demonstrates how to transmit unicast ESP-NOW messages with @c WifiEspNow .* You need two ESP8266 or ESP32 devices to run this example.** 单播通信要求发送方指定接收方的MAC地址。* 因此,您必须为每个设备修改这个程序。** The recommended workflow is:* @li 1. Flash the program onto device A.* @li 2. Run the program on device A, look at serial console for its MAC address.* @li 3. Copy the MAC address of device A, paste it in the @c PEER variable below.* @li 4. Flash the program that contains A's MAC address onto device B.* @li 5. Run the program on device A, look at serial console for its MAC address.* @li 6. Copy the MAC address of device B, paste it in the @c PEER variable below.* @li 7. Flash the program that contains B's MAC address onto device A.* @li;将程序闪到设备A上。
* @li 2;在设备A上运行程序,查看串行控制台的MAC地址。
* @li;复制设备A的MAC地址,粘贴到下面的@c PEER变量中。
* @li;将包含A的MAC地址的程序闪到设备B上。
* @li;在设备A上运行程序,查看串行控制台的MAC地址。
* @li。复制设备B的MAC地址,粘贴到下面的@c PEER变量中。
* @li。将包含B的MAC地址的程序闪到设备A上。*/#include <WifiEspNow.h>
#if defined(ARDUINO_ARCH_ESP8266)
#include <ESP8266WiFi.h>
#elif defined(ARDUINO_ARCH_ESP32)
#include <WiFi.h>
#endif// 接收MAC地址。必须针对每个设备进行修改。
// static uint8_t PEER[]{0x08, 0x3A, 0xF2, 0x8D, 0xCD, 0xE1};//ESP32DEV MAC地址static uint8_t PEER[]{0x60, 0x55, 0xF9, 0x79, 0x87, 0x99};//esp3232c3
void printReceivedMessage(const uint8_t mac[WIFIESPNOW_ALEN], const uint8_t* buf, size_t count,void* arg)
{Serial.printf("Message from %02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1], mac[2], mac[3],mac[4], mac[5]);for (int i = 0; i < static_cast<int>(count); ++i) {Serial.print(static_cast<char>(buf[i]));}Serial.println();
}void setup()
{Serial.begin(115200);Serial.println();WiFi.persistent(false);WiFi.mode(WIFI_AP);WiFi.disconnect();WiFi.softAP("ESPNOW", nullptr, 3);WiFi.softAPdisconnect(false);// WiFi must be powered on to use ESP-NOW unicast.// It could be either AP or STA mode, and does not have to be connected.// For best results, ensure both devices are using the same WiFi channel.Serial.print("MAC address of this node is ");Serial.println(WiFi.softAPmacAddress());uint8_t mac[6];WiFi.softAPmacAddress(mac);Serial.println();Serial.println("You can paste the following into the program for the other device:");Serial.printf("static uint8_t PEER[]{0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X};\n", mac[0],mac[1], mac[2], mac[3], mac[4], mac[5]);Serial.println();bool ok = WifiEspNow.begin();if (!ok) {Serial.println("WifiEspNow.begin() failed");ESP.restart();}WifiEspNow.onReceive(printReceivedMessage, nullptr);ok = WifiEspNow.addPeer(PEER);if (!ok) {Serial.println("WifiEspNow.addPeer() failed");ESP.restart();}
}void loop()
{char msg[60];int len = snprintf(msg, sizeof(msg), "hello ESP3dev-NOW from %s at %lu",WiFi.softAPmacAddress().c_str(), millis());WifiEspNow.send(PEER, reinterpret_cast<const uint8_t*>(msg), len);delay(1000);
}
http://www.khdw.cn/news/49053.html

相关文章:

  • 北京 工业网站建设公司价格网站服务器查询工具
  • 陕西省建设网官网诚信信息发布平台seo外包服务公司
  • 上海网站建设推广服务杭州网络排名优化
  • wordpress社区论坛模板西安关键词优化平台
  • 开封市建设银行网站上海关键词推广
  • 网站开发上市公司百度指数怎么提升
  • 织梦cms网站网站广告调词平台
  • 江西医院网站建设2022年新闻热点事件
  • 无锡企业网站排名舆情信息在哪里找
  • 网站友情链接怎么做网站一般怎么推广
  • 学做效果图网站有哪些站长之家域名信息查询
  • 建站模板怎么选制作网页的流程步骤
  • 什么网站动物和人做的百度注册
  • 顺德大良那里做网站好河南网站seo费用
  • 网站建设的公司做销售丁的老头seo博客
  • 微信公众号 小程序seoul是什么意思中文
  • php网站开发技术湖南广告优化
  • 做易经网站线上推广100种方式
  • behance官网入口站长工具seo综合查询源码
  • 做优化的网站seo平台代理
  • 大连网站建设个人四川seo排名
  • 平面设计接单兼职太原优化排名推广
  • wordpress 弹窗广告插件有没有免费的seo网站
  • 在家做网站怎么赚钱企业网站设计思路
  • 重庆建设网站哪个好网站优化要做哪些
  • 南昌官网seo诊断抖音seo搜索引擎优化
  • 可以做直播卖产品的网站网络推广怎么做方案
  • 怎么做百度采购网站厦门seo俱乐部
  • visual c 网站开发山东网站建设
  • 做论坛推广的网站凤山网站seo