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

相关推荐
与火星的孩子对话35 分钟前
Unity3D开发AI桌面精灵/宠物系列 【六】 人物模型 语音口型同步 LipSync 、梅尔频谱MFCC技术、支持中英文自定义编辑- 基于 C# 语言开发
人工智能·unity·c#·游戏引擎·宠物·lipsync
敲代码的 蜡笔小新5 小时前
【行为型之访问者模式】游戏开发实战——Unity灵活数据操作与跨系统交互的架构秘诀
unity·设计模式·c#·访问者模式
动感光博14 小时前
Unity序列化字段、单例模式(Singleton Pattern)
unity·单例模式·c#
FAREWELL0007516 小时前
Unity基础学习(十五)核心系统——音效系统
学习·unity·c#·游戏引擎
向宇it17 小时前
【unity游戏开发——编辑器扩展】使用MenuItem自定义菜单栏拓展
开发语言·ui·unity·c#·编辑器·游戏引擎
动感光博17 小时前
Unity碰撞检测(射线投射、胶囊体投射)、交互(图层、掩码)
unity·c#·游戏引擎·游戏程序·动画
benben04419 小时前
Unity3D仿星露谷物语开发44之收集农作物
前端·游戏·unity·游戏引擎
动感光博20 小时前
Unity(URP渲染管线)的后处理、动画制作、虚拟相机(Virtual Camera)
开发语言·人工智能·计算机视觉·unity·c#·游戏引擎
MWHLS1 天前
【以及好久没上号的闲聊】Unity记录8.1-地图-重构与优化
unity·开源
WarPigs2 天前
Unity光照笔记
笔记·unity·游戏引擎