Cov txheej txheem:

Tsab Ntawv Ceeb Toom Tswb Tswb Tswb: 11 Kauj Ruam (nrog Duab)
Tsab Ntawv Ceeb Toom Tswb Tswb Tswb: 11 Kauj Ruam (nrog Duab)

Video: Tsab Ntawv Ceeb Toom Tswb Tswb Tswb: 11 Kauj Ruam (nrog Duab)

Video: Tsab Ntawv Ceeb Toom Tswb Tswb Tswb: 11 Kauj Ruam (nrog Duab)
Video: Nraug txuj kev hlub 2024, Kaum ib hlis
Anonim
Tsab ntawv tsa suab nrhiav Tswb System
Tsab ntawv tsa suab nrhiav Tswb System

Nco tseg! Reactive Blocks tsis muaj rau rub tawm ntxiv. Lub koob yees duab USB yooj yim tuaj yeem siv los tshuaj xyuas cov lus tsa suab hauv chav. Hauv cov theem hauv qab no peb yuav qhia koj yuav ua li cas koj tuaj yeem siv Reactive Blocks los ua haujlwm npaj rau khiav Java daim ntawv thov uas xa SMS lossis Email thaum pom cov lus tsa suab. Nrog Reative Blocks koj ua Java SE daim ntawv thov kom lub tswb thov tuaj yeem siv rau ntawm ib lub tshuab nrog Java SE thiab lub koob yees duab txuas lossis ua ke. Daim ntawv thov tau yooj yim xa mus rau Pi txij li Raspbian tso tawm muaj Oracle Java ua ntej teeb tsa..

Nov yog yam koj xav tau:

  1. Raspberry Pi Qauv B+ nrog Raspbian OS
  2. Txuj USB lub koob yees duab
  3. Ethernet cable
  4. Screen thiab keyboard rau Pi
  5. Windows lossis MAC computer nrog JDK
  6. Nco tseg! Reactive Blocks tsis muaj rau rub tawm ntxiv. Koj yuav xav tau Reactive Blocks, Eclipse plugin, los teeb tsa daim ntawv thov.

Daim ntawv thov ceeb toom no yog ib qho ntawm ntau qhov piv txwv piv txwv uas tuaj yeem siv tau tom qab koj teeb tsa Reactive Blocks. Daim ntawv thov tau npaj tiav kom khiav tawm ntawm lub thawv thiab koj yuav tsis xav tau ib qho txuj ci Java programming kom ua tiav cov lus qhia. Txhawm rau ua koj tus kheej Reactive Blocks daim ntawv thov thiab tsim cov tsev, koj yuav tsum muaj txuj ci Java programmer. Thaum tsim cov ntawv thov nyuaj nrog ntau qhov kev ntsuas thiab ua haujlwm, Reactive Blocks ua rau nws yooj yim kom tau txais cov laj thawj thiab cov ntaub ntawv ntws raug. Reactive Blocks yog pub dawb rau qhib qhov haujlwm.

Kauj Ruam 1: Nruab Reactive Blocks

Reactive Blocks tau raug txiav lawm

Kauj ruam 2: Rub tawm daim ntawv thov los ntawm Lub Tsev Qiv Ntawv

Rub tawm daim ntawv thov los ntawm Lub Tsev Qiv Ntawv
Rub tawm daim ntawv thov los ntawm Lub Tsev Qiv Ntawv

Nco ntsoov tias koj tau qhib Reactive Blocks pom thiab tias koj nyob hauv Blocks view. From the Blocks view select the import button and choose Reference applications. Xaiv qhov project Motion Detection project. Txij ntawm no mus koj yuav raug nug kom sau npe nrog google ID. Qhov no yuav ua rau koj nkag mus tau sai rau cov tsev thaiv cov tsev qiv ntawv thiab hloov kho cov kab ke thiab qhia paub.

Txoj haujlwm tshawb nrhiav qhov koj tau rub tawm suav nrog peb daim ntawv thov, Tswb System SMS, Lub Tswb System Email thiab daim ntawv thov ntsuas qhov Test motion detection. Hauv qhov kev qhia no peb coj koj los ntawm Tswb System SMS. Yog tias koj xav xa Email koj tuaj yeem ua tib theem nrog Alarm System Email

Kauj Ruam 3: Daim Ntawv Thov Hauv Qib Siab

Daim Ntawv Thov Hauv Qib Siab
Daim Ntawv Thov Hauv Qib Siab

Cov kauj ruam no muab cov lus piav qhia txog daim ntawv thov. Thawj daim duab qhia pom daim duab ntawm qhov ua tiav daim ntawv thov zoo li nyob rau qib siab. Nws yog tsim los ntawm 7 lub tsev tsim khoom; 5 tus txheej txheem tsim tsev los ntawm cov tsev qiv ntawv thiab 2 qhov kev cai tsim ua ntu uas tau ua rau daim ntawv thov no.

Txheem Thaiv los ntawm IoT lub tsev qiv ntawv yog:

  • Grabber, tuav cov duab los ntawm lub koob yees duab USB
  • Tsab ntawv tsa suab nrhiav, ua qhov tseeb kuaj pom cov duab
  • Lub Sijhawm Teev Sijhawm, pib ntawm lub sijhawm raug thiab xa lub cim ntawm tus zuam tus pin txhua lub sijhawm.
  • Tsis Txaus Siab, thawb tawm thawj lub hauv paus ntawm kab. Kev tsis txaus siab uas tsuas yog ib qho lus tau xa mus rau SMS Xa block vim nws tsuas tuaj yeem ua cov lus ib zaug.
  • SMS Xa Buffered, xa SMS los ntawm Twilio cov kev pabcuam. Cov ntsiab lus yuav raug xa mus tsis raug los xyuas kom meej tias tsuas yog ib qho lus xa tuaj ib zaug.
  • Txwv, kom tsis txhob muaj SMS ntau dhau thaum pom tus neeg nkag mus.
  • Nyeem Java Properties file, nyeem cov ntaub ntawv teeb tsa los ntawm cov ntaub ntawv nkag
  • Saib, pom ib daim duab ntawm qhov screen.

Periodic Timer block ua haujlwm raws li lub tshuab ua haujlwm. Nws yuav muab cov zuam ib ntus uas xa lub teeb liab mus rau Grabber thaiv los ntawm tus pin tuav. Thaum qhov thaiv tau pib, cov xov cais tau pib nyeem cov ntaub ntawv los ntawm lub koob yees duab. Cov xov mloog rau kab lus txib. Thaum lub block tau txais cov lus txib los ntawm tus pin rub nws yuav coj ib daim duab thiab xa nws mus rau qhov kev xav e tus pin.

Cov duab tom qab ntawd dhau mus rau Motion Detection block uas ua qhov tseeb ntawm kev tshawb pom duab. Tsab ntawv tsa suab tshawb nrhiav tseem siv OpenIMAJ. Ib txoj hauv kev hauv qhov thaiv no piv ob daim duab thiab yuav chij hloov pauv cov duab thaum pom cov lus tsa suab. Txoj hauv kev yog siv CPU ntau heev thiab yuav tsum tau khiav hauv cov xov sib cais. Thaum pom cov duab nws tau tshaj tawm ntawm tsab ntawv motionDetected pin uas yuav ua rau muaj kev tsim tawm ntawm cov lus SMS.

Lub thawv xiav lub teeb yog txhua txoj hauv kev Java tshwj xeeb tau ua rau daim ntawv thov no. Nyem rau ntawm ib txoj hauv kev thaiv qhib Java editor.

Thaum koj nyem rau ntawm lub tsev thaiv koj tuaj yeem pom cov ntsiab lus ntawm cov laj thawj hauv lub block. Yog tias koj piv txwv li saib sab hauv ReadConfig thaiv koj yuav pom nws tau ua los ntawm kev sib txuas ib lub tsev uas twb muaj lawm thiab 4 txoj hauv kev Java.

Tus Limiter tso qhov txwv ntawm tus lej ntawm cov lus tsim tawm. Pom daim P nyob rau sab xis ntawm lub tsev thaiv. Nws qhia tias koj tuaj yeem teev cov kev pabcuam me me ntev npaum li cas daim ntawv thov yuav tsum tau tos ua ntej nws xa SMS tshiab. Lub neej ntawd teeb tsa yog 300000ms, piv txwv li 5 feeb. Los hloov tus nqi. Txoj cai nyem rau ntawm lub block thiab xaiv tsis thiab generics.

Kauj ruam 4: Pab kom SMS

Pab kom SMS
Pab kom SMS

Daim ntawv thov ceeb toom no siv Twilio ua kev pabcuam SMS. Txhawm rau pab kom SMS koj yuav tsum hloov kho cov ntaub ntawv teeb tsa/tswb-system.properties. Koj tuaj yeem pom nws hauv pob tshawb nrhiav hauv qab br.ref.motiondetection, saib daim duab.

Cov ntaub ntawv no yog tib cov ntaub ntawv siv hauv Tswb System Email. Yog tias koj muaj email ceeb toom koj yuav siv daim ntawv thov no thiab kho cov ntaub ntawv nrog koj li ntawv pov thawj email.

Yog tias koj tsis muaj Twilio kev pabcuam koj tuaj yeem hloov kho daim ntawv thov kom siv koj li kev pabcuam SMS. Peb kuj tseem npaj tau siv lub tsev thaiv rau Clickatell kev pabcuam. Lossis koj tuaj yeem txuas tus modem xa SMS.

Koj tuaj yeem pom cov tsev thaiv rau SMTP email, AirVantage Cloud, IBM Bluemix thiab Xively rau npe ob peb.

Nco ntsoov tias txhawm rau hloov pauv, koj yuav tsum xub ua koj li haujlwm. Tom qab ntawd luam/theej daim ntawv thov rau hauv koj qhov haujlwm tshiab uas tau tsim. Koj tuaj yeem pom yuav ua li cas thiaj ua tiav ntawm no:

Tsis txhob yig tiv tauj kuv yog tias koj xav tau kev pab

Kauj ruam 5: Tsim thiab Khiav Daim Ntawv Thov ntawm Koj Lub Laptop

Tsim thiab Khiav Daim Ntawv Thov ntawm Koj Lub Laptop
Tsim thiab Khiav Daim Ntawv Thov ntawm Koj Lub Laptop

Koj yuav tsum tsim daim ntawv thov ua ntej koj ua nws, thiab xa nws mus rau Raspberry Pi. Qhov no tau ua tiav siv Reactive Blocks code generator uas tsim cov haujlwm Java tiav los ntawm cov qauv ntawm cov tsev tsim. Cov cai uas sawv cev rau daim duab kos yog kev ua haujlwm sib kho uas ua haujlwm cov xwm txheej hauv qhov raug thiab raws lub sijhawm, thiab feem ntau suav nrog ntau dua 60% ntawm kab ntawm cov cai hauv koj qhov haujlwm. Txij li cov tsev tsim muaj cov lej ua tau zoo lub tshuab hluav taws xob tuaj yeem hloov qhov kev xav no mus rau txoj cai zoo. Qhov no yog qhov zoo heev Reactive Blocks feature vim tias los sau cov cai no ntawm tus kheej yog qhov nyuaj thiab nyuaj. Txhawm rau tsim cov cai, qhov no yog txhua yam koj yuav tsum tau ua:

Txoj cai nyem rau txoj haujlwm Tswb System SMS hauv qab Cov Haujlwm tab thiab Xaiv Java tus qauv txheej txheem. Nco ntsoov tias cov ntaub ntawv nkag mus yog INFO. Cov phiaj xwm tsim tawm yuav qhib tam sim ntawd hauv qab Pob Ntawv Explorer tab. Saib daim duab kom paub meej.

Kauj Ruam 6: Khiav Daim Ntawv Thov ntawm Koj Lub Computer

Khiav daim ntawv thov ntawm koj lub computer
Khiav daim ntawv thov ntawm koj lub computer
Khiav daim ntawv thov ntawm koj lub computer
Khiav daim ntawv thov ntawm koj lub computer

Tam sim no koj tuaj yeem ua qhov project tsim tawm. Hauv pob Explorer pom hauv qab qhov tsim tawm _exe txoj haujlwm, nyem rau AlarmSystemSMS.launch thiab xaiv RunAs thiab tom qab ntawd xaiv AlarmSystemSMS.

Saib lub qhov rai ntawm qhov screen thiab saib Console. Yuav tsum saib qee yam zoo li daim duab thib ob.

Txiav daim ntawv thov los ntawm kev kaw lub koob yees duab qhov rai.

Rau qhov xa email thov: Yog tias koj tau txais kev lees paub yuam kev, nco ntsoov tias SMTP tau tso cai rau koj li email. Saib kev daws teeb meem hauv qab ntawm email qhia:

Kauj Ruam 7: Export Raws Li Runnable JAR File

Export Raws li Runnable JAR Cov Ntaub Ntawv
Export Raws li Runnable JAR Cov Ntaub Ntawv

Yog tias koj xav khiav daim ntawv thov ntawm Raspberry Pi, cov kauj ruam tom ntej yog xa cov phiaj xwm tsim tawm mus rau cov ntaub ntawv JAR uas khiav tau. Txhawm rau ua qhov no, nyem rau txoj haujlwm ua tiav hauv pob tshawb pom thiab xaiv cov khoom xa tawm. Tom qab ntawv xaiv qhov Runnable JAR cov ntaub ntawv xaiv thiab ntaus tom ntej. Nyob rau hauv lub qhov rai hauv qab no xaiv qhov tsim nyog tsim teeb tsa thiab xa tawm cov hom phiaj. Hauv qhov chaw xa tawm, siv khawm xaub kom koj tuaj yeem tso.jar cov ntaub ntawv qhov chaw uas koj tuaj yeem pom nws.

Kauj Ruam 8: Npaj Koj Raspberry Pi

  • Npaj daim npav SD nrog Raspbian (peb tau sim siv NOOBS)
  • Ntxig daim npav SD rau hauv Raspberry pi
  • Txuas lub koob yees duab
  • Txuas lub network
  • Txuas lub vijtsam thiab keyboard rau Pi
  • Pib Raspberry pi los ntawm kev txuas lub micro USB rau lub zog siv.
  • Tshawb nrhiav tus IP chaw nyob ntawm koj tus Raspberry Pi. Thaum pib pib, koj tus Raspberry Pi yuav tshaj tawm qee yam xws li "Kuv tus IP chaw nyob yog 10.10. 15.107"
  • Peb tau sim nrog Raspbian (tus ID nkag mus tsis raug: pi, password: raspberry), uas suav nrog Java los ntawm lub neej ntawd.

Kauj Ruam 9: Siv Daim Ntawv Thov rau Koj Raspberry Pi

Txhawm rau luam cov ntawv ntim tau los ntawm koj lub khoos phis tawj mus rau Rapsberry Pi ua raws cov theem no:

  • Qhib lub davhlau ya nyob twg ntawm koj lub tshuab
  • Mus rau phau ntawv teev npe uas cov ntaub ntawv JAR tau tsim nyob
  • Ntaus scp alarmsystem.jar [email protected]: ~/
  • Koj yuav raug nug kom ua tus lej sib xyaw. "pi" yog lub npe siv tsis raug thiab "raspberry" tus password tsis raug
  • Mus rau phau ntawv teev npe qhov chaw teeb tsa cov ntaub ntawv tswb_system.properties nyob. Qhov yooj yim tshaj plaws rau kuv yog txhawm rau luam cov ntaub ntawv los ntawm Eclipse editor hla mus rau cov npe tib yam li cov ntawv thawv.
  • Ntaus scp motiondetection.ini [email protected]: ~/

10.10.15.107 yog IP chaw nyob, hloov nws los ntawm IP chaw nyob ntawm koj tus Raspberry Pi.

- Koj tuaj yeem tseem tuaj yeem siv lub cim xeeb lo los theej nws mus rau Pi

Kauj ruam 10: Khiav Daim Ntawv Thov ntawm Koj Raspberry Pi

Tam sim no koj tau npaj los khiav daim ntawv thov.

  • Nkag mus rau Raspberry Pi ncaj qha lossis nyob deb ntawm ssh.
  • Ua tus txheej txheem teeb tsa tshiab: mkdir teeb tsa
  • Txheeb xyuas yog tias cov ntaub ntawv JAR khiav tau thiab.ini tau theej rau Raspberry Pi
  • Txav cov ntaub ntawv.ini mus rau qhov teeb tsa directory: mv alarm_system.properties config/
  • Ntaus sudo java -jar alarmsystem.jar
  • Saib cov zis ntawm lub console
  • Txiav nrog ^C.

Kauj Ruam 11: Hloov Kho Koj Daim Ntawv Thov

Tam sim no koj tuaj yeem hloov kho thiab txuas ntxiv koj daim ntawv thov raws li koj nyiam. Yog tias koj xav txuas ntxiv cov txheej txheem tuaj txawv tebchaws zoo li lub tswb ceeb toom no, thawj zaug koj yuav tsum ua koj tus kheej txoj haujlwm thiab theej tawm lub tswb ceeb toom rau koj tus kheej txoj haujlwm.

Nco ntsoov tias txhawm rau hloov pauv, koj yuav tsum xub ua koj li haujlwm. Tom qab ntawd luam/theej daim ntawv thov rau hauv koj qhov haujlwm tshiab uas tau tsim. Koj tuaj yeem pom yuav ua li cas thiaj ua tiav ntawm no:

Ua raws IoT Tuturial txoj hauv kev kom tau txais cov lus piav qhia ib qib zuj zus ntawm yuav tsim lossis hloov kho tshwj xeeb li cas rau cov ntawv thov Reactive Blocks.

Pom zoo: