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

相关推荐
一种时光16 小时前
Unity 获取当前播放的动画,判断是否是某个动画
unity·游戏引擎
不绝19120 小时前
Unity入门 :场景叠加/预制体资源包/脚本资源/生命周期函数/Inspector页面
unity·游戏引擎
在路上看风景21 小时前
20. 资源和脚本的绑定关系
unity
yj爆裂鼓手1 天前
unity对象池
unity·c#
在路上看风景1 天前
3.7 SRP Batcher
unity
快乐觉主吖1 天前
Unity方便修改产品名和包名的小工具
unity·游戏引擎
JIes__2 天前
Unity(二)——MonoBehavior中的重要内容
unity·游戏引擎
4Forsee2 天前
【增强现实】快速上手 Vuforia Unity Android AR 应用开发
android·unity·ar
两水先木示2 天前
【Unity】对指定物体进行描边——模板测试法
unity·游戏引擎·shader·外描边
Miss_SQ2 天前
实现Unity录音、百度云语音转文字
unity·语音识别