Cov txheej txheem:

Taw qhia rau ESP32: 10 Cov Kauj Ruam
Taw qhia rau ESP32: 10 Cov Kauj Ruam

Video: Taw qhia rau ESP32: 10 Cov Kauj Ruam

Video: Taw qhia rau ESP32: 10 Cov Kauj Ruam
Video: QHIA QHOV TSEEB - KUB VAJ LOOG TSUA NEW MUSIC VIDEO 2022 2024, Hlis ntuj nqeg
Anonim
Image
Image
Nta Tseem Ceeb
Nta Tseem Ceeb

Hauv kab lus no peb yuav tham txog ESP32, uas kuv xav tias yog tus tij laug ntawm ESP8266. Kuv nyiam qhov microcontroller no tiag tiag vim nws muaj WiFi. Tsuas yog koj muaj lub tswv yim, ua ntej ESP muaj, yog tias koj xav tau Arduino kom muaj WiFi, koj yuav tsum tau siv nruab nrab ntawm $ 200 thiab $ 300 los yuav Wifi adapter. Tus adapter rau network cable tsis kim heev, tab sis rau WiFi nws ib txwm ua thiab tseem kim. Tab sis hmoov zoo, Espressif Systems tau tshaj tawm ESP thiab tab tom daws peb lub neej.

Kuv nyiam ESP32 nrog hom ntawv no uas muaj USB chaw nres nkoj. Cov phiaj xwm NodeMCU no yooj yim los tswj vim nws tsis xav tau cov khoom siv hluav taws xob. Tsuas yog ntsaws rau hauv kab, txuas lub cuab yeej thiab ua haujlwm rau nws. Nws ua haujlwm zoo ib yam li Arduino.

Xijpeem, hnub no peb yuav tham txog txhua yam ntawm ESP32 thiab yuav teeb tsa Arduino IDE li cas rau ntau yam khoom siv ntawm hom. Tsis tas li peb yuav ua qhov haujlwm uas tshawb xyuas cov tes hauj lwm thiab qhia qhov twg yog qhov muaj zog dua.

Kauj Ruam 1: Cov Ntais Tseem Ceeb

Chip nrog built-in WiFi: tus qauv 802.11 B / G / N, ua haujlwm nyob ntawm thaj tsam 2.4 txog 2.5GHz

Hom kev ua haujlwm: Client, Access Point, Station + Access Point

Dual core microprocessor Tensilica Xtensa 32-ntsis LX6

Kho lub moos los ntawm 80MHz txog 240MHz

Ua haujlwm voltage: 3.3 VDC

Nws muaj SRAM ntawm 512KB

Nta 448KB ROM

Nws muaj lub cim xeeb sab nraud ntawm 32Mb (4 megabytes)

Qhov siab tshaj tam sim no rau tus pin yog 12mA (nws raug nquahu kom siv 6mA)

Nws muaj 36 GPIOs

GPIOs nrog PWM / I2C thiab SPI kev ua haujlwm

Nws muaj Bluetooth v4.2 BR / EDR thiab BLE (Bluetooth Tsawg Zog)

Kauj Ruam 2: Sib Piv Ntawm ESP32, ESP8266 thiab Arduino R3

Kev Sib Piv Ntawm ESP32, ESP8266 thiab Arduino R3
Kev Sib Piv Ntawm ESP32, ESP8266 thiab Arduino R3

Kauj Ruam 3: Hom ESP32

Hom ESP32
Hom ESP32

ESP32 tau yug los nrog ntau tus nus muag. Hnub no kuv siv thawj zaug los ntawm sab laug, Espressif, tab sis muaj ntau lub npe thiab hom, suav nrog Oled zaub built-in. Txawm li cas los xij, qhov sib txawv yog txhua yam tib lub nti: Tensilica LX6, 2 Core.

Kauj Ruam 4: WiFi NodeMCU-32S ESP-WROOM-32

WiFi NodeMCU-32S ESP-WROOM-32
WiFi NodeMCU-32S ESP-WROOM-32

Nov yog daim duab ESP uas peb tab tom siv hauv peb lub rooj sib txoos. Nws yog lub nti uas muaj ntau qhov kev thov thiab lub zog. Lawv yog ob peb tus pin koj xaiv seb lawv xav ua haujlwm li digital analog, analog digital lossis txawm tias qhov ntawd ua haujlwm lub qhov rooj zoo li digital.

Kauj Ruam 5: Kho Arduino IDE (Windows)

Kev teeb tsa Arduino IDE (Windows)
Kev teeb tsa Arduino IDE (Windows)
Kev teeb tsa Arduino IDE (Windows)
Kev teeb tsa Arduino IDE (Windows)

Nov yog yuav teeb tsa Arduino IDE yog li peb tuaj yeem suav sau rau ESP32:

1. Rub cov ntawv los ntawm qhov txuas:

2. Unzip cov ntawv thiab luam cov ntsiab lus rau hauv qab no:

C: / Users / [YOUR_USER_NAME] / Documents / Arduino / hardware / espressif / esp32

Nco tseg: Yog tias tsis muaj cov npe "espressif" thiab "esp32", tsuas yog tsim lawv ib txwm muaj.

3. Qhib phau ntawv teev npe

C: / Users / [YOUR_USER_NAME] / Documents / Arduino / hardware / espressif / esp32 / cov cuab yeej

Khiav cov ntaub ntawv "get.exe".

4. Tom qab qhov "get.exe" ua tiav, ntsaws ESP32, tos kom cov tsav tsheb raug teeb tsa (lossis teeb tsa tus kheej).

Npaj txhij, tam sim no tsuas yog xaiv ESP32 pawg thawj coj hauv "cuab yeej >> pawg thawj coj saib" thiab sau koj cov cai.

Kauj ruam 6: WiFi Scan

Nov yog qhov piv txwv ntawm yuav ua li cas thiaj nrhiav tau cov WiFi sib txuas nyob ze ESP-32, nrog rau lub teeb liab lub zog ntawm txhua tus ntawm lawv. Nrog txhua qhov scan, peb tseem yuav pom tias lub network twg muaj lub teeb liab zoo tshaj plaws.

Kauj ruam 7: Code

Ua ntej peb suav nrog lub tsev qiv ntawv "WiFi.h", nws yuav tsim nyog tso cai rau peb ua haujlwm nrog daim npav network ntawm peb lub cuab yeej.

#suav nrog "WiFi.h"

Nov yog ob qhov kev hloov pauv uas yuav siv los khaws lub network SSID (lub npe) thiab lub zog teeb liab.

Txoj hlua networkSSID = ""; int zogSignal = -9999;

Kauj ruam 8: Teeb tsa

Hauv kev teeb tsa () muaj nuj nqi, peb yuav txheeb xyuas hom WiFi tus cwj pwm ntawm peb lub cuab yeej. Hauv qhov no, txij li lub hom phiaj yog txhawm rau tshawb nrhiav cov network uas muaj, peb yuav teeb tsa peb lub cuab yeej kom ua haujlwm "chaw nres tsheb".

void teeb () {// Initialize Serial nkag mus rau hauv Serial Monitor Serial.begin (115200);

// teeb tsa hom kev ua haujlwm ntawm WiFi raws li chaw nres tsheb WiFi.mode (WIFI_STA); // WIFI_STA yog qhov txuas tas li qhia qhov chaw nres tsheb

// txiav tawm ntawm qhov nkag mus yog nws twb txuas nrog WiFi.disconnect (); ncua (100);

// Serial.println ("Teeb tsa ua tiav");}

Kauj ruam 9: Loop

Hauv lub voj () ua haujlwm, peb yuav tshawb rau cov tes hauj lwm uas muaj thiab tom qab ntawd luam tawm cov cav hauv cov tes hauj lwm pom. Rau txhua ntawm cov tes hauj lwm no peb yuav ua qhov sib piv kom pom qhov uas muaj lub teeb liab siab tshaj plaws.

void loop () {// Serial.println ("pib scan"); // ua qhov kev txheeb xyuas ntawm cov tes hauj lwm uas muaj

int n = WiFi.scanNetworks ();

Serial.println ("Ua tiav Scan");

// txheeb xyuas yog tias koj tau pom ib lub network yog (n == 0) {Serial.println ("Tsis pom lub network"); } lwm {networkSSID = ""; StrengthSignal = -9999; Serial.print (n); Serial.println ("network pom / n"); rau (int i = 0; i <n; ++ i) {// luam tawm ntawm tus saib xyuas txhua tus ntawm tes hauj lwm pom Serial.print ("SSID:"); Serial.println (WiFi. SSID (kuv)); // network npe (ssid) Serial.print ("SIGNAL:"); Serial.print (WiFi. RSSI (kuv)); // teeb liab lub zog Serial.print ("\ t / tCHANNEL:"); Serial.print ((int) WiFi.channel (kuv)); Serial.print ("\ t / tMAC:"); Serial.print (WiFi. BSSIDstr (kuv)); Serial.println ("\ n / n"); yog (abs (WiFi. RSSI (i)) <abs (lub zogSignal)) {lub zogSignal = WiFi. RSSI (kuv); networkSSID = WiFi. SSID (kuv); Serial.print ("NETWORK nrog ZOO TSHAJ PLAWS ZOO TSHAJ PLAWS: ("); Serial.print (networkSSID); Serial.print (") - SIGNAL: ("); Serial.print (strengthSignal); Serial.println (")"); } ncua (10); }} Serial.println ("\ n ----------------------------------------- ------------------------------------------- / n ");

// ncua sijhawm 5 vib nas this los ua qhov kev ncua scan tshiab (5000); }

"Yog tias (abs (WiFi. RSSI (i)))"

Nco ntsoov tias hauv nqe lus saum toj no peb siv abs (), txoj haujlwm no siv tus nqi meej (piv txwv li tsis zoo) ntawm tus lej. Hauv peb qhov xwm txheej peb tau ua qhov no txhawm rau nrhiav qhov tsawg tshaj plaws ntawm cov txiaj ntsig hauv kev sib piv, vim tias lub teeb liab siv tau muab ua tus lej tsis zoo thiab ze rau xoom zoo dua lub teeb liab.

Kauj ruam 10: Cov ntaub ntawv

Rub tawm tag nrho kuv cov ntaub ntawv hauv: www.fernandok.com

Pom zoo: