Cov txheej txheem:

Arduino Raws Lub Suab-Tswj IOT Relay Hloov (Google Tsev & Alexa Txhawb): 11 Cov Kauj Ruam
Arduino Raws Lub Suab-Tswj IOT Relay Hloov (Google Tsev & Alexa Txhawb): 11 Cov Kauj Ruam

Video: Arduino Raws Lub Suab-Tswj IOT Relay Hloov (Google Tsev & Alexa Txhawb): 11 Cov Kauj Ruam

Video: Arduino Raws Lub Suab-Tswj IOT Relay Hloov (Google Tsev & Alexa Txhawb): 11 Cov Kauj Ruam
Video: Текстовые LCD дисплей на контроллере HD44780, Уроки Arduino 2024, Hlis ntuj nqeg
Anonim
Arduino Raws Lub Suab-Tswj IOT Relay Hloov (Google Tsev & Alexa Txhawb)
Arduino Raws Lub Suab-Tswj IOT Relay Hloov (Google Tsev & Alexa Txhawb)

Txoj haujlwm no piav qhia yuav ua li cas thiaj ua Arduino-based, tswj lub suab, IOT relay hloov. Qhov no yog qhov txuas uas koj tuaj yeem qhib thiab tua nyob deb siv lub app rau iOS thiab Android, ntxiv rau khi nws rau hauv IFTTT thiab tswj nws nrog koj lub suab siv Google Tsev thiab/lossis Alexa ib yam. Peb yuav npog tag nrho cov kauj ruam xav tau los tsim lub cuab yeej, txuas lub app, thiab txuas hauv ntau yam kev pabcuam IOT ib yam.

Khoom siv

  • Wemos D1 Mini Lite ESP8285 (ob peb daus las ntawm Amazon)
  • 5V Relay Module rau Arduino/Raspberry Pi
  • 2N2222 NPN transistor
  • 47K ohm resistor
  • 1K ohm tiv thaiv

Kauj ruam 1: Tsim Circuit Court

Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court

Thawj kauj ruam yog xaim xov hluav taws xob. Kuv tau suav nrog cov txheej txheem thiab kab kos kab ib txwm muaj, nyob ntawm seb koj tau siv li cas. Kuv tau ua kuv thawj lub Circuit Court ntawm ib lub khob cij ua ntej thiab tom qab ntawd hloov nws mus rau PCB rau kev teeb tsa tas mus li thiab nyob hauv lub thawv 3D luam tawm qhov project.

Cov kis tau tus mob yog opto-cais H/L 5V relay, uas txhais tau hais tias ua ntej, qhov ua rau lub tshuab hluav taws xob raug cais tawm ntawm kev xa mus rau nws tus kheej, uas tshem tawm txhua qhov teeb meem muaj peev xwm nrog kev tawm tswv yim rov qab mus rau Wemos microcontroller. Muaj kev nyab xeeb zoo. Qhov thib ob, nws yog qhov hloov pauv siab/qis, uas txhais tau tias nws tuaj yeem teeb tsa tau, los ntawm kev txav cov jumper daj uas koj pom hauv cov duab, los ntawm qhov ua rau thaum lub teeb liab siab (+5V), lossis ua rau thaum lub teeb liab qis (0V). Wemos nws tus kheej xa tawm 3.3V los ntawm nws cov pins digital thiab peb tab tom siv D1 raws li peb lub hauv paus ntsiab lus, uas txhais tau tias peb yuav tsum ua kom nrov nrov me ntsis, yog li peb tau ze rau +5V cov teeb liab digital los ua rau kev xa tawm. Hloov koj tuaj yeem siv 3.3V xa tawm thiab tshem tawm cov transistor lub tshuab hluav taws xob tiv thaiv hauv Circuit Court thiab mus ncaj qha los ntawm D1 mus rau lub teeb liab tus pin ntawm kev xa tawm. Kuv tsis muaj 3.3V xa tawm, yog li peb siv ntau dua 5V kev xa tawm thiab amp Circuit.

DC+ thiab DC- ntawm qhov txuas txuas mus rau 5V thiab GND pins ntawm Wemos, uas muab qhov hluav taws xob tsim nyog los ua haujlwm txuas. Kev xa tawm tau ntsuas los ntawm cov hluav taws xob me me txhua txoj hauv kev rau kab hluav taws xob, tab sis kuv siv qhov no los tswj cov ntawv thov hluav taws xob qis. Yog tias koj siv qhov no los tswj cov kab hluav taws xob, thov xyuas kom koj paub tias koj tab tom ua dab tsi, koj tsim nyog tau txais, thiab koj ua raws li kev ceev faj uas tsim nyog. Yog tias tsis yog, tsis txhob siv qhov no los tswj cov kab hluav taws xob daim ntawv thov.

Pin D1 ntawm Wemos txuas rau 47K ohm resistor uas pub rau hauv paus ntawm NPN transistor. Tus emitter txuas rov qab rau hauv av. Tus neeg khaws khoom tau txuas nrog lub teeb liab nkag ntawm qhov txuas. Kev xa tawm tau teeb tsa kom qis qis, yog li thaum D1 muab lub teeb liab, 3.3v lub teeb liab tau nce mus txog kwv yees li 5V thiab qhib qhov qhib. Thaum D1 qis dua, lub teeb liab mus rau qhov txuas mus qis thiab qhov txuas txuas tau kaw thiab ua tiav qhov Circuit Court.

Kuv tsis nco qab thaij duab ntawm kuv lub voj voos ib ntus ntawm daim ntawv qhia zaub mov, tab sis nws zoo nkaus li zoo li daim duab Fritzing saum toj no, yog nws pab tau. Kuv suav nrog cov duab ntawm kuv qhov xwm txheej tas mus li tas li koj tuaj yeem pom tias nws tau txuas li cas, yog tias koj xav tau qee qhov kev nkag siab lossis xav tau kev pom ntawm cov khoom tshwj xeeb uas kuv siv.

Kauj ruam 2: Programming the Wemos - Txheej txheem cej luam

Ib yam uas kuv nyiam txog Wemos yog tias lawv tuaj yeem tsim kho tau zoo ib yam li Arduino, siv tib IDE. Txawm li cas los xij, muaj ob peb kauj ruam ntawm no.

  1. Nruab Wemos cov tsav tsheb rau lub khoos phis tawj tuaj yeem tham nrog Wemos
  2. Hloov kho Arduino IDE yog li Wemos board muaj
  3. Ua qhov ntsuas "Blink" sai kom paub tseeb tias txhua yam ua haujlwm raug
  4. Tau teeb tsa nrog Blynk (Kuv paub tias nws tsis meej pem, tab sis nws yeej txawv dua li qhov "ntsuas ntsais")
  5. Tau txais daim ntawv thov los ntawm Blynk
  6. Hloov kho Wemos/Arduino code nrog Blynk cov ntaub ntawv
  7. Tshaj tawm cov cai rau koj teeb tsa Wemos.

Kauj ruam 3: Programming the Wemos - Install Drivers

Programming Wemos - Nruab Tsav Tsheb
Programming Wemos - Nruab Tsav Tsheb

Mus ntawm no (qhov txuas no zoo li hloov pauv tas li, Kuv yuav sim ua kom nws hloov tshiab):

www.wemos.cc/en/latest/ch340_driver.html

Thiab rub lub pob tsav tsheb raug rau koj OS. Tom qab ntawd rho tawm zip rau hauv cov npe thiab ua tiav "SETUP" daim ntawv thov los nruab nws.

Thaum kuv tau ua qhov no thawj zaug, Kuv tau txais qee qhov yuam kev weird txog nws tsis txhim kho. Kuv pom lwm tus neeg sau ntawv txog qhov no thiab lawv cov kev daws teeb meem, uas ua haujlwm rau kuv. Yog li yog tias koj tau txais qhov yuam kev, sim siv lub pob "Uninstall" thiab tom qab ntawd siv "Nruab" dua. Vam tias qhov no daws qhov teeb meem zoo li nws tau ua rau kuv.

Kauj Ruam 4: Ua Haujlwm Wemos - Hloov Kho Arduino IDE

Programming Wemos - Hloov kho Arduino IDE
Programming Wemos - Hloov kho Arduino IDE
Programming Wemos - Hloov kho Arduino IDE
Programming Wemos - Hloov kho Arduino IDE
Programming Wemos - Hloov kho Arduino IDE
Programming Wemos - Hloov kho Arduino IDE

Yog tias koj tsis tau teeb tsa Arduino IDE, nws yog lub sijhawm zoo los ua tam sim no. Koj tuaj yeem rub nws los ntawm www.arduino.cc

Nov yog cov ntaub ntawv hais txog yam peb tab tom yuav ua hauv theem no.

wiki.wemos.cc/tutorials:get_started:get_st…

  1. Cia peb teeb tsa lub rooj tsav xwm tshiab yog li nws pom tau tias yog qhov kev xaiv hauv Arduino IDE. Kauj Ruam 2 - 4 raug txiav tawm los ntawm phau ntawv teeb tsa ntawm nplooj ntawv github hauv qab no.

    github.com/esp8266/Arduino

  2. Pib Arduino IDE thiab qhib qhov Preferences window.
  3. Nkag mus "https://arduino.esp8266.com/stable/package_esp8266com_index.json" rau hauv Pawg Thawj Saib Xyuas Haujlwm Ntxiv URLs teb. Koj tuaj yeem ntxiv ntau qhov URL, cais lawv nrog tus lej.
  4. Qhib Tus Thawj Saib Xyuas Haujlwm los ntawm Cov Cuab Yeej> Pawg Thawj Coj> Tus Thawj Saib Xyuas Haujlwm (nyob rau sab saum toj), tshawb rau "esp8266" thiab teeb tsa cov npe esp8266 platform.
  5. Txog ntawm no koj yuav pom Wemos cov laug cam hauv Cov Cuab Yeej → Board: xxx Xaiv Wemos D1 Mini. Hauv kuv qhov xwm txheej, raws li koj tuaj yeem pom los ntawm daim duab, lub npe tshwj xeeb yog "LOLIN (WEMOS) D1 R2 & mini"
  6. Txuas lub USB cable ntawm lub khoos phis tawj thiab Wemos
  7. Pom zoo tias tam sim no "Chaw nres nkoj" tau ua haujlwm hauv Cov Ntawv Qhia Cuab Yeej thiab zoo li raug.

Kauj Ruam 5: Ua Haujlwm Wemos - Ntsuas Ntsig

Programming the Wemos - Blink Test
Programming the Wemos - Blink Test

Ua ntej peb mus ntxiv, peb yuav tsum paub tseeb tias peb tuaj yeem sib txuas lus nrog Wemos board thiab txhua yam zoo li qub. Qhov yooj yim tshaj plaws los ua qhov no yog ntsaws rau hauv USB cable thiab sim thiab thawb ib txoj haujlwm yooj yim mus rau Wemos. Blink yog qhov piv txwv yooj yim tshaj plaws thiab tau cawm kuv ntau qhov teeb meem thaum ua haujlwm nrog cov laug cam tshiab, uas kuv ib txwm ua qhov no ua ntej.

  1. Mus rau: Cov Ntaub Ntawv> Piv txwv> ESP8266> Nyem thiab ntsais qhov muag ntsais muag rau Wemos ntaus ntawv
  2. Sau thiab xa cov duab kos

Yog tias xiav LED pib ntsais muag txog ib zaug ib pliag, yog li koj zoo mus rau qib tom ntej! Yog tias tsis yog, rov qab mus thiab teeb meem cov kauj ruam dhau los. Saib yog tias muaj teeb meem nrog cov tsav tsheb thiab tus thawj tswj hwm. Kuv muaj qee qhov teeb meem nrog lub rooj tsav xwm pob rau ESP8266 thiab yuav tsum tshem nws tag thiab rov nruab nws vim tias muaj qee yam txawv nrog cov qauv uas tau tshwm sim. Tsis txhob tso tseg, thiab tshawb hauv internet tuaj yeem yog koj tus phooj ywg!

Xav tias txhua yam yog qhov zoo, mus rau kauj ruam tom ntej.

Kauj Ruam 6: Ua Haujlwm Wemos - Teeb Up Blynk

Programming the Wemos - Teeb tsa Blynk
Programming the Wemos - Teeb tsa Blynk
Programming the Wemos - Teeb tsa Blynk
Programming the Wemos - Teeb tsa Blynk
Programming the Wemos - Teeb tsa Blynk
Programming the Wemos - Teeb tsa Blynk

Hauv cov kauj ruam tom ntej no, peb yuav tsum teeb tsa tus as khauj nrog Blynk thiab tau txais tus lej cim rau peb kom siv los tswj lub Circuit Court peb tau tsim.

  1. Rub tawm lub app, thiab tsim ib tus as khauj (nws dawb)
  2. Tsim txoj haujlwm tshiab
  3. Xaiv Wemos D1 ua Kho Vajtse hauv qab Xaiv Ntaus
  4. Muab lub npe ua haujlwm thiab khaws hom txuas ua WiFi
  5. Nyem Tsim Txoj Haujlwm
  6. Txog tam sim no tus Auth Token yuav raug xa mus rau email chaw nyob uas koj siv thaum koj tsim koj tus lej Blynk. Txuag qhov ntawd rau tom qab, peb yuav muab cov txiaj ntsig tso rau hauv daim duab kos hauv cov kauj ruam tom ntej.
  7. Thaum koj tau mus rau qhov khoob khoob khoob khoob khoob khoob khawm, tsuas yog los so sab laug thiab koj yuav tau txais cov ntawv qhia zaub mov widget. Xaiv "Khawm" txhawm rau ntxiv "khawm" rau txoj haujlwm
  8. Xaiv lub pob thiab tom qab ntawd teeb tsa tus Pin los ntawm txhaj nws thiab xaiv "Digital" thiab "D1" ua tus pi thiab nyem "Ok"
  9. Txij ntawm no, txhua yam yuav tsum npaj kom txhij. Txhawm rau kom ua haujlwm no koj yuav xav xaiv daim duab peb sab icon nyob rau sab xis, tab sis nws yuav tsis ua haujlwm tseem tsis tau, txog thaum peb tau txais cov duab kos teeb tsa thiab teeb tsa, uas yog cov kauj ruam tom ntej!

Kauj Ruam 7: Ua Haujlwm Wemos - Txhim Kho Tsev Kawm Ntawv Blynk

Yuav kom tuaj yeem xa daim duab Blynk raws qhov kos duab, peb yuav tsum teeb tsa lawv lub tsev qiv ntawv. Cov ntsiab lus tuaj yeem pom ntawm no.

github.com/blynkkk/blynk-library/releases

Tsis tas li, rau qee qhov keeb kwm yav dhau, txheeb xyuas lawv lub vev xaib tseem ceeb ntawm no (https://blynk.io/en/getting-started)

Qhov no tau nkag siab rau kuv thaum xub thawj, tab sis nws yooj yim dua li nws lub suab. Tsuas yog unzip cov ntawv rau koj cov npe Arduino. Rau kuv qhov no nyob hauv / user / Documents / Arduino. Muaj twb muaj daim nplaub tshev hu ua "tsev qiv ntawv" nyob ntawd. Cov ntaub ntawv zip muaj "tsev qiv ntawv" thiab "cov cuab yeej" cov npe. Thaum koj unzip nws mus rau Arduino cov npe, nws ntxiv nws cov ntsiab lus rau cov tsev qiv ntawv thiab tsim cov cuab yeej yog tias nws tsis tau muaj.

Kauj Ruam 8: Ua Haujlwm Wemos - Sketch

Peb yuav luag tiav ntawm qhov no. Daim duab yog yooj yim zoo nkauj, nws ncaj los ntawm Blynk thiab qhov tseem ceeb txuas Blynk cov kev pabcuam thiab pawg thawj coj. Koj tuaj yeem siv lawv tus tsim ntawm no:

examples.blynk.cc/?board=WeMos%20D1&shield=ESP8266%20WiFi&example=Widgets%2FTerminal

Lossis koj tuaj yeem siv cov qauv no uas yuav tsum ua haujlwm rau koj. Tsuas yog xyuas kom koj hloov qhov txiaj ntsig rau daim ntawv pov thawj tus kheej thiab koj daim ntawv pov thawj rau koj lub network wifi.

/*************************************************************

Rub tawm Blynk lub tsev qiv ntawv tshiab kawg ntawm no: https://github.com/blynkkk/blynk-library/releases/latest Blynk yog lub platform nrog iOS thiab Android apps los tswj Arduino, Raspberry Pi thiab nyiam hauv Is Taws Nem. Koj tuaj yeem yooj yim tsim cov duab cuam tshuam rau txhua qhov koj cov haujlwm los ntawm kev yooj yim rub thiab xa cov widgets. Downloads, docs, tutorials: https://www.blynk.cc Sketch generator: https://examples.blynk.cc Blynk zej zog: https://community.blynk.cc Ua raws li peb: https://www.fb. com/blynkapp Blynk lub tsev qiv ntawv tau ntawv tso cai nyob hauv MIT daim ntawv tso cai Qhov piv txwv no yog nyob rau pej xeem. ********************************************************** ****** *********** Koj tuaj yeem xa/tau txais cov ntaub ntawv twg siv WidgetTerminal object. Teeb tsa txoj haujlwm app: Lub davhlau ya nyob twg txuas rau Virtual Pin V1 *************************************** **********************//*Hais tawm qhov no kom tsis txhob luam tawm thiab txuag chaw*/ #define BLYNK_PRINT Serial #include #include // Koj yuav tsum tau txais Kev Tso Cai Token hauv Blynk App. // Mus rau Qhov Chaw Haujlwm (icon txiv ntoo). char auth = "YourAuthToken"; // Koj li ntawv pov thawj WiFi. // Teeb tus password rau "" rau qhib tes hauj lwm. char ssid = "YourNetworkName"; char pass = "YourPassword"; // Txuas lub davhlau ya nyob twg virtual rau Virtual Pin V1 WidgetTerminal davhlau ya nyob twg (V1); // Koj tuaj yeem xa cov lus txib los ntawm Terminal rau koj kho vajtse. Tsuas yog siv // Tus Pin Zoo tib yam li koj lub davhlau ya nyob twg BLYNK_WRITE (V1) {// yog tias koj ntaus "Marco" rau hauv Terminal Widget - nws yuav teb: "Polo:" if (String ("Marco") == param.asStr ()) {terminal.println ("Koj hais tias: 'Marco'"); terminal.println ("Kuv hais tias: 'Polo'"); } lwm tus {// Xa nws rov qab terminal.print ("Koj hais tias:"); terminal.write (param.getBuffer (), param.getLength ()); terminal.println (); } // Xyuas kom txhua yam raug xa mus rau terminal.flush (); } void teeb () {// Debug console Serial.begin (9600); Blynk.begin (auth, ssid, dhau); // Koj tseem tuaj yeem hais qhia server: //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80); //Blynk.begin(auth, ssid, dhau, IPAddress (192, 168, 1, 100), 8080); // Qhov no yuav luam tawm Blynk Software version mus rau Terminal Widget thaum // koj lub khoos phis tawj tau txuas nrog Blynk Server terminal.println (F ("Blynk v" BLYNK_VERSION ": Pib ntaus ntawv")); terminal.println (F ("-------------")); terminal.println (F ("Hom 'Marco' thiab tau txais lus teb, lossis hom")); terminal.println (F ("lwm yam thiab tau txais nws luam rov qab.")); davhlau ya nyob twg.flush (); } tsis muaj dab tsi voj () {Blynk.run (); }

Kauj Ruam 9: Ua Haujlwm Wemos - Kawg Kawg

Image
Image

Thaum cov duab kos tau rub tawm, ua ke thiab xa cov duab kos thiab koj yuav tsum tau npaj los sim koj teeb tsa!

Qhib Blynk app, nyem daim duab peb sab hauv kaum sab xis rau koj li Wemos Project

Tom qab ntawd nyem lub pob! Koj yuav tsum hnov lub suab nyem nyem thiab cov xwm txheej LEDs ntawm lub rooj sib tham relay qhia tias kev hloov pauv tau hloov lub xeev.

Tam sim no koj tuaj yeem txuas qhov txuas mus rau ib daim ntawv thov hluav taws xob qis uas xav tau hloov pauv yooj yim thiab tswj nws los ntawm koj li Blynk app. Qhov kawg uas peb yuav tsum tau ua yog khi hauv IFTTT thiab siv Google lossis Alexa los tswj hwm Blynk system yog li peb tsis tas yuav ua los ntawm peb Blynk app.

Kauj Ruam 10: Tswj Blynk Nrog IFTTT thiab Google Tsev lossis Alexa

Kuv tab tom kwv yees ntawm qhov no tias koj muaj qee qhov paub nrog IFTTT. Yog tias tsis yog, muaj qee qhov kev qhia zoo heev uas yuav pab koj kawm paub siv thiab siv IFTTT li cas. Nws muaj zog heev thiab qee yam uas koj yuav xav kawm yog tias koj tsis tau paub dua.

  1. Tsim ib qho tshiab applet hauv IFTTT
  2. Xaiv Google Assistant ua "Yog Yog Qhov no" thiab siv "Cov Lus Yooj Yim" ua qhov ua rau. Rau kuv, txij li qhov no yuav qhib lossis tua kuv lub qhov cub, kuv cov lus yog "qhib lub qhov cub"
  3. Rau ntu "Tom Qab Ntawd", tshawb nrhiav thiab siv Webhooks
  4. Xaiv "Ua lub vev xaib thov"
  5. Rau qhov URL koj yuav xav siv:

    "https://blynk-cloud.com/XXXXYYYYZZZZZ/update/d5?value=1"

  6. Teem txoj hauv kev kom tau txais, hom ntsiab lus rau urlencoded, thiab koj tuaj yeem tawm ntawm BODY dawb paug thiab tom qab ntawd txuag

Tos ob peb feeb thiab tom qab ntawd mus tom ntej thiab sim koj cov kab lus nrog koj lub cuab yeej google hauv tsev. Kuv pom tias nws siv sijhawm li ob feeb rau nws kom npaj tau.

NCO TSEG: ib qho ntxiv uas yuav tau them sai sai rau ntawm no. Daim ntawv ceeb toom tias kuv siv "d5" hauv kuv qhov API hu, tab sis kuv txuas nrog tus pin D1 ntawm lub rooj tsavxwm. Nws coj kuv txog ib hnub los txheeb xyuas tias GPIO tus lej tus lej thiab lub vijtsam luam tawm tus lej ntawm lub rooj tsavxwm tsis zoo ib yam. Tom qab hloov qhov tseem ceeb nrog kev hu ncaj qha URL thiab ntsuas qhov ntsuas hluav taws xob ntawm tus pin sib txawv nrog lub ntsuas hluav taws xob, Kuv muaj peev xwm pom tias kev hu mus rau d1 ntawm API tau hloov pauv qhov hluav taws xob, tab sis tsis yog D1 ntawm pawg thawj coj. d5/GPIO 5 ua tau zoo sib xws rau D1 ntawm lub rooj tsavxwm. Thaum kuv tau hloov qhov ntawd, txhua yam ua haujlwm zoo nkauj!

Hooking Alexa zoo ib yam rau Google tsev, tsuas yog siv Alexa kev pabcuam ntawm IFTTT xwb.

Kauj Ruam 11: Xaus

Txij ntawm no mus, koj yuav tsum muaj lub suab tswj hwm IOT kev xa xov siv Wemos D1 mini lite. Txaus siab rau thiab hmoov zoo!

Ib zaug ntxiv, hluav taws xob yog qhov txaus ntshai, yog li thov ua tib zoo tiv thaiv thiab yog tias koj tsis tsim nyog, thov tsis txhob.

Pom zoo: