当前位置:网站首页>First knowledge of esp8266 (I) -- access point and wireless terminal mode
First knowledge of esp8266 (I) -- access point and wireless terminal mode
2022-07-27 21:53:00 【C V engineering lion】
One . Model is introduced
1. Access point mode : In access point mode ,ESP8266 Equivalent to a wireless router , Can send out wifi The signal , Other mobile computers can connect to this wifi The signal , But do not provide Internet service .
2. Wireless terminal mode : In wireless terminal mode ,ESP8266 Like mobile phones and computers , Equivalent to a terminal , Be able to connect other wifi The signal , In the same wifi The terminal under the signal can communicate .
Two . Function introduction
1.WiFi.softAP(ssid,password)
Parameters :ssid For the wifi Name of signal ,password Create for wifi The password of the signal
effect : In access point mode, use this function to create wifi The signal
2.WiFi.softAPIP()
effect : Print through this function in access point mode ESP8266 Of IP Address , here IP The address is fixed
3.WiFi.begin(ssid,password)
Parameters :ssid Is the name of the access wireless ,password Password for wireless access
effect : In wireless terminal mode , Access to ssid As the name ,password Wireless signal for password
4.WiFi.status()
effect : In wireless terminal mode , return esp8266 Access wireless status , If the wireless connection is normal , Then the return WL_CONNECTED.
5.WiFi.localIP()
effect : In wireless terminal mode , Back at this point ESP8266 Of IP Address , At this time IP The address is assigned by the wireless router
6.WiFi.SSID()
effect : Under the wireless terminal , Return the access wireless name
7.wifiMulti.addAP("HUAWEI Mate 30","1234567890")
effect : Add multiple wireless names and passwords ,ESP8266 Automatically select the connection with the strongest signal
8.wifiMulti.run()
effect : And WiFi.status() similar , Return to the state of accessing the strongest wireless
3、 ... and . Code
// Access point mode
#include <ESP8266WiFi.h>
void setup(void)
{
const char *ssid="GCR";
const char *password="12345678";
Serial.begin(9600);
// Create a GCR, The password for 12345678 Of wifi The signal
WiFi.softAP(ssid,password);
Serial.print("Access Point:");
Serial.println(ssid);
Serial.print("Address:");
// Print in access point mode IP Address
Serial.println(WiFi.softAPIP());
}
void loop(void)
{
}// Wireless terminal mode
#include <ESP8266WiFi.h>
void setup(void)
{
int i=0;
const char *ssid="HUAWEI Mate 30";
const char *password="1234567890";
Serial.begin(9600);
// Access name is HUAWEI Mate 30, The password for 1234567890 Of wifi
WiFi.begin(ssid,password);
Serial.print("Connect to:");
Serial.println(ssid);
// Judge WiFi Whether to access , If there is no access, wait
while(WiFi.status()!=WL_CONNECTED)
{
delay(1000);
Serial.print(i++);
Serial.print(" ");
}
Serial.println(" ");
Serial.println("Connect OK");
// Print after connecting IP Address
Serial.println(WiFi.localIP());
}
void loop(void)
{
}// Automatic connection is the strongest wifi
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
// Create a class , You can call the functions of this class
ESP8266WiFiMulti wifiMulti;
void setup(void)
{
int i=0;
Serial.begin(9600);
// Add these two WiFi, Connect whichever signal is strong
wifiMulti.addAP("HUAWEI Mate 30","1234567890");
wifiMulti.addAP("HUAWEI-B91AN8","ghs13934488149");
Serial.println("Connecting...");
// Judge the strongest signal wifi Whether to access , If there is no access, wait
while(wifiMulti.run()!=WL_CONNECTED)
{
delay(1000);
Serial.print(i++);
Serial.print(" ");
}
Serial.println(" ");
// Access successful , Print access wifi Name and IP Address
Serial.println(WiFi.SSID());
Serial.println(WiFi.localIP());
}
void loop(void)
{
}边栏推荐
- 异常-Exception
- Software test interview questions: the steps to write test cases by drawing cause and effect diagrams are___ And transforming the cause and effect diagram into a state diagram in five steps. What are
- CocoaPods 重装
- day 1 - day 4
- Plato Farm在Elephant Swap上铸造的ePLATO是什么?为何具备高溢价?
- Search, insert and delete of hash table
- Unit-- read Excel
- 2021-11-05理解main方法语法、代码块及final关键字
- 哈希表的查找与插入及删除
- 监听服务器jar运行,及重启脚本
猜你喜欢

Analysis of STL source code

Common shortcut keys and setting methods of idea

Idea connects to MySQL database and performs SQL query operations

B站崩了,那晚负责修复的开发人员做了什么?

How to realize a good knowledge management system?

IDEA常用快捷键及设置方法

Can JVM tuning be done with single core CPU and 1G memory?

@Detailed introduction of requestparam annotation

MySQL execution process and order

Plato Farm在Elephant Swap上铸造的ePLATO是什么?为何具备高溢价?
随机推荐
Basic usage of two-dimensional array
Simple manual implementation of map
Pytest failed and rerun
MySQL data recovery process is based on binlog redolog undo
day 1 - day 4
Oppo core making plan officially announced: the first chip or oppo M1
LinkedList underlying source code
华为成立全球生态发展部:全力推进HMS全球生态建设
Box model and element positioning
It seems to be a bug of thread pool, but I think the source code design is unreasonable.
内部类(四种内部类详解)
Unit-- read Excel
Under the epidemic, the mobile phone supply chain and offline channels are blocked! Sales plummeted and inventory was serious!
Understanding of L1 regularization and L2 regularization [easy to understand]
高并发遇到死锁了,如何搞?
Qmodbus library is used, and it is written as ROS node publishing topic and program cmakelist
异常-Exception
Software testing interview question: when does the software testing project start? Why?
排序(冒泡排序)后面学习持续更新其它排序方法
Dual process theory and triple mental model