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

相关推荐
zdr尽职尽责8 天前
UnityCli 兼容2022版本
ui·unity·ai·c#·游戏引擎
ellis197010 天前
Claude Code[二] 上下文相关的机制
unity·ai编程
zdr尽职尽责11 天前
Unity 3C 动画系统:从「蜘蛛网」到可维护的动画架构
unity·架构·游戏引擎
国家一级摸鱼选手11 天前
[Unity]几何碰撞检测:SAT 分离轴定理详解(从数学原理到 C# 实现)
unity·c#·游戏引擎·分离轴定理(sat)·多边形相交
暴走约伯13 天前
【VFX工具链源码拆解 09】终极工业化闭环:基于 ID 规则驱动的全自动场景建档、骨骼挂载与男转女场景迁移
unity·c#·游戏引擎·材质
寂寞的船14 天前
【Unity知识速递】第13期 Unity 内存泄漏排查实战:从 Memory Profiler 到 Lua 引用泄漏的生产级全链路诊断
unity·junit·c#·游戏引擎·lua
寂寞的船15 天前
【Unity Bug挑战】第12期 Awaitable 二次 await 死锁之谜 —— 为什么同一个异步操作等两次就卡死?
unity·c#·游戏引擎·bug
探求虚无16 天前
用 AI 在 Unity 里做一款 RTS:最难的不是生成代码,而是证明它真的能玩
人工智能·unity·游戏引擎
17岁的勇气17 天前
Unity Shader unity文档学习笔记(二十二):shader变体
笔记·学习·unity
寂寞的船18 天前
【Unity知识速递】第10期 Unity GC 零分配实战:从 UnityEngine.Pool 到手动 GC 控制的全链路优化
jvm·unity·c#·游戏引擎·lucene