惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页
雷峰网
雷峰网
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学
腾讯CDC
T
Tailwind CSS Blog
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
The Cloudflare Blog
D
DataBreaches.Net
Recent Announcements
Recent Announcements
Engineering at Meta
Engineering at Meta
B
Blog
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
博客园 - 司徒正美
MongoDB | Blog
MongoDB | Blog
Google DeepMind News
Google DeepMind News
Apple Machine Learning Research
Apple Machine Learning Research

Lan小站-嗯,不错! - 物联网

ESP8266开发板接入点模式 - Lan小站-嗯,不错! MicroPython控制ESP8266灯光开关 - Lan小站-嗯,不错!
ESP8266开发板无线终端模式 - Lan小站-嗯,不错!
Lan · 2021-02-25 · via Lan小站-嗯,不错! - 物联网
#include <ESP8266WiFi.h>  // 程序使用ESP8266WiFi库
const char *ssid = "WIFI名";  //WIFI名
const char *pwd = "密码"; //WIFI密码

void setup() {
  Serial.begin(9600);  //启动串口通讯
  WiFi.begin(ssid,pwd); //连接
  while (WiFi.status() != WL_CONNECTED){
    delay(1000); //每隔一秒重连一次
    Serial.print('.');
  }
  Serial.print("IP:");
  Serial.print(WiFi.localIP()); //输出IP
}

void loop() {
  // put your main code here, to run repeatedly:

}

连接WIFI并输出IP地址

升级版,多个WIFI备选

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

ESP8266WiFiMulti wifiMulti; //实例化对象

void setup()
{
  Serial.begin(9600);
  wifiMulti.addAP("WI-FI","12345678");
  wifiMulti.addAP("WI-FI_5G","12345678");
  
  while (wifiMulti.run() != WL_CONNECTED)
  {
    delay(1000);
    Serial.print('.');
  }
  Serial.print("Connected to ");
  Serial.println(WiFi.SSID());
  Serial.print("IP:");
  Serial.print(WiFi.localIP());
}

void loop()
{
  // put your main code here, to run repeatedly:
}

学习教程-太极创客:http://www.taichi-maker.com/homepage/esp8266-nodemcu-iot/iot-c/