Cov txheej txheem:
- Kauj ruam 1: Taw qhia
- Kauj Ruam 2: Txoj hauv Kev Ua Kom ESP32
- Kauj ruam 3: Timer
- Kauj Ruam 4: Sab Nraud Wakeup (txuas ntxiv0)
- Kauj ruam 5: Sab Nraud Wakeup (ext1)
- Kauj Ruam 6: ULP Coprocessor Wakeup
- Kauj ruam 7: Touchpad
- Kauj Ruam 8: Nkag Siab Qhov Tsaug Zog
- Kauj Ruam 9: Nov Yog Qee Cov Lus Qhia Tseem Ceeb Ntxiv
- Kauj Ruam 10: Qhia tawm
- Kauj Ruam 11: WiFi NodeMCU-32S ESP-WROOM-32
- Kauj Ruam 12: Sib dhos
- Kauj Ruam 13: Txoj Haujlwm
- Kauj Ruam 14: Yuav tsum muaj Lub Tsev Qiv Ntawv
- Kauj Ruam 15: Cov Tsev Qiv Ntawv thiab Cov Txiaj Ntsig
- Kauj ruam 16: Teeb tsa
- Kauj Ruam 17: Loop, Callback & ConfigureDisplay
- Kauj Ruam 18: Print_wakeup_reason (paub qhov Ua rau Tsaug Zog)
- Kauj Ruam 19: Print_wakeup_touchpad (paub GPIO Kov)
- Kauj ruam 20: Rub tawm Cov Ntaub Ntawv
Video: Txuag Roj Teeb Lub Neej Nrog Tsaug Zog: 20 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:29
Koj puas xav siv roj teeb nrog koj ESP32? Yog tias yog, Kuv yuav tham txog hnub no qee cov ntaub ntawv tseem ceeb hais txog cov ncauj lus no. Peb paub tias lub microcontroller no siv ntau lub zog thaum nws xa cov ntaub ntawv. Nws siv ze rau 190 milliamps. Hauv cov vis dis aus no, kuv yuav qhia yuav ua li cas txuag hluav taws xob los ntawm ESP32 nrog qhov hu ua "DEEP SLEEP" ua haujlwm. Peb yuav teeb lub nti kom nkag mus rau hom no, kawm paub txoj hauv kev kom tawm ntawm hom no, thiab tsim ib qho piv txwv qhia peb txoj hauv kev sib txawv kom tsa ESP32.
Nws yog ib qho tseem ceeb kom nco ntsoov tias lub xov tooj cua siv ntau lub zog, ntau dua li tus txheej txheem. Kev txuag hluav taws xob tseem ceeb heev. Qhov no yog vim tias Endpoints (cov kab hluav taws xob uas xa cov ntaub ntawv) feem ntau siv roj teeb thiab yuav tsum kav ntev txog tsib xyoos. Muaj qee qhov chaw tsim khoom cog lus txog kaum xyoo nyob rau lub sijhawm, thiab qhov no siv tau rau cov roj teeb zoo uas tsis siv Cov Endpoints ntau npaum li cas. Hauv txhua qhov xwm txheej, Kuv qhia koj kom siv Deep Sleep kom txuag tau hluav taws xob los ntawm koj lub Circuit Court.
Kauj ruam 1: Taw qhia
ESP32 muaj lub zog txuag lub zog, hu ua "Deep Sleep." Hauv hom no, CPUs, feem ntau RAM, thiab tag nrho cov khoom siv digital clocked raug kaw. Tsuas yog ib feem ntawm cov nti uas tseem tuaj yeem txuas nrog tau yog RTC tus tswj hwm, RTC cov khoom siv txuas ntxiv (suav nrog ULP tus neeg tsim khoom), thiab RTC nco.
Peb muaj ntau txoj hauv kev los tsa ESP32 thaum tsaug zog. Kev tsim cov hauv paus tuaj yeem teeb tsa tau txhua lub sijhawm ua ntej nkag mus rau Deep Sleep mode.
Kauj Ruam 2: Txoj hauv Kev Ua Kom ESP32
Muaj tsib txoj hauv kev los tsim ESP32:
• Timer
• Sab nraud sawv (ext0)
• Kev sawv sab nraud (ext1)
• ULP coprocessor sawv
• Touchpad
Kauj ruam 3: Timer
RTC tus tswj hwm muaj lub sijhawm ua haujlwm uas tuaj yeem siv los qhib lub nti tom qab lub sijhawm tau teev tseg ua ntej. Lub sijhawm tau teev tseg nrog microsecond qhov tseeb.
esp_deep_sleep_enable_timer_wakeup (uint64_t time_in_us)
time_in_us> yog lub sijhawm hauv microseconds
Kauj Ruam 4: Sab Nraud Wakeup (txuas ntxiv0)
RTC IO module muaj cov laj thawj los ua rau lub tswb ceeb toom thaum ib qho ntawm RTC GPIOs nkag mus rau qib kev xav ua ntej. RTC IO yog ib feem ntawm lub zog sau npe ntawm RTC cov khoom siv sib txuas, yog li RTC cov khoom siv txuas ntxiv yuav raug khaws cia kom muaj sia nyob thaum pw tsaug zog yog tias qhov kev thov qhib no tau thov.
esp_deep_sleep_enable_ext0_wakeup (gpio_num_t gpio_num, qib theem)
gpio_num> GPIO tus lej siv los ua qhov chaw. Tsuas yog RTC-ua haujlwm GPIOs tuaj yeem siv: 0, 2, 4, 12-15, 25-27, 32-39.
qib> qib theem uas yuav ua rau lub tswb (0 = LOW, 1 = HIGH)
Kauj ruam 5: Sab Nraud Wakeup (ext1)
Tus tswj hwm RTC muaj cov laj thawj los ua lub tswb moos siv ntau RTC GPIOs.
esp_deep_sleep_enable_ext1_wakeup (uint64_t daim npog, esp_ext1_wakeup_mode_t hom)
daim npog> daim npog me me ntawm GPIO tus lej uas yuav ua rau muaj kev qhib. Tsuas yog RTC-qhib GPIOs tuaj yeem siv hauv qhov bitmap no: 0, 2, 4, 12-15, 25-27, 32-39.
hom> xaiv lub logic muaj nuj nqi siv los txiav txim qhov ua kom mob:
• ESP_EXT1_WAKEUP_ALL_LOW: sawv thaum tag nrho cov GPIO xaiv hauv LOW
• ESP_EXT1_WAKEUP_ANY_HIGH: sawv thaum twg ntawm qhov xaiv GPIOs yog HIGH
Kauj Ruam 6: ULP Coprocessor Wakeup
Tus ULP tus tsim ua haujlwm tuaj yeem ua haujlwm thaum lub nti nyob hauv Deep Sleep thiab tuaj yeem siv los tshawb nrhiav cov cuab yeej, saib xyuas ADC lossis muaj peev xwm kov lub ntsuas qhov tseem ceeb, thiab qhib lub nti thaum pom qhov xwm txheej tshwj xeeb.
ULP coprocessor yog ib feem ntawm lub zog sau npe ntawm RTC cov khoom siv thiab ua haujlwm cov haujlwm khaws cia hauv lub cim xeeb qeeb RTC. Yog li ntawd, RTC cov khoom siv txuas ntxiv thiab RTC lub cim xeeb qeeb yuav tau qhib thaum pw tsaug zog yog tias hom kev ua kom raug thov no.
Kauj ruam 7: Touchpad
RTC tus tswj hwm muaj cov laj thawj los ua lub tswb siv lub peev xwm kov lub ntsej muag. Lub ntsiab lus ntawm tus kov tus pin, txawm li cas los xij, txawv. Peb yuav tsum siv qhov cuam tshuam cuam tshuam rau txhua tus pin xav tau.
Tom qab teeb tsa kev cuam tshuam, peb tau qhib lub hom kom sawv los siv cov ntsuas.
// Kho qhov Touchpad li qhov tsim tawm qhov chaw esp_sleep_enable_touchpad_wakeup ();
Kauj Ruam 8: Nkag Siab Qhov Tsaug Zog
Tom qab teeb tsa hom kev sawv, ib lo lus txib kom tso ESP32 hauv Deep Sleep mode (siv 2.5 μA lossis tsawg dua) yog txaus. Kuv hais meej ntawm no tias qhov kev siv nyiaj no yog los ntawm ESP nti thiab tsis yog phaj, vim tias tom kawg siv ntau dua.
esp_deep_sleep_start ();
Los ntawm cov lus txib no, ESP32 tsaug zog thiab tsis ua txoj kab txuas ntxiv ntawm cov cai piv txwv.
Tseem ceeb: Txhua qhov teeb tsa sawv yuav tsum tau ua ua ntej ua tiav cov lus txib saum toj no.
Kauj Ruam 9: Nov Yog Qee Cov Lus Qhia Tseem Ceeb Ntxiv
Kev hu hauv qab no rov qab ua rau ESP32 sawv.
1: EXT0 2: EXT1 3: TIMER 4: TOUCHPAD 5: ULP
esp_sleep_get_wakeup_cause ();
Yog tias peb teeb tsa sawv los ntawm lub touchpad, peb tuaj yeem rov qab tau qhov GPIO uas kov tau tshwm sim los ntawm kev hais kom ua
esp_sleep_get_touchpad_wakeup_status ();
Txhua lub sijhawm ESP32 sawv los, nws yuav rov los teeb tsa dua. Yog li txhua qhov kev hloov pauv uas tsis tau hais tseg hauv RTC nco yuav rov qab mus rau lawv lub xeev.
Txhawm rau khaws qhov sib txawv hauv kev nco txawm tias tom qab tsaug zog, siv qhov kev tshaj tawm tsis sib xws hauv qhov piv txwv hauv qab no:
// RTC_DATA_ATTR aloca a variável na memória RTCRTC_DATA_ATTR int bootCount = 0;
Kauj Ruam 10: Qhia tawm
Cov vis dis aus qhia qhov haujlwm ua haujlwm, raws li daim duab.
Kauj Ruam 11: WiFi NodeMCU-32S ESP-WROOM-32
Kauj Ruam 12: Sib dhos
Kauj Ruam 13: Txoj Haujlwm
Tam sim no peb yuav ua qhov haujlwm uas peb yuav teeb tsa ESP32 kom nkag mus rau Deep Sleep mode. Qhov no yuav sawv hauv peb txoj hauv kev sib txawv: ib qho rau Sab Nraud wakeup (ext0), ib qho rau Timer, thiab ib qho rau Touchpad. Lawv tsis tuaj yeem ua haujlwm ua ke, yog li peb yuav siv qhov sib txawv uas yuav yog lub txee rau tus lej ESP32 muab Boot los teeb tsa txoj hauv kev kom sawv.
Kauj Ruam 14: Yuav tsum muaj Lub Tsev Qiv Ntawv
Txhawm rau tswj cov zaub OLED, peb xav tau lub tsev qiv ntawv sab nraud. Txog qhov no, peb yuav rub lub tsev qiv ntawv U8g2.
Hauv Arduino IDE, mus rau Sketch menu >> Xws li Lub Tsev Qiv Ntawv >> Tswj Lub Tsev Qiv Ntawv….
Kauj Ruam 15: Cov Tsev Qiv Ntawv thiab Cov Txiaj Ntsig
Peb tau suav nrog lub tsev qiv ntawv los tswj cov zaub OLED, nrog rau tus tsim ntawm cov khoom siv saib ua piv txwv. Tsis tas li, peb faib qhov sib txawv hauv RTC nco. Peb teeb tsa qhov rhiab heev rau kev lees paub kov, microsecond hloov pauv hloov rau vib nas this, thiab lub sijhawm ESP32 mus rau hom pw tsaug zog (hauv vib nas this).
#include // biblioteca para controle do display oled
// construtor da instancia do controlador do display // SDA = 21 e SCL = 22 U8X8_SSD1306_128X64_NONAME_SW_I2C zaub (SCL, SDA, U8X8_PIN_NONE); // RTC_DATA_ATTR aloca a variável na memoria RTC RAT_DATA_ATTR int bootCount = 0; // sensibilidade para aceitação do toque #define Threshold 40 // fator de conversão de microsegundos para segundos #define uS_TO_S_FACTOR 1000000 // tempo que o ESP32 ficará em modo sleep (em segundos) #define TIME_TO_SLEEP 3
Kauj ruam 16: Teeb tsa
Hauv Teeb, peb nce tus naj npawb ntawm lub sijhawm Boot tau tshwm sim. Peb hu lub luag haujlwm los luam Boot motif. Yog tias tus lej khau raj yog PAR, peb teeb tsa ESP32 kom sawv ntawm lub (EXT0) khawm. Yog tias nws yog ntau ntawm 3, peb teeb tsa ESP32 kom sawv los tom qab teem sijhawm. Txwv tsis pub, peb teeb tsa lub peev xwm kov kov kom sawv ESP32. Thaum kawg, peb teeb tsa Touchpad ua qhov chaw sawv thiab yuam ESP32 nkag mus rau hom pw.
teeb tsa tsis muaj dab tsi () {Serial.begin (115200); ncua (1000); // incrementa o numero de vezes que o BOOT ocorreu ++ bootCount; configureDisplay (); // chama a função para imprimir o motivo do BOOT print_wakeup_reason (); // se o numero de boot for PAR configuramos o ESP32 para despertar através do botão (EXT0) yog (bootCount % 2 == 0) {esp_sleep_enable_ext0_wakeup (GPIO_NUM_39, 1); // 1 = High, 0 = Low} // se rau multiplo de 3 configuramos o ESP32 para despertar depois de um tempo definido lwm yam yog (bootCount % 3 == 0) {esp_sleep_enable_timer_wakeup (TIME_TO_SLEEP * uS_TO_S_FACTOR); } // caso contrario configuramos os pinos de touch capacitivo para despertar o ESP32 lwm {{Teeb teeb cuam tshuam ntawm Touch Pad 5 (GPIO12) touchAttachInterrupt (T5, rov qab, Threshold); // Kho qhov Touchpad li qhov tsim tawm qhov chaw esp_sleep_enable_touchpad_wakeup (); } Serial.println ("entrando em modo pw tsaug zog"); esp_deep_sleep_start (); // força o ESP32 entrar em modo SLEEP}
Kauj Ruam 17: Loop, Callback & ConfigureDisplay
Hauv Loop, peb tsis muaj dab tsi ua. Peb mam li txuas ntxiv cuam tshuam kev hu rov qab yog tias peb muaj qee yam yuav tsum ua thaum cuam tshuam tshwm sim. Hais txog configureDisplay, peb pib ua cov zaub thiab teeb tsa qee yam tsis. Peb luam tawm ntawm lub vijtsam tus lej ntawm lub sijhawm Boot tau tshwm sim.
// nada a se fazer no loopvoid loop () {} // callback das interrupções void callback () {// caso queira fazer algo ao ocorrer a interrupção} void configureDisplay () {// inicializa o display e configura alguns parametros zaub pib (); display.setPowerSave (0); // modo powerSave (0-Off? 1-On) display.setFont (u8x8_font_torussansbold8_u); // fonte utilizada // imprime tsis muaj zaub os numero de vezes que aconteceu o BOOT display.drawString (0, 0, "BOOT NUM:"); display.drawString (0, 2, Txoj hlua (bootCount).c_str ()); display.drawString (0, 4, "MOTIVO:"); }
Kauj Ruam 18: Print_wakeup_reason (paub qhov Ua rau Tsaug Zog)
Ntawm no, peb muaj txoj haujlwm luam tawm qhov ua rau ESP32 sawv los. Txheeb tus pin thiab luam tawm ntawm cov zaub.
// função para imprimir a causa do ESP32 despertarvoid print_wakeup_reason () {esp_sleep_wakeup_cause_t wakeup_reason; Txoj hlua vim = ""; wakeup_reason = esp_sleep_get_wakeup_cause (); // recupera a causa do despertar switch (wakeup_reason) {case 1: vim = "EXT0 RTC_IO BTN"; tawg; rooj plaub 2: vim li cas = "EXT1 RTC_CNTL"; tawg; rooj plaub 3: vim li cas = "TIMER"; tawg; rooj plaub 4: vim li cas = "TOUCHPAD"; tawg; rooj plaub 5: vim li cas = "ULP PROGRAM"; tawg; vim: vim = "TSIS YOG CAUSE"; tawg; } Serial.println (vim li cas); display.clearLine (6); // apha a linha 6 do display.drawString (0, 6, vim li cas.c_str ()); // luam tawm qhov ua rau lub suab nrov tsis pom // se despertou por TOUCHPAD, então vamos verificar em qual dos pinos ocorreu yog (wakeup_reason == 4) {print_wakeup_touchpad (); // verifica o pino e imprime tsis muaj zaub}}
Kauj Ruam 19: Print_wakeup_touchpad (paub GPIO Kov)
Tam sim no, hauv theem no, peb muaj txoj haujlwm luam tus pin uas tau kov. Peb tau rov qab pom GPIO uas tsim lub ESP32 thiab luam tawm ntawm lub vijtsam.
// função para imprimir o pino que foi tocadovoid print_wakeup_touchpad () {touch_pad_t touchPin; touchPin = esp_sleep_get_touchpad_wakeup_status (); // rov ua haujlwm GPIO que despertou o ESP32 String GPIO = ""; hloov (touchPin) {rooj plaub 0: GPIO = "4"; tawg; rooj plaub 1: GPIO = "0"; tawg; rooj plaub 2: GPIO = "2"; tawg; rooj plaub 3: GPIO = "15"; tawg; rooj plaub 4: GPIO = "13"; tawg; rooj plaub 5: GPIO = "12"; tawg; rooj plaub 6: GPIO = "14"; tawg; rooj plaub 7: GPIO = "27"; tawg; rooj plaub 8: GPIO = "33"; tawg; rooj plaub 9: GPIO = "32"; tawg; default: Serial.println ("Wakeup tsis los ntawm touchpad"); tawg; } Serial.println ("GPIO:"+GPIO); display.clearLine (7); // apha a linha 7 do display.drawString (0, 7, "GPIO:"); display.drawString (6, 7, GPIO.c_str ()); // luam tawm lossis GPIO}
Kauj ruam 20: Rub tawm Cov Ntaub Ntawv
INO
Pom zoo:
Dab tsi yog PSM (Txuag Lub Zog Txuag) hauv LTE Cat.M1?: 3 Cov Kauj Ruam
Dab tsi yog PSM (Kev Txuag Lub Zog) hauv LTE Cat.M1?: LTE Cat.M1 (Cat.M1) yog tus qauv los ntawm 3GPP uas yog Lub Koom Haum Txuj Ci Txuj Ci Thoob Ntiaj Teb thiab tau pab thoob tebchaws los ntawm SKT. Tsis tas li, Cat.M1 yog tus sawv cev LPWAN (Tsawg-Lub Hwjchim Loj Hauv Cheeb Tsam Network) thev naus laus zis thiab tshwj xeeb hauv IoT daim ntawv thov d
Txuag Lub Neej Txaus Ntshai Nrog Lub Teeb Ntseg: 3 Kauj Ruam
Txuag Lub Neej Txaus Ntshai Nrog Lub Teeb Ntseg: Peb txhua tus cia siab tias peb tuaj yeem nyob tau yooj yim dua hauv tsev. Puas yog koj feem ntau tsis xis nyob vim tias qhov teeb ntawm lub teeb hauv tsev tsis ntse txaus? Lossis puas yog koj xav tias tsis txaus siab vim tias muaj nuj nqi ntawm cov teeb hluav taws xob hauv tsev? Lub teeb no tuaj yeem daws koj cov teeb meem
Lub Teeb Siv Lub Zog Txuag Siv Lub Tshuab Luam Ntawv thiab Thermistors: 6 Cov Kauj Ruam
Kev Siv Lub Zog Siv Lub Zog Txuag Siv Photocells thiab Thermistors: Cov lus qhia no yog tsim los qhia koj li cas kom txuag hluav taws xob los ntawm kev hloov lub teeb siv lub photocells thiab thermistors. Peb yuav qhia koj yuav ua li cas tsim cov Circuit Court thiab code Arduino siv MATLAB
DIY Loj & Tsim Lub Roj Teeb Lub Hwj Chim Backup Lub Tshuab Hluav Taws Xob W/ 12V Deep Cycle Roj Teeb: 5 Cov Kauj Ruam (nrog Duab)
DIY Loj & Tsim Lub Hwj Chim Lub Hwj Chim Backup Lub Tshuab Hluav Taws Xob W/ 12V Deep Cycle Batteries: *** Nco tseg: Ceev faj thaum ua haujlwm nrog roj teeb thiab hluav taws xob. Tsis txhob roj teeb luv. Siv cov cuab yeej insulated. Ua raws txhua txoj cai kev nyab xeeb thaum ua haujlwm nrog hluav taws xob. *** Npaj ua ntej lub sijhawm tom ntej lub zog tawm nrog lub roj teeb tos
Cov Roj Teeb Lemon Me, thiab Lwm Cov Qauv rau Xoom Tus Nqi Hluav Taws Xob thiab Coj Lub Teeb Tsis Muaj Roj Teeb: 18 Kauj Ruam (nrog Duab)
Cov Roj Teeb Lemon Me, thiab Lwm Cov Qauv rau Xoom Tus Nqi Hluav Taws Xob thiab Coj Lub Teeb Tsis Muaj Roj Teeb: Nyob zoo, tej zaum koj twb paub txog txiv qaub roj teeb lossis roj teeb roj teeb. Lawv tau siv ib txwm siv rau lub hom phiaj kev kawm thiab lawv siv cov tshuaj tiv thaiv hluav taws xob uas tsim hluav taws xob qis, feem ntau pom nyob rau hauv daim ntawv ntawm cov coj lossis lub teeb ci ci. Cov no