ESP8266使用记录(一)

1、23.7.17从TB买了个8266

2、下载安装Arduino

3、卖家的配套资料,直接覆盖相关文件

4、文件-首选项-设置-编辑器语言-中文(简体)

其他开发板管理器地址

http://arduino.esp8266.com/stable/package_esp8266com_index.json

5、工具-端口-COM6 工具-开发板-esp8266-Generic-ESP8266 Module

6、文件-示例-01.basics-Blink 测试正常

7、测试UDP通信 正常

复制代码
/**********************************************************************
项目名称/Project          : 零基础入门学用物联网
程序名称/Program name     : ESP8266WiFiUdp_12
团队/Team                : 太极创客团队 / Taichi-Maker (www.taichi-maker.com)
作者/Author              : 小凯
日期/Date(YYYYMMDD)     : 20200319
程序目的/Purpose          : 
用于演示ESP8266WiFiUdp库中print函数
-----------------------------------------------------------------------
本示例程序为太极创客团队制作的《零基础入门学用物联网》中示例程序。
该教程为对物联网开发感兴趣的朋友所设计和制作。如需了解更多该教程的信息,请参考以下网页:
http://www.taichi-maker.com/homepage/esp8266-nodemcu-iot/iot-c/esp8266-nodemcu-web-client/http-request/
***********************************************************************/
 
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
 
#define ssid      "TaichiMaker_WIFI" //这里改成你的设备当前环境下WIFI名字
#define password  "xxxxxxx"          //这里改成你的设备当前环境下WIFI密码
 
WiFiUDP Udp;//实例化WiFiUDP对象
unsigned int localUdpPort = 1234;  // 自定义本地监听端口
unsigned int remoteUdpPort = 4321;  // 自定义远程监听端口
char incomingPacket[255];  // 保存Udp工具发过来的消息
char  replyPacket[] = "Hi, this is esp8266\n";  //发送的消息,仅支持英文
 
void setup()
{
  Serial.begin(115200);//打开串口
  Serial.println();
 
  Serial.printf("正在连接 %s ", ssid);
  WiFi.begin(ssid, password);//连接到wifi
  while (WiFi.status() != WL_CONNECTED)//等待连接
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println("连接成功");
 
  if(Udp.begin(localUdpPort)){//启动Udp监听服务
    Serial.println("监听成功");
      
    //打印本地的ip地址,在UDP工具中会使用到
    //WiFi.localIP().toString().c_str()用于将获取的本地IP地址转化为字符串   
    Serial.printf("现在收听IP:%s, UDP端口:%d\n", WiFi.localIP().toString().c_str(), localUdpPort);
  }else{
    Serial.println("监听失败");
  }
}
 
void loop()
{
  //向udp工具发送消息
  Udp.beginPacket(Udp.remoteIP(), remoteUdpPort);//配置远端ip地址和端口
  Udp.print(replyPacket);//把数据写入发送缓冲区
  Udp.endPacket();//发送数据
  Serial.println("UDP数据发送成功");
  delay(3000);//延时3秒
}

相关链接地址
https://detail.tmall.com/item.htm?id=621477763135&spm=a1z09.2.0.0.141e2e8dKlJrPa&_u=gms1fgr0560
http://www.taichi-maker.com/homepage/esp8266-nodemcu-iot/iot-c/esp8266-nodemcu-web-client/http-request/
https://www.arduino.cc/en/software/
https://zhuanlan.zhihu.com/p/612965686?utm_id=0

相关推荐
林枫依依6 小时前
Unity Webgl在编辑器中报错:Cannot connect to destination host
unity·编辑器·webgl
KhalilRuan7 小时前
Unity-Shader详解-其一
unity·游戏引擎
Clank的游戏栈12 小时前
Unity多线程渲染指令队列设计与集成技术详解
windows·unity·游戏引擎
Thomas_YXQ19 小时前
Unity3D IK解算器技术分析
开发语言·搜索引擎·unity·全文检索·unity3d·lucene
星火撩猿1 天前
常见游戏引擎介绍与对比
unity·ue5·游戏引擎·godot
sky_smile_Allen1 天前
[Unity]-[UI]-[Prefab] 关于Unity UGUI 的布局及组件讲解
ui·unity·游戏引擎
太妃糖耶1 天前
URP-利用矩阵在Shader中实现物体的平移和缩放
unity·矩阵
是阿根2 天前
unity使用iTextSharp生成PDF文件
unity·c#·游戏引擎
常城2 天前
Unity中通过TMP使用图片字体
unity·游戏引擎
惊鸿醉2 天前
⭐Unity 开发 | 如何通过 NTP 网络时间实现精准的跨平台时间同步【附完整源码 + UI 模块 + 偏差分析】
网络·unity·游戏引擎