Arduino core for ESP8266 WiFi chip ESP8266 WiFi中文文档

本文介绍了如何在Arduino环境中使用ESP8266 WiFi芯片,重点讲解了ESP8266WiFi库的快速入门、工作模式、连接管理和配置方法,包括站模式的连接、断开、重连以及智能配置等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://github.com/esp8266/Arduino
https://arduino-esp8266.readthedocs.io/en/2.4.2/
这个项目为Arduino环境带来了对ESP8266芯片的支持。它允许您使用熟悉的Arduino函数和库编写草图,并直接在ESP8266上运行,不需要外部微控制器。ESP8266 Arduino core拥有使用TCP和UDP通过WiFi通信的库,设置HTTP、mDNS、SSDP和DNS服务器,做OTA更新,使用闪存中的文件系统,使用SD卡、伺服器、SPI和I2C外设。

ESP8266WiFi library ESP8266WiFi库

Quick Start 快速入门
#include <ESP8266WiFi.h>

void setup()
{
   
   
  Serial.begin(115200);
  Serial.println();

  WiFi.begin("network-name", "pass-to-network");

  Serial.print("Connecting");
  while (WiFi.status() != WL_CONNECTED)
  {
   
   
    delay(500);
    Serial.print(".");
  }
  Serial.println();

  Serial.print("Connected, IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
   
   }

在线路WiFi。开始(“network-name”, “pass-to-network”)将"network-name"和"pass-to-network"替换为您想要连接的Wi-Fi网络的名称和密码。然后将草图上传到ESP模块,打开串口监视器应该能看到有IP输出。
#include <ESP8266WiFi.h> 包括ESP8266WiFi库。这个库提供了ESP8266特定的Wi-Fi例程,我们调用它来连接网络。

实际连接到Wi-Fi是通过调用:`

WiFi.begin("network-name", "pass-to-network");

连接过程可能需要几秒钟的时间,我们正在检查,以完成以下循环:

while (WiFi.status() != WL_CONNECTED)
{
   
   
  delay(500);
  Serial.print(".");
}

while()循环将在WiFi.status()不是WL_CONNECTED时继续循环。只有当状态更改为WL_CONNECTED时,循环才会退出。
最后一行将打印出DHCP分配给E

### Arduino ESP8266 Library for WiFi Projects For developing projects based on the ESP8266 module using Arduino IDE, configuring the environment to support this chip involves adding specific libraries and board definitions. The process includes importing a library that supports ESP8266 into the Arduino IDE[^1]. This setup enables developers to leverage the powerful capabilities of ESP8266 modules within an easy-to-use development framework. The core library required for interfacing with ESP8266 through Arduino IDE is named `esp8266` or sometimes referred to as `ESP8266WiFi`. Once installed, this package provides necessary functions like connecting to Wi-Fi networks, establishing web servers, handling HTTP requests, among others. Developers can also explore additional libraries such as those provided by third parties which might offer more specialized functionalities depending on project requirements. To install these libraries: - Open Preferences under File menu in Arduino IDE. - Add URL https://arduino.esp8266.com/stable/package_esp8266com_index.json to Additional Board Manager URLs field. - Navigate Boards Manager via Tools -> Board option. - Search esp8266 and proceed installing it. After installation completes successfully, one should be able to select boards from the family of ESP8266 when choosing target hardware platforms inside Arduino IDE settings. Additionally, alternative environments like PlatformIO are compatible not only with standard Arduino models but extend support towards other popular microcontroller units including ESP8266 series too[^2]. Below shows how simple code snippet looks while utilizing built-in WiFi features offered by official ESP8266ArduinoCore SDK after proper configuration has been done previously mentioned steps above: ```cpp #include <ESP8266WiFi.h> const char* ssid = "yourNetworkName"; const char* password = "yourPassword"; void setup() { Serial.begin(115200); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi..."); } Serial.println("Connected!"); } void loop() {} ``` This example demonstrates basic connectivity establishment between your device running firmware compiled against ESP8266 core API set alongside any given wireless network identified by SSID along with corresponding security credentials.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值