Cov txheej txheem:
- Kauj ruam 1: PINOUT
- Kauj ruam 2: WiFiManager
- Kauj Ruam 3: Nws Ua Haujlwm Li Cas
- Kauj ruam 4: Cov tsev qiv ntawv
- Kauj ruam 5: Kev ua haujlwm
- Kauj Ruam 6: Sib dhos
- Kauj ruam 7: Code
- Kauj ruam 8: Teeb tsa
- Kauj ruam 9: Loop
- Kauj ruam 10: Hu rov qab
Video: ESP8266 thiab ESP32 Nrog WiFiManager: 10 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:29
Koj puas paub WiFiManager? Nws yog lub tsev qiv ntawv uas ua haujlwm ua tus saib xyuas kev sib txuas wireless, thiab nrog nws, peb muaj txoj hauv kev yooj yim dua los teeb tsa ob qho Access Point thiab Chaw Nres Tsheb. Kuv tau txais ob peb lub tswv yim los tham txog cov ncauj lus no; yog li hnub no kuv yuav qhia koj txog lub tsev qiv ntawv no thiab nws cov haujlwm. Kuv tseem yuav ua qauv qhia ntawm nws siv nrog ob qho ESP32 thiab ESP8266.
Kauj ruam 1: PINOUT
Ntawm no kuv qhia tus lej PINOUT ntawm ob lub cuab yeej uas peb yuav siv:
- NodeMCU ESP-12E
- NodeMCU ESP-WROOM-32
Kauj ruam 2: WiFiManager
WiFiManager yeej tsis muaj dab tsi ntau tshaj li lub tsev qiv ntawv sau rau saum WiFi.h kom yooj yim tswj kev sib txuas wireless. Nco ntsoov tias nrog nws, peb muaj qhov chaw zoo dua los teeb tsa ob qho Access Point thiab Chaw Nres Tsheb. Txog Chaw Nres Nkoj, peb teeb tsa los ntawm lub portal hauv qhov browser.
Qee qhov tshwj xeeb:
• Nws nyob ntawm kev sib txuas tsis siv neeg
• Kev pib ua qhov tsis zoo siv lub portal
• Ua haujlwm xaiv hauv hom ob
Kauj Ruam 3: Nws Ua Haujlwm Li Cas
ESP yuav pib WiFi teeb tsa lub portal thaum txuas nrog thiab yuav khaws cov ntaub ntawv teeb tsa mus rau qhov tsis hloov pauv. Tom qab ntawd, kev teeb tsa lub portal tsuas yog pib dua yog tias lub pob nyem hauv ESP module.
Ntawm no koj tuaj yeem tshawb xyuas cov txheej txheem ntws thiab ua raws cov kauj ruam no ib kauj ruam:
1. Siv ib lub cuab yeej siv WiFi txuas nrog lub browser, txuas rau qhov chaw nkag tshiab tsim thiab nkag mus rau qhov chaw nyob 192.168.4.1.
2. Ntawm qhov screen koj yuav muaj ob txoj kev xaiv los txuas rau lub network uas twb muaj lawm:
• Kho WiFi
• Kho WiFi (Tsis Muaj Scan)
3. Xaiv ib qho ntawm cov tes hauj lwm thiab sau tus password (yog xav tau). Tom qab ntawv txuag thiab tos kom ESP rov pib dua.
4. Thaum kawg ntawm lub khau raj, ESP sim txuas rau lub network uas tau txais kev cawmdim. Yog tias koj tsis tuaj yeem ua qhov no, koj yuav qhib qhov Access Point.
Kauj ruam 4: Cov tsev qiv ntawv
Ntxiv tsev qiv ntawv "WifiManager-ESP32".
Mus rau https://github.com/zhouhan0126/WIFIMANAGER-ESP32 thiab rub lub tsev qiv ntawv.
Unzip cov ntawv thiab muab tso rau hauv cov ntawv qiv ntawm Arduino IDE.
C: / Program Files (x86) / Arduino / qiv
Ntxiv "DNSServer-ESP32" lub tsev qiv ntawv.
Mus rau https://github.com/zhouhan0126/DNSServer---esp32 txuas thiab rub lub tsev qiv ntawv.
Unzip cov ntawv thiab muab tso rau hauv cov ntawv qiv ntawm Arduino IDE.
C: / Program Files (x86) / Arduino / qiv
Ntxiv "WebServer-ESP32" lub tsev qiv ntawv.
Mus rau https://github.com/zhouhan0126/WebServer-esp32 txuas thiab rub lub tsev qiv ntawv.
Unzip cov ntawv thiab muab tso rau hauv cov ntawv qiv ntawm Arduino IDE.
C: / Program Files (x86) / Arduino / qiv
Nco tseg:
WiFiManager-ESP32 lub tsev qiv ntawv twb muaj cov kev teeb tsa uas ua haujlwm nrog ESP8266, yog li peb tsuas yog siv qhov no, tsis yog ob WiFiManager libs (ib qho rau txhua hom nti).
Raws li peb yuav pom tom qab, ESP8266WiFi thiab ESP8266WebServer yog cov tsev qiv ntawv uas peb tsis xav tau rub tawm, vim tias lawv twb tuaj thaum peb teeb tsa ESP8266 hauv Arduino IDE.
Kauj ruam 5: Kev ua haujlwm
Nov yog qee qhov haujlwm uas WiFiManager muab rau peb.
1. autoConnect
Qhov kev sib txuas autoConnect muaj lub luag haujlwm los tsim Chaw Nkag Nkag. Peb tuaj yeem siv nws hauv peb txoj hauv kev.
• autoConnect ("network name", "password"); - tsim lub network nrog lub npe txhais thiab tus password.
• autoConnect ("lub npe network"); - tsim lub network qhib nrog lub npe txhais.
• autoConnect (); - tsim kev qhib thiab tau txais lub npe network nrog lub npe yog 'ESP' + chipID.
2. pibConfigPortal
StartConfigPortal muaj nuj nqi yog lub luag haujlwm los tsim Lub Chaw Nkag Nkag yam tsis tau sim txuas rau lub network uas tau khaws tseg yav dhau los.
• startConfigPortal ("network name", "password"); - tsim lub network nrog lub npe txhais thiab tus password.
• startConfigPortal (); - tsim kev qhib thiab tau txais lub npe network nrog lub npe yog 'ESP' + chipID.
3. getConfigPortalSSID
Rov qab SSID ntawm lub portal (Access Point)
4. tau txais SSID
Qhov no rov qab SSID ntawm lub network uas nws txuas nrog.
5. getPassword
Qhov no rov qab lo lus zais ntawm lub network uas nws txuas nrog.
6. setDebugOutput
SetDebugOutput muaj nuj nqi yog luam tawm cov lus debug ntawm tus saib xyuas. Cov lus no twb tau hais tseg hauv lub tsev qiv ntawv. Thaum koj dhau los ntawm cov haujlwm, cov ntaub ntawv yuav raug luam tawm.
Los ntawm lub neej ntawd, txoj haujlwm no tau teeb tsa rau TRUE. Yog tias koj xav kom xiam cov lus, tsuas yog teeb tsa lub luag haujlwm rau FALSE.
7. setMinimumSignalQuality
SetMinimumSignalQuality ua haujlwm yog lub luag haujlwm rau lim cov tes hauj lwm raws li teeb liab zoo. Los ntawm lub neej ntawd, WiFiManager yuav tsis qhia kos npe-rau tes hauj lwm qis dua 8%.
8. setRemoveDuplicateAPs
Teeb tsa setRemoveDuplicateAPs yog lub luag haujlwm tshem tawm cov network sib tshooj.
Los ntawm lub neej ntawd nws tau teeb tsa rau TRUE.
9. setAPStaticIPConfig
Kev ua haujlwm setAPStaticIPConfig yog lub luag haujlwm rau teeb tsa qhov chaw nyob zoo li qub thaum nyob hauv hom kev nkag mus.
(IP, GATEWAY, SUBNET)
10. setSTAStaticIPConfig
SetSTAStaticIPConfig muaj nuj nqi yog teeb tsa qhov chaw nyob zoo li qub thaum nyob hauv chaw nres tsheb.
(IP, GATEWAY, SUBNET)
Koj yuav tsum ntxiv cov lus txib ua ntej autoConnect !!!
11. setAPCallback
SetAPCallback muaj nuj nqi yog qhia rau koj tias AP hom tau pib lawm.
Qhov ntsuas yog qhov ua haujlwm uas yuav tsum tau tsim los qhia nws li kev hu rov qab;
12. setSaveConfigCallback
SetSaveConfigCallback muaj nuj nqi yog qhia rau koj tias kev teeb tsa tshiab tau raug cawm thiab kev sib txuas tau ua tiav tiav.
Qhov ntsuas ntsuas yog lub luag haujlwm los tsim thiab qhia qhov no ua ib qho rov qab.
Koj yuav tsum ntxiv cov lus txib ua ntej autoConnect !!!
Kauj Ruam 6: Sib dhos
Piv txwv
Hauv peb qhov piv txwv, peb yuav tsim Access Point nrog ESP (cov cai yuav ua haujlwm rau ESP8266 thiab ESP32). Tom qab tsim AP, peb yuav nkag mus rau lub portal los ntawm IP 192.168.4.1 (uas yog lub hauv paus nkag mus rau nws). Yog li cia peb tau txais cov network muaj, xaiv ib qho thiab txuag. Los ntawm qhov ntawd, ESP yuav rov pib dua thiab sim txuas rau nws, thiab tom qab ntawd nws yuav ua haujlwm raws li lub chaw nres tsheb thiab tsis yog Qhov Chaw Nkag Mus.
Tom qab nkag mus rau qhov chaw nres tsheb, koj tuaj yeem ua ESP rov qab mus rau Access Point hom nkaus xwb los ntawm khawm.
Kauj ruam 7: Code
Tsev qiv ntawv
Ua ntej cia peb txhais cov tsev qiv ntawv uas peb yuav siv.
Nco ntsoov tias peb muaj #if txhais, #else, thiab #endif cov lus txib. Lawv yog qhov muaj cai suav nrog cov tsev qiv ntawv tsim nyog ntsig txog lub nti. Qhov no yog qhov tseem ceeb tshaj plaws los ua tib txoj cai ntawm ob qho ESP8266 thiab ESP32.
#if txhais (ESP8266)
#include // ESP8266 Core WiFi Library #else #include // ESP32 Core WiFi Library #endif
#if txhais (ESP8266)
#include // Local WebServer siv los ua haujlwm teeb tsa portal
#lwm
#include // Local DNS Server siv rau kev xa rov qab txhua qhov kev thov mus rau kev teeb tsa portal (https://github.com/zhouhan0126/DNSServer---esp32)
#ib
#include // Local WebServer siv los ua haujlwm teeb tsa portal (https://github.com/zhouhan0126/DNSServer---esp32) #include // WiFi Configuration Magic (https://github.com/zhouhan0126/DNSServer-- -esp32) >> https://github.com/zhouhan0126/DNSServer---esp32 (ORIGINAL)
Kauj ruam 8: Teeb tsa
Hauv kev teeb tsa, peb tau teeb tsa peb li WiFiManager hauv txoj kev yooj yim tshaj plaws. Cia peb tsuas yog txhais cov callbacks thiab tsim lub network.
const int PIN_AP = 2;
teeb tsa tsis muaj dab tsi () {Serial.begin (9600); pinMode (PIN_AP, INPUT); // tshaj tawm objeto wifiManager WiFiManager wifiManager;
// utilizando esse comando, as configurações são apagadas da memória // caso tiver salvo alguma rede para conectar automaticamente, ela é apagada. // wifiManager.resetSettings (); // callback rau quando entra em modo de configuração AP wifiManager.setAPCallback (configModeCallback); // hu rov qab rau quando se conecta em uma rede, ou seja, quando passa a trabalhar em modo estação wifiManager.setSaveConfigCallback (saveConfigCallback); // cria uma rede de nome ESP_AP com senha 12345678 wifiManager.autoConnect ("ESP_AP", "12345678"); }
Kauj ruam 9: Loop
Hauv lub voj, peb yuav nyeem tus lej khawm kom pom tias nws tau raug nias, thiab tom qab ntawd peb yuav hu rau txoj hauv kev kom rov qhib tau hom AP.
void voj () {
WiFiManager wifiManager; // se o botão foi pressionado yog (digitalRead (PIN_AP) == HIGH) {Serial.println ("resetar"); // tenta abrir o portal yog (! wifiManager.startConfigPortal ("ESP_AP", "12345678")) {Serial.println ("Falha ao conectar"); ncua (2000); ESP.restart (); ncua (1000); } Serial.println ("Conectou ESP_AP !!!"); }
Thaum koj nias lub pob, ESP yuav tawm hom Chaw Nres Tsheb thiab qhib koj li Access Point thiab portal.
Nco ntsoov tias peb tsis siv qhov resetSettings () hais kom ua. Cov teeb tsa tseem raug cawm tseg rau lub sijhawm tom ntej ESP khau raj.
Kauj ruam 10: Hu rov qab
Lub luag haujlwm hu rov qab, uas cuam tshuam nrog cov xwm txheej, ua haujlwm rau koj kom muaj lub sijhawm tseeb ntawm kev ua haujlwm, hauv peb qhov xwm txheej, nkag mus rau AP hom thiab hom chaw nres tsheb. Peb tuaj yeem siv qee qhov niaj hnub xav tau, xws li rov qab SSID los ntawm kev sib txuas hauv network, piv txwv.
// callback que indica que o ESP entrou no modo AP
void configModeCallback (WiFiManager *myWiFiManager) {// Serial.println ("Nkag mus rau hom teeb tsa"); Serial.println ("Nkag mus rau qhov tsis muaj kev teeb tsa"); Serial.println (WiFi.softAPIP ()); // luam tawm IP ua AP Serial.println (myWiFiManager-> getConfigPortalSSID ()); // luam tawm lossis SSID criado da rede
}
// callback que indica que salvamos uma nova rede para se conectar (modo estação)
void saveConfigCallback () {// Serial.println ("Yuav tsum txuag kev teeb tsa"); Serial.println ("Configuração salva"); Serial.println (WiFi.softAPIP ()); // luam tawm lossis IP rau AP}
Pom zoo:
Qhov muag tsis pom kev Nrog ESP8266, Google Tsev thiab Openhab Kev Sib Koom thiab Kev Tswj Xyuas Web: 5 Cov Kauj Ruam (nrog Duab)
Qhov muag tsis pom kev Nrog ESP8266, Google Tsev thiab Openhab Kev Sib Koom thiab Kev Tswj Xyuas Web: Hauv Cov Lus Qhia no kuv qhia koj li cas kuv ntxiv kev siv tshuab rau kuv qhov muag tsis pom. Kuv xav kom muaj peev xwm ntxiv thiab tshem tawm qhov kev siv tshuab nws, yog li txhua qhov kev teeb tsa yog clip ntawm.Qhov tseem ceeb yog: Stepper motor Stepper tsav tswj bij ESP-01 Iav thiab teeb tsa
Saib Xyuas thiab Sau Kub Nrog Bluetooth LE thiab RaspberryPi: 9 Kauj Ruam (nrog Duab)
Saib Xyuas thiab Sau Kub Nrog Bluetooth LE thiab RaspberryPi: Cov lus qhia no yog hais txog yuav ua li cas ua ke ntau qhov ntsuas kub ntsuas nrog Bluetooth LE sensor kab laum los ntawm Blue Radios (BLEHome) thiab RaspberryPi 3BT ua tsaug rau kev txhim kho ntawm Bluetooth LE tus qauv, muaj tam sim no tuaj yeem siv tau
DIY Huab Cua Raid Siren Nrog Cov Tiv Thaiv thiab Capacitors thiab Transistors: 6 Cov Kauj Ruam (nrog Duab)
DIY cua Raid Siren Nrog Cov Tiv Thaiv thiab Capacitors thiab Transistors: Qhov pheej yig Air Raid Siren DIY txoj haujlwm yog qhov tsim nyog rau kev tshawb fawb tus kheej oscillation Circuit tsim los ntawm tsuas yog resistors thiab capacitors thiab transistors uas tuaj yeem txhawb koj txoj kev paub. Thiab nws yog qhov tsim nyog rau Kev Tiv Thaiv Kev Kawm Txuj Ci rau Cov Menyuam, hauv
8 Relay Tswj Nrog NodeMCU thiab IR Txais Txais Siv WiFi thiab IR Chaw Taws Teeb thiab Android App: 5 Kauj Ruam (nrog Duab)
8 Relay Tswj Nrog NodeMCU thiab IR Txais Txais Siv WiFi thiab IR Chaw Taws Teeb thiab Android App: Tswj 8 qhov hloov pauv hloov siv nodemcu thiab ir tus txais tshaj wifi thiab ir chaw taws teeb thiab hauv app.the ir tej thaj chaw deb ua haujlwm ywj pheej ntawm wifi txuas. NTUJ
Kub thiab Vaum Zaub thiab Sau Cov Ntaub Ntawv Nrog Arduino thiab Ua: 13 Kauj Ruam (nrog Duab)
Kub thiab Vaum Zaub thiab Sau Cov Ntaub Ntawv Nrog Arduino thiab Ua: Intro: Qhov no yog Txoj Haujlwm uas siv Arduino board, Sensor (DHT11), lub khoos phis tawj Windows thiab Kev Ua Haujlwm (rub tawm dawb) program los tso saib Kub, Cov ntaub ntawv vaum hauv digital thiab bar kab ntawv, tso tawm lub sijhawm thiab hnub tim thiab suav lub sijhawm suav