Cov txheej txheem:

Tsev Automation Nrog Android thiab Arduino: Qhib Lub Qhov Rooj Thaum Koj Mus Tsev: 5 Kauj Ruam
Tsev Automation Nrog Android thiab Arduino: Qhib Lub Qhov Rooj Thaum Koj Mus Tsev: 5 Kauj Ruam

Video: Tsev Automation Nrog Android thiab Arduino: Qhib Lub Qhov Rooj Thaum Koj Mus Tsev: 5 Kauj Ruam

Video: Tsev Automation Nrog Android thiab Arduino: Qhib Lub Qhov Rooj Thaum Koj Mus Tsev: 5 Kauj Ruam
Video: Qhia teeb lub automatic anwering hauv what's app what's app automatic answer 2024, Kaum ib hlis
Anonim
Tsev Automation Nrog Android thiab Arduino: Qhib Lub Qhov Rooj Thaum Koj Mus Tsev
Tsev Automation Nrog Android thiab Arduino: Qhib Lub Qhov Rooj Thaum Koj Mus Tsev

Cov Lus Qhia no yog hais txog teeb tsa lub tsev siv tshuab hauv tsev kom tswj tau los ntawm lub xov tooj ntawm tes, siv kev sib txuas hauv is taws nem, yog li nws tuaj yeem nkag los ntawm txhua qhov chaw koj xav tau. Ntxiv mus, nws yuav ua qee yam kev ua thaum twg ua tau raws li qhov xav tau (zoo li, piv txwv li, qhib lub teeb thaum lub xov tooj smartphone txuas rau lub network wifi hauv tsev, qhib lub qhov rooj thaum koj nkag mus rau thaj tsam GPS txiav txim, lossis txhua yam uas koj xav tau).

Ib daim ntawv thov Android uas twb muaj lawm yuav raug siv, uas yuav tsum muaj qhov tsawg kawg ntawm kev ua lej tau: tsuas yog tso cov cai thiab koj ua tiav. Lub hlwb - tus tswj hwm microcontroller - yuav yog Arduino, lossis Arduino -siv tau lub rooj tsavxwm, xws li Aruino Uno nrog Ethernet shield lossis NodeMCU ESP8266.

Txhawm rau ua rau lub system thaum muaj xwm txheej tau ntsib (GPS txoj haujlwm, sijhawm, thiab lwm yam …) peb yuav siv lub Tasker tsis muaj npe; ntxiv rau qhov tom qab.

Hauv kev ua tiav cov kab ke cov ntsiab lus tseem ceeb hauv qab no tau muaj nyob hauv siab:

  • Nws yuav tsum tau pheej yig.
  • Nws yuav tsum siv tau los ntawm sab nraum lub network hauv tsev (piv txwv li koj lub wifi).
  • Nws yuav tsum yog tiag tiag yooj yim thiab nrawm los tsim thiab teeb tsa.
  • Nws yuav tsum ntseeg tau.

Qhov ntawd tau hais tias, tag nrho txoj haujlwm yuav raug nqi kwv yees 20 € (7.50 € rau ESP8266, 8 € rau pawg tswj hwm, qhov seem rau kho vajtse ntxiv), thiab yuav coj koj li 30 feeb los teeb tsa txhua yam - tsis phem hlo li.

Yog li, yog tias koj xav tau, ua raws cov lus qhia yooj yim thiab nrawm no, thiab teeb tsa koj tus kheej!

Kauj ruam 1: Teeb Kho Vajtse

Teeb Kho Vajtse
Teeb Kho Vajtse

Thaum koj tau sau tag nrho koj cov khoom, thawj qhov uas yuav tsum tau ua yog xaim nws tag nrho.

Hauv qhov piv txwv no peb yuav txuas lub teeb nrig mus rau ESP8266; Nco ntsoov tias koj yuav tsum tau ceev faj heev thaum ua haujlwm nrog lub zog tseem ceeb - tsev siv 220V, uas tuaj yeem tua koj! Ib txwm txiav lub zog ua ntej ua haujlwm rau nws, thiab yog tias koj tsis ntseeg siab tshawb nrhiav rau tus kws tshaj lij pab!

Qhov ntawd tau hais tias: txhawm rau tswj cov qib kev nruj thiab tam sim no (uas yuav hlawv tawm qhov me me ESPR8266) peb yuav tsum siv qhov kev xa khoom tsim nyog (zoo li qhov no yog 5V lub tswv yim, tsim nyog rau tus qauv Arduino, lossis qhov no, 3.3V logic level relay), tsim nyog rau 3.3V pinout ntawm ESP82666); kev sib txuas yog yooj yim zoo nkauj, ua raws daim duab peb tau txuas nrog.

Nco tseg tias qee lub rooj sib txuas sib txuas (zoo li qhov peb tau txuas nrog) yog QHOV QAB QAB; qhov no txhais tau tias koj yuav tsum txuas tus xa mus rau hauv av kom nws tig rau, thiab hloov pauv. Yog tias qhov no yog koj li ntaub ntawv, Homotica muab cov tshuaj zoo; peb yuav pom qhov twg hauv kab lus tom ntej.

Kauj ruam 2: ESP8266 Kev teeb tsa

ESP8266 Kev teeb tsa
ESP8266 Kev teeb tsa
ESP8266 Kev teeb tsa
ESP8266 Kev teeb tsa
ESP8266 Kev teeb tsa
ESP8266 Kev teeb tsa

Tam sim no uas peb tau teeb tsa kho vajtse ntawm lub tshuab ua haujlwm tsis zoo, peb yuav tsum tau teeb tsa lub microcontroller.

Txhawm rau ua qhov ntawd, peb yuav xav tau Arduino software txhawm rau rub cov duab kos rau ESP8266; yog li ntawd mus rau Arduino Download Nplooj Ntawv thiab rub cov ntawv uas haum rau koj tshaj plaws.

Thaum rub tawm, nruab nws.

Tam sim no peb tau teeb tsa peb li IDE, peb xav tau lub tsev qiv ntawv xav tau los kos duab ua haujlwm; txhawm rau nruab nws qhib App Github Repo thiab xaiv Rub tawm los ntawm lub pob ntsuab ntawm sab xis.

Lub taub hau mus rau Download nplaub tshev ntawm koj lub PC, thiab siv software zoo li WinRar lossis WinZip unzip cov ntawv; qhib daim nplaub tshev uas tsim tshiab "homotica-master" thiab luam daim nplaub tshev sab hauv lub npe "Homotica" mus rau Arduino Editor Libraries folder (feem ntau koj tuaj yeem pom nws hauv C: / Users / your_user_name / Documents / Arduino / libraries). Rho tawm cov ntawv ntxiv hauv "homotica-master", peb yuav tsis xav tau lawv

Ib kauj ruam ploj lawm los ntawm kev xa cov cai mus rau ESP8266: peb yuav tsum tau txais lub tsev qiv ntawv kom muaj Arduino IDE sib txuas lus nrog lub rooj tsavxwm, vim nws tsis tau lees paub.

Txhawm rau ua qhov ntawd, ua raws cov theem no (khab nias: Github ES8266 Arduino Repo):

  • Pib Arduino thiab qhib Cov Ntaub Ntawv> Nyiam qhov rai.
  • Nkag mus "https://arduino.esp8266.com/stable/package_esp8266com_index.json" (tsis hais nqe lus) rau hauv Pawg Thawj Saib Xyuas Haujlwm Ntxiv URLs teb. Koj tuaj yeem ntxiv ntau qhov URLs, cais lawv nrog tus lej.
  • Qhib Tus Thawj Saib Xyuas Haujlwm los ntawm Cov Cuab Yeej> Cov ntawv qhia zaub mov thiab teeb tsa esp8266 platform (tshawb rau "esp8266" thiab rub tawm "esp8266 los ntawm ESP8266 Zej Zog").

Txhua yam tau teeb tsa. Cia peb saib xyuas daim duab kos.

Qhib Cov Ntaub Ntawv> Piv txwv> Homotica> Homotica ESP8266, luam tag nrho cov cai hauv daim duab tshiab thiab hloov kho cov hauv qab no:

  • ssid: ntxig rau ntawm no lub npe ntawm koj lub wireless network
  • password: koj tus password wifi
  • ip, rooj vag, subnet: tej zaum koj yuav tsis tau kov cov teeb tsa no; hloov ip yog tias koj xav kom koj ESP8266 muaj lwm qhov chaw nyob
  • mUdpPort: qhov chaw nres nkoj uas peb yuav qhib hauv router tom qab; yog tias koj tsis paub nws yog dab tsi, tsis txhob kov nws
  • chaws: tus lej tshwj xeeb 8-tus lej uas yuav siv los txheeb xyuas koj li app; koj tuaj yeem xaiv yam koj xav tau.

Yog tias koj tab tom siv ACTIVE LOW teeb tsa, tsis txhob hnov qab hu rau homotica.setActiveLow () raws li qhia hauv tus lej piv txwv!

Txhawm rau ua kom tiav: ntxiv homotica.addUsedPin (5) (raws li qhia hauv qhov piv txwv) qhia rau ESP8266 uas GPIO nws yuav tsum tau ua, nruab nrab ntawm lub voj thiab homotica.set (mUdpPort, code); rho tawm txhua homotica.simulateUdp (…) kab.

Nov yog tus lej koj yuav tsum tau sab laug nrog:

#suav nrog

#include #include const char* ssid = "mywifiname"; const char* password = "wifipassword"; Tus IP chaw nyob IP (192, 168, 1, 20); IPAddress rooj vag (192, 168, 1, 1); IPAddress subnet (255, 255, 255, 0); unsigned int mUdpPort = 5858; Zoo li txoj hlua txoj cai = "aBc159"; Homotica homotica; teeb tsa tsis muaj dab tsi () {WiFi.config (ip, rooj vag, subnet); WiFi.begin (ssid, password); thaum (WiFi.status ()! = WL_CONNECTED) {ncua (500); } homotica.addUsedPin (5); homotica.setActiveLow (); // <- tsuas yog koj xav tau homotica.set (mUdpPort, chaws); } tsis muaj dab tsi voj () {homotica.refresh (); }

Thaum txhua yam raug teeb tsa kom raug, hloov kho cov teeb tsa los ntawm cov cuab yeej ntawv qhia zaub mov raws li cov duab txuas nrog, thiab xaiv qhov chaw nres nkoj koj ESP8266 txuas nrog koj lub khoos phis tawj hauv Cov Cuab Yeej> Chaw Nres Nkoj.

Tam sim no, nyem upload. Koj lub microcontroller tau teeb tsa thiab npaj khiav!

Kauj ruam 3: Router thiab IP

Router thiab IP
Router thiab IP
Router thiab IP
Router thiab IP

Txhawm rau sib txuas lus rau ESP8266 los ntawm txhua lub network, peb yuav tsum qhia lub router kom nyob hauv cov lus txib peb xa mus rau nws.

Txhawm rau ua qhov ntawd, mus rau koj nplooj ntawv teeb tsa router (feem ntau yog 192.168.1.1) thiab nrhiav qee yam xws li "virtual server" lossis "chaw xa khoom xa mus"; koj tuaj yeem nrhiav qhov tseeb teeb tsa rau koj tus qauv router tshawb hauv Google.

Hauv kev xa mus rau chaw nres nkoj, tsim txoj cai tshiab uas tso cai rau txhua qhov txuas mus rau ESP8266 (ib qho teeb tsa ua ntej) los ntawm ESP8266 chaw nres nkoj (dua, ib qho teeb tsa ua ntej). Npe nws Homotica, ntxig rau ESP8266 IP hauv IP teb, thiab txuag.

Yog tias lub router koj siv tsis tso cai rau koj ua qhov no, tsis txhob txhawj xeeb: koj yuav tsis tuaj yeem siv lub app los ntawm lub xov tooj ntawm tes, tab sis nws yuav ua haujlwm zoo kawg nkaus los ntawm sab hauv koj lub tsev wifi.

Tam sim no, kom xa mus rau peb lub router los ntawm lub ntiaj teb sab nrauv peb yuav tsum paub nws tus IP pej xeem; qhov tsis zoo yog qhov feem ntau ntawm cov kws muab internet tsis muab tus IP zoo li qub rau koj, tab sis qhov hloov pauv hloov pauv, uas hloov pauv lub sijhawm.

Tab sis tos, peb tuaj yeem daws qhov no!

Lub taub hau rau NoIp, tsim tus as khauj tshiab, tom qab ntawd tsim lub npe tshiab (saib daim duab txuas). Nco ntsoov dab tsi hostname koj muaj (hauv kuv tus piv txwv: https://yourhostname.ddns.net), thiab mus rau kauj ruam tom ntej.

(Nco tseg: koj yuav xav kom koj lub PC tau txais kev sib txuas ncaj qha koj tus IP IP nrog koj NoIp hostname: rub lawv cov app dawb los ua qhov ntawd)

Kauj ruam 4: App Configuration

App Configuration
App Configuration
App Configuration
App Configuration
App Configuration
App Configuration

Cia peb saib xyuas lub app, puas yog?

Rub tawm lub app los ntawm Play Store Page, thiab qhib nws.

Qhib cov ntawv qhia zaub mov sab laug, xaiv Boards, thiab tsim ib qho tshiab. Peb yuav sau rau hauv qhov ntsuas uas peb tau hais yav dhau los hauv ESP8266 daim duab kos duab:

  • Arduino Lub Npe: yam koj xav tau (cia qhov no yog ESP8266)
  • Tus tswv tsev IP: qhov no tuaj yeem yog

    • tus router zoo li qub IP hais txog NoIp txuas
    • ESP8266 IP yog tias koj xav siv nws tsuas yog sab hauv koj lub tsev wifi network 192.168.1.20
  • Chaw nres nkoj tus tswv: qhov peb teeb tsa thiab qhib ua ntej 5858
  • Tus lej cim: tus lej 8-char peb tau piav qhia hauv daim duab aBc195

Txuag. Qhib cov ntawv qhia zaub mov dua, tsim lub cuab yeej tshiab; peb yuav txuas lub teeb pom kev zoo rau kev ua qauv qhia:

  • Lub npe: lub teeb
  • Khawm lub npe: peb yuav siv On, xaiv yam koj nyiam
  • Tus lej tus lej: tus pin rau qhov peb txuas lub teeb nrig. Ceev faj! Ntawm ESP8266 tus lej cim npe (D1, D2…) tsis sib xws rau GPIO Pin npe! Tshawb hauv Google txhawm rau txiav txim siab tus pin twg yog GPIO (hauv peb qhov piv txwv: tus pin 5 tau sau tias D1)
  • Tus cwj pwm: koj tuaj yeem xaiv ntawm kev qhib, tua, hloov lub xeev ntawm "thawb" (tig rau tom qab) tua lub cuab yeej.

Txuag. Yog tias koj tau teeb tsa txhua yam kom raug kom txog rau tam sim no, Nias Ntawm lub teeb nrig yuav tsum qhib.

Txias, tsis yog nws?

Tam sim no koj tuaj yeem muaj kev lom zem ntxiv ntau lub cuab yeej, txawm tias muaj ntau lub laug cam, thiab npaj lawv hauv qhov xwm txheej.

Tab sis kom siv lub zog tag nrho yam koj nyuam qhuav tsim, peb yuav tau siv Tasker.

Kauj Ruam 5: Kev koom ua ke Tasker

Kev koom ua ke Tasker
Kev koom ua ke Tasker
Kev koom ua ke Tasker
Kev koom ua ke Tasker
Kev koom ua ke Tasker
Kev koom ua ke Tasker

Yog tias koj muaj Tasker, lossis xav yuav nws, nyeem ntxiv! Peb yuav siv nws los qhia Homotica yuav ua dab tsi thiab thaum twg yuav tsum ua.

Hauv qhov piv txwv no peb yuav tig lub teeb thaum twg peb txuas rau peb lub tsev wifi THIAB lub sijhawm nyob nruab nrab ntawm 4 teev tsaus ntuj txog 6 teev tsaus ntuj.

Qhib Tasker; tsim txoj haujlwm tshiab (cia lub npe nws Qhib Lub Teeb), xaiv Ntxiv> Plugin> Homotica, nias tus xaum xaum kom teeb tsa lub plugin. Xaiv Teeb> Nyob thiab Txuag. Rov qab mus rau cov ntawv qhia zaub mov tseem ceeb tsim qhov Profile tshiab, xaiv Xeev> WiFi txuas nrog, ntxig ncig Wifi npe hauv thaj teb SSID; nias rov qab thiab xaiv Turn On Light as enter activity. Tam sim no, nias ntev ntawm sab laug ntawm cov ntawv tsim tshiab, xaiv Ntxiv> Sijhawm> Los ntawm 4 teev tsaus ntuj txog 6 teev tsaus ntuj, tom qab ntawd kaw.

Peb ua tiav. Peb lub teeb yuav qhib thaum peb nkag mus hauv tsev nyob rau lub sijhawm peb teeb tsa.

Nws yog qhov yooj yim!

Tam sim no nws yog koj lub sijhawm: muaj tswv yim nrog Homotica thiab Tasker, thiab tsis txhob hnov qab qhia peb qhov koj tsim!

Pom zoo: