Cov txheej txheem:
- Kauj ruam 1: Kho vajtse
- Kauj ruam 2: Arduino Sketch
- Kauj Ruam 3: Sinatra Ua Tus Kheej
- Kauj Ruam 4: Teeb Koj Lub Tshuab Txhim Kho
- Kauj ruam 5: Ruby ntawm Mac lossis Linux
- Kauj Ruam 6: Ruby ntawm Windows
- Kauj Ruam 7: Txheeb thiab Teeb Koj Ruby
- Kauj Ruam 8: Nruab Sinatra (txhua lub Platforms)
- Kauj ruam 9: Redis ntawm Mac lossis Linux
- Kauj ruam 10: Redis ntawm Windows
- Kauj Ruam 11: Tsim Daim Ntawv Thov Kev Pabcuam Web
- Kauj Ruam 12: Tso rau Huab Siv Heroku
- Kauj Ruam 13: Muab Txhua Qhov Ua Ke
- Kauj Ruam 14: Muaj peev xwm
Video: Tsev Ceeb Toom: Arduino + Cloud Messaging ntawm Cov Zaub Loj: 14 Cov Kauj Ruam (nrog Duab)
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:29
Hauv lub hnub nyoog ntawm xov tooj ntawm tes, koj yuav cia siab tias tib neeg yuav teb rau koj qhov kev hu 24/7.
Los yog … tsis. Thaum kuv tus poj niam rov los txog tsev, lub xov tooj tseem nyob hauv nws txhais tes, lossis lub roj teeb tiaj tus. Peb tsis muaj kab hauv av. Hu lossis SMSing kom thov nqa lub tsev los ntawm chaw nres tsheb ciav hlau thaum hmo ntuj los nag lossis hu xov tooj mus nug yog tias kuv cov yuam sij tseem nyob ntawm kuv lub rooj yog qhov kev xav tiag.
Kuv muaj qhov teeb meem no ntau zaus txaus los daws qhov kev daws teeb meem. Me ntsis ntawm tinkering nrog Arduino thiab Freetronics Dot Matrix Display (DMD) ua rau muaj kev cuam tshuam heev (rau kuv tus poj niam) lub cuab yeej, tab sis ib qho cuab yeej sib txuas lus zoo thiab cov ntaub ntawv chaw rau kuv. Kuv nyiam nws, thiab nws tsuas yog version 1!
Kev Ceeb Toom Hauv Tsev yog ua los ntawm cov ntu no:
- Freetronics Dot Matrix Zaub, uas yog kab ntawm 16x32 LEDs. Lawv tuaj hauv cov xim sib txawv, tab sis kuv siv liab los hais qhia tias lub cuab yeej no yog rau "ceeb toom" cov ntawv ceeb toom.
- Ib Arduino Uno nrog Ethernet Shield.
- Lub sijhawm sib tsoo ntawm lub sijhawm tiag tiag, zoo li qhov no lossis qhov no.
- Ib qho piezo buzzer
- DHT22 qhov ntsuas kub thiab av noo.
Kev Ceeb Toom Hauv Tsev yog tswj hwm los ntawm nplooj ntawv web uas yog nyob ntawm Heroku, huab-raws li daim ntawv thov tus tswv. Cov nplooj ntawv web tau teev nyob rau hauv Ruby, siv Sinatra lub vev xaib app, thiab Redis qhov tseem ceeb-tus nqi khw.
Ua tibzoo saib ntawm lub vev xaib (qhia hauv thawj daim duab txuas hauv cov kauj ruam no), qhov twg daim ntawv tos cov lus tshiab los ntawm tus neeg siv.
Thawj daim teb lees paub tus lej lej khoos phis tawj. Nws yog tus lej uas tso cai rau koj rau lub hom phiaj tshwj xeeb hauv Tsev Kev Ceeb Toom, vim txhua tus tuaj yeem muab tus lej tshwj xeeb. Lossis, koj tuaj yeem muaj ntau Lub Tsev Ceeb Toom sib qhia tib txoj cai, yog li cov lus zoo ib yam tau nthuav tawm rau ntau qhov chaw.
Cov lus koj xav tso tawm mus rau qhov chaw thib ob. Txhua cov ntawv koj ntaus nyob rau ntawd yuav tshwm rau hauv DMD.
Yog tias koj xav ua suab nrov, kos rau Yog! checkbox, thiab lub suab nrov yog kom tau txais kev mloog zoo ntawm txhua tus neeg nyob ze.
Hauv kab lus no, Kuv yuav qhia koj li cas los tsim koj tus kheej Lub Tsev Kev Ceeb Toom Tsev, ob qho tib si Arduino kho vajtse thiab software, nrog rau Sinatra mini web application.
Cia peb pib!
Kauj ruam 1: Kho vajtse
DMD yog lub hauv paus ntawm lub cuab yeej. Kuv tuaj yeem mus nrog lub vijtsam LCD me me, tab sis lub tswv yim tseem ceeb rau txoj haujlwm no yog tsim qee yam uas tuaj yeem pom thiab hnov los ntawm qhov deb. Rau qhov pom kev, kuv xav tau qee yam loj thiab ci, thiab Freetronics zaub no yog qhov kuv xav tau. Txhua lub vaj huam sib luag muaj kab ntawm 16x32 LEDs, thiab koj tuaj yeem lo ob peb ntawm cov no ua ke los tsim cov lus loj dua. Nov yog qee yam kuv xav ua yav tom ntej.
DMD los nrog kev yooj yim siv Arduino lub tsev qiv ntawv. nws sib txuas lus nrog Arduino ntawm SPI nrawm. Kuv muaj peev xwm tau txais lub tsev qiv ntawv los ntawm Freetronics Github nplooj ntawv, tom qab ntawd tua hluav taws cov duab kos thiab ua haujlwm tsis pub dhau feeb ntawm qhib lub thawv. Kuv xav tsis thoob thaum pom lub teeb ci zoo siv tsuas yog lub zog los ntawm Arduino. Yog tias koj xav kom qhov muag tsis pom koj cov neeg saib ib ntus, koj tuaj yeem xa cov khoom siv hluav taws xob tshwj xeeb rau DMD no. Yog tias qhov no tsis tau txais kev mloog, tsis muaj dab tsi yuav!
Lub cev, qhov ntsuas no ntsuas 320mm (W), 160mm (H) thiab 14mm (D).
Lub vaj huam sib luag sab nraub qaum muaj cov txuas rau lub zog sab nraud, 5V nrog tsawg kawg 4Amps muaj peev xwm, Arduino txuas cim HUB1, thiab txuas rau daisy-txuas txuas ntxiv cov lus ntawm sab nraud. Raws li cov ntaub ntawv, koj tuaj yeem daisy-saw txog plaub DMDs.
DMD yog tswj los ntawm Arduino Uno. Freetronics muab qhov yooj yim heev "DMDCON" txuas uas tsuas yog snaps ncaj qha mus rau qhov tseeb SPI thiab cov ntaub ntawv pins.
Lwm yam tshaj li DMD, Kuv siv Arduino Uno, Ethernet Shield, lub sijhawm qhib lub sijhawm tiag tiag, lub suab nrov, thiab DHT22. Rau txhua qhov ntawm cov khoom no, Kuv tau tsim cov lus qhuab qhia piav qhia lawv kev ua haujlwm hauv kuv chav Udemy. (Tsis txaj muag txhawb tus kheej: sau npe rau kuv li email npe ntawm arduinosbs.com thiab tau txais daim coupon uas muab rau koj txo tus nqi nkag mus rau tag nrho 55 lus qhuab qhia).
Lub sijhawm tiag tiag, kev tawm tsam raws li DS18072 moos IC, yog I2C lub cuab yeej yog li nws txuas nrog Uno tus lej sib piv 1 thiab 2, uas siv I2C npav.
Lub suab nrov tau txuas nrog tus lej digital 3, los ntawm qhov uas kuv tswj hwm nws siv lub suab nrov () ua haujlwm.
DHT22 sensor txuas nrog tus lej digital 2. Ceev faj kom txuas 10KΩ rub tawm tus neeg tawm tsam ntawm 5V kab thiab kab ntawv cov ntaub ntawv.
Kauj ruam 2: Arduino Sketch
Cov duab kos tsis loj raws li kab suav, tab sis nws yuav luag tag nrho Uno muaj lub cim xeeb nco ua tsaug rau txhua lub tsev qiv ntawv suav nrog. Muaj ntau chav rau kev ua kom nco tau zoo dua, tab sis txij li thaum kuv nyob rau theem pib, uas yog txoj haujlwm rau lwm hnub. Cov cai no muaj nyob ntawm Github.
Nov yog cov duab kos, nrog cov lus pom (saib PDF txuas).
Lub luag haujlwm tseem ceeb ntawm daim duab no yog ua kom Arduino yog tus neeg siv khoom siv web service. Qhov kev pabcuam web yog lub vev xaib yooj yim nrog ob lub ntsiab lus kawg, ib qho rau tib neeg siv nkag los ntawm lub vev xaib thiab xa cov kab ntawv uas lawv xav pom ntawm DMD, thiab lwm qhov uas Arduino yuav nkag mus rau hauv khaws cov ntawv ntawd.
Thov rub tawm thiab nyeem cov ntawv PDF uas txuas nrog, nws muaj cov lus piav qhia uas piav qhia nws txoj haujlwm.
Kauj Ruam 3: Sinatra Ua Tus Kheej
Muaj ntau txoj hauv kev los tsim cov vev xaib thiab cov kev pabcuam web. Los ntawm cov phiaj xwm cov lus nrog lub vev xaib txhawb nqa cov tsev qiv ntawv, kom ua tiav cov txheej txheem, nws tuaj yeem tsis meej pem thiab nyuaj rau xaiv ib qho rau txoj haujlwm no.
Kuv tau siv thiab ua si nrog tus lej ncaj ncees ntawm lub vev xaib thev naus laus zis, thiab pom tias Sinatra zoo tagnrho rau kev tsim cov vev xaib thiab cov vev xaib me. Tshwj xeeb, thaum kuv tsim lub vev xaib pabcuam los txhawb nqa Arduino gadget, Sinatra yog qhov kev xaiv zoo tiag tiag.
Sinatra yog dab tsi, thiab vim li cas nws thiaj yog qhov kev xaiv zoo? Kuv zoo siab koj nug!
Sinatra yog hom lus rau kev txhim kho sai ntawm cov ntawv thov web. Nws yog tsim nyob rau sab saum toj ntawm Ruby, nrov heev thiab nthuav qhia lub hom phiaj kev sau cov lus. Koj tuaj yeem hnov Sinatra raug xa mus ua "DSL", Cov Lus Qhia Tshwj Xeeb. Tus sau ntawm no yog Lub Vev Xaib. Cov ntsiab lus (lo lus) thiab cov syntax tsim rau Sinatra yog qhov uas nws ua rau nws yooj yim thiab nrawm rau tib neeg los tsim web applications.
Nyob rau lub sijhawm uas hu ua "kev xav" cov txheej txheem rau lub vev xaib kev txhim kho zoo li Ruby on Rails thiab Django yog qhov nrov tshaj plaws, Sinatra ntes qhov kawg ntawm qhov pom ntawm qhov muag. Thaum Ruby ntawm Rails thiab Django xav kom tus programmer ua raws cov lus cog tseg tshwj xeeb thiab txoj hauv kev ua tej yam (uas, nyeg, cuam tshuam txog txoj kab nkhaus thiab kev kawm ntev), Sinatra tsis ua raws li qhov xav tau.
Sinatra yog lub tswv yim yooj yim dua Rails thiab Djangos ntawm lub ntiaj teb. Koj tuaj yeem sawv thiab khiav nrog lub vev xaib thov uas tuaj yeem cuam tshuam nrog koj Arduino hauv feeb.
Kuv yuav ua piv txwv piv txwv. Nov yog qhov Sinatra qhov web app zoo li cas (tsuas yog nyeem cov hauv qab no rau tam sim no, tsis txhob ua qhov no ntawm koj lub khoos phis tawj vim tias tej zaum koj tsis muaj qhov yuav tsum tau teeb tsa ua ntej rau qhov no):
Hauv ib daim ntawv, cia peb hu nws my_app.rb, ntxiv cov ntawv no:
xav tau 'sinatra'get'/'ua "Nyob zoo, ntiaj teb!" kawg
Ntawm kab hais kom ua, pib lub app zoo li no:
ruby kuv_app.rb
Koj lub app yuav pib, thiab koj yuav pom cov ntawv no hauv lub console:
peter@ubuntu-dev: ~/arduino/sinatra_demo $ ruby my_app.rbPuma 2.8.1 pib…* Min threads: 0, max threads: 16* Environment: development* Mloog ntawm tcp: // localhost: 4567 == Sinatra/1.4.4 tau ua theem ntawm 4567 rau kev txhim kho nrog thaub qab los ntawm Puma
Tam sim no lub app tau npaj kom tau txais cov neeg thov. Qhib tus browser, taw tes rau https:// localhost: 4567, thiab qhov no yog qhov koj yuav pom (saib cov duab txuas nrog).
Ntawd yog plaub kab yooj yim ntawm cov cai hauv ib daim ntawv. Hauv kev sib piv, Ntsia yuav xav tau ntau dua ib puas cov ntaub ntawv, tsim tawm tsuas yog ua kom tau raws li cov txheej txheem xav tau. Tsis txhob ua rau kuv yuam kev, Kuv nyiam Rails, tab sis tiag tiag?…
Yog li, Sinatra yog qhov yooj yim, thiab khiav nrawm. Kuv yuav xav tias koj tsis paub dab tsi txog Ruby, Sinatra, thiab daim ntawv thov xa mus rau Huab, yog li hauv ntu tom ntej kuv yuav coj koj ib qib zuj zus los ntawm xoom mus rau xa koj li Arduino web service mus rau huab.
Kauj Ruam 4: Teeb Koj Lub Tshuab Txhim Kho
Sinatra yog ua raws cov lus Ruby. Yog li, koj yuav tsum nruab Ruby ua ntej koj nruab Sinatra.
Koj kuj tseem yuav tsum teeb tsa tus yuam sij-tus nqi khaws cia server hu ua Redis. Xav txog Redis ua lub hauv paus uas khaws cov ntaub ntawv tiv thaiv tus yuam sij. Koj siv tus yuam sij los khaws cov ntaub ntawv, thiab nws tau ua kom zoo dua qhov nrawm dua li hloov pauv ntawm cov ntaub ntawv txheej txheem uas ib txwm muaj keeb kwm txheeb ze txheeb ze tau tsim los rau. Kev Ceeb Toom Hauv Tsev khaws nws cov lus hauv Redis.
Kauj ruam 5: Ruby ntawm Mac lossis Linux
Yog tias koj siv Mac lossis Linux khoos phis tawj, Kuv pom zoo kom koj siv RVM los nruab thiab tswj hwm koj li Ruby teeb tsa (RVM: Ruby Version Manager). Cov lus qhia rau kev txhim kho Ruby nrog RVM nyob hauv nplooj ntawv no, lossis tsuas yog luam thiab muab lo lus txib no tso rau hauv koj lub plhaub:
curl -sSL https://get.rvm.io | bash -s ruaj khov --ruby
Zaum, rov qab, so, thiab tos kom rub tawm, muab tso ua ke, thiab teeb tsa RVM thiab Ruby kom tiav.
Kauj Ruam 6: Ruby ntawm Windows
Yog tias koj nyob ntawm Windows, Kuv pom zoo ua raws cov lus qhia no ntawm Ruby Installer rau Windows lub vev xaib, thiab siv daim ntawv thov teeb tsa.
Kauj Ruam 7: Txheeb thiab Teeb Koj Ruby
Thaum lub sijhawm sau ntawv, Ruby ruaj khov tso tawm zaum kawg yog 2.1.1.p76. Koj tuaj yeem tshawb xyuas qhov version uas tau teeb tsa nrog RVM los ntawm kev ntaus qhov no:
rvm cov info
Cov ntaub ntawv ntau txog RVM thiab Ruby yuav tshwm sim. Hauv kuv qhov xwm txheej, qhov no yog Tshooj Ruby:
ruby: txhais lus: "ruby" version: "2.1.1p76" date: "2014-02-24" platform: "x86_64-linux" patchlevel: "2014-02-24 revision 45161" full_version: "ruby 2.1.1p76 (2014 -02-24 kev kho dua 45161) [x86_64-linux]"
Kuv pom zoo tias koj kuj siv Ruby 2.1.1, yog li yog tias koj pom ib yam dab tsi laus dua ntawd, hloov kho zoo li no:
rvm nruab 2.1.1
Qhov no yuav nruab Ruby 2.1.1. RVM qhov chaw haujlwm muaj ntau cov ntaub ntawv hais txog RVM thiab yuav tswj hwm koj li Ruby kev teeb tsa li cas.
Kauj Ruam 8: Nruab Sinatra (txhua lub Platforms)
Hauv Ruby, cov cai tau muab faib ua pob khoom hu ua "gems". Cov cai uas ua rau Sinatra tuaj yeem teeb tsa hauv koj lub computer ua lub pov haum zoo li no:
gem install sinatra
Kab ntawv no yuav nqa tag nrho cov cai thiab cov ntaub ntawv thiab teeb nws rau hauv koj lub computer.
Kauj ruam 9: Redis ntawm Mac lossis Linux
Teeb tsa Redis ntawm Mac lossis Linux yog qhov yooj yim. Cov txheej txheem tau piav qhia ntawm Redis lub vev xaib. Qhib lub plhaub dav hlau, thiab ntaus cov lus txib no:
$ wget https://download.redis.io/releases/redis-2.8.7.tar… $ tar xzf redis-2.8.7.tar.gz $ cd redis-2.8.7 $ ua
Khiav Redis los ntawm kev ntaus ntawv:
$ src/redis-neeg rau zaub mov
… thiab koj ua tiav!
Kauj ruam 10: Redis ntawm Windows
Redis ntawm Windows tsuas yog pom zoo rau kev txhim kho, thiab koj yuav tsum tau suav nws siv dawb Visual Studio Express kev txhim kho ib puag ncig. Nws xav tau sijhawm me ntsis kom nws ua haujlwm, tab sis nws ua haujlwm tau zoo thiab tsim nyog rau kev siv zog. Ua raws cov lus qhia ntawm txoj haujlwm Github nplooj ntawv. Nyob ntawd, koj tseem yuav pom qhov txuas rau Visual Studio Express nplooj ntawv.
Kauj Ruam 11: Tsim Daim Ntawv Thov Kev Pabcuam Web
Cia peb tsim daim ntawv thov thiab khiav nws ntawm koj lub tshuab txhim kho. Peb yuav hloov kho Arduino kos duab los txuas rau qhov piv txwv ntawm daim ntawv thov thaum peb sim nws. Thaum peb txaus siab tias txhua yam ua haujlwm tau zoo, peb yuav xa mus rau huab thiab hloov kho cov duab kom siv cov piv txwv huab.
Nov yog Ruby code, txhua yam hauv ib daim ntawv hu ua "web.rb" (cov lej no muaj nyob ntawm Github).
Tseem ceeb: Rub tawm thiab nyeem cov ntawv PDF uas txuas nrog, nws muaj cov ncauj lus ntxaws ntxaws ntxaws (thov ua qhov no ua ntej koj mus txuas ntxiv!).
Tam sim no koj tuaj yeem sim koj li Kev Ceeb Toom Hauv Tsev. Hauv koj daim duab, hloov WEBSITE thiab WEBPAGE qhov txuas mus rau taw qhia rau koj lub tshuab txhim kho thiab tus lej chaw nres nkoj rau koj txoj kev txhim kho Sinatra server. Hauv kuv qhov xwm txheej, Kuv muaj lub tshuab txhim kho ntawm IP 172.16.115.136, thiab kev txhim kho Sinatra server tau mloog qhov chaw nres nkoj 5000, yog li kuv cov duab teeb tsa yog:
#define HW_ID "123" #define WEBSITE "172.16.115.136:5000" #define WEBPAGE "/get_message/"
Tus IP chaw nyob no tsuas siv tau rau cov khoom siv hauv kuv lub tsev network.
HW_ID teeb tsa sawv cev rau "kho vajtse ID", uas yog, ID uas Arduino tswj hwm DMD yuav txheeb xyuas nws tus kheej rau daim ntawv thov Sinatra. Nws yog ib qho yooj yim heev ntawm kev txheeb xyuas qhov tseeb. Daim ntawv thov lub vev xaib yuav muab cov lus xa mus rau Arduino nug nws raws li qhov muab HW_ID. Koj tuaj yeem muaj ntau yam khoom siv nrog HW_ID tib yam, nyob rau hauv rooj plaub twg txhua lub cuab yeej yuav tso tawm tib cov lus. Yog tias koj xav tau "kev ceev ntiag tug", xaiv tus ID nrog ntau tus cim tsis raug uas lwm tus neeg yuav tsis tuaj yeem kwv yees tau. Tsis tas li ceev faj, tsis muaj kev sib txuas lus yog encrypted.
Tam sim no mus tom ntej thiab pib koj li Sinatra app, ntaus qhov no (piv txwv tias koj nyob hauv Sinatra qhov project):
ruby web.rb
… Thiab koj yuav pom qee yam zoo li no (qee cov ntsiab lus yuav txawv, tsuav yog qhov no tsis sib tsoo, koj ua tau zoo):
10:42:18 web.1 | pib nrog pid 4911910: 42: 18 web.1 | Puma 2.8.1 pib… 10: 42: 18 web.1 | * Min threads: 0, max threads: 1610: 42: 18 web.1 | * Ib puag ncig: kev txhim kho 10: 42: 18 web.1 | * Mloog ntawm tcp: //0.0.0.0: 5000
Taw tes koj lub vev xaib mus rau qhov chaw uas tus neeg rau zaub mov tau mloog, thiab koj yuav pom qhov no (saib qhov txuas thib ob).
Tshaj tawm koj cov duab kos rau Arduino, xyuas kom nws txuas nrog koj lub network hauv zej zog. Yog tias txhua yam mus tau zoo, Arduino yuav xaiv koj qhov web service ib zaug txhua feeb. Muab nws cov lus los qhia: Hauv HW code teb, ntaus hauv tib tus ID koj teeb tsa rau HW_ID tas li hauv daim duab. Ntaus ib yam dab tsi hauv "Koj cov lus" teb, thiab tshawb xyuas "Buzz?" checkbox.
Xa, tos ib pliag, thiab pom koj cov lus tshwm hauv DMD!
Kauj Ruam 12: Tso rau Huab Siv Heroku
Tam sim no tias Kev Ceeb Toom Hauv Tsev tab tom ua haujlwm hauv kev txhim kho, cia nws ua haujlwm ntawm Huab. Muaj ntau txoj hauv kev xaiv muaj rau xa daim ntawv thov web. Raws li qhov muaj peev xwm thiab nyuaj ntawm Kev Ceeb Toom Hauv Tsev, Kuv txiav txim siab tias teeb tsa kuv tus kheej lub server ntiag tug virtual tsis tsim nyog siv. Hloov chaw, nws zoo dua mus rau qhov kev pabcuam zoo li Heroku, tus tswv tsev thov. Rau kuv qhov ntsuas, Heroku qib dawb yog ntau dua li txaus. Txawm hais tias rau Redis tivthaiv, Kuv muaj peev xwm xaiv txoj kev npaj dawb los ntawm ib ntawm ntau tus muab kev pabcuam Redis uas ua haujlwm nrog Heroku.
Tseem, muaj kev siv zog me ntsis koom nrog, uas yuav tsum tau ua rau kuv daim ntawv thov hloov kho me ntsis kom nws tuaj yeem ua raws li Heroku cov lus qhia tshwj xeeb. Cov ntsiab lus nyob ntawm no, tab sis qhov tseem ceeb koj yuav xav tau ntxiv cov ntaub ntawv no rau koj txoj haujlwm Sinatra (txhua cov ntaub ntawv uas ua raws tuaj yeem rub tawm los ntawm kuv tus lej Github):
* config.ru: Nws qhia Heroku cov ntaub ntawv twg muaj daim ntawv thov. Nov yog cov ntsiab lus:
xav tau './web'run Sinatra:: Application
Thawj kab ntawv taw tes rau web.rb, thiab kab thib ob tau ua tiav koj daim ntawv thov.
* Gemfile: nws muaj Gems (ruby code pob) uas xav tau los ntawm daim ntawv thov. Heroku yuav saib sab hauv cov ntaub ntawv no txhawm rau txheeb xyuas lwm yam cai nws xav tau los teeb tsa kom koj daim ntawv thov ua haujlwm. Lwm txoj hauv kev los saib ntawm Gemfile yog qhov uas muaj cov npe ntawm kev vam khom rau koj txoj haujlwm. Yog tias ib qho ntawm cov kev vam khom no tsis muaj, koj daim ntawv thov yuav tsis ua haujlwm. Nov yog dab tsi sab hauv Gemfile rau lub app no:
qhov chaw "https://rubygems.org" ruby "2.1.1" gem 'sinatra'gem' puma'gem 'redis'
Ua ntej, nws teeb tsa qhov chaw khaws cia ntawm txhua lub pov haum txoj cai kom rubygems.org. Ntxiv mus, nws xav tau Ruby version 2.1.1 yog siv los ua daim ntawv thov. Tom qab ntawd nws teev cov Gems uas xav tau: Sinatra, Puma (zoo Ruby web thov server), thiab Redis.
* Procfile: nws qhia Heroku yuav pib li cas rau koj lub server. Tsuas muaj ib kab ntawm no:
web: rackup -s puma -p $ PORT
Kab ntawv no hais tias "lub vev xaib" tsuas yog hom kev pabcuam xav tau (koj tuaj yeem muaj lwm tus, xws li "tus neeg ua haujlwm", rau kev ua haujlwm yav dhau los), thiab kom pib qhov kev pabcuam Heroku yuav tsum siv cov lus txib uas los tom qab ":".
Koj tuaj yeem sim qhov Heroku yuav ua dab tsi los ntawm kev ua raws ntu no ntawm koj lub tshuab kev txhim kho (tsuas yog ntaus qhov ntsuas ua ntej xub; dab tsi ua raws tus xub tsuas yog piav qhia ntawm qhov hais kom ua):
$> lub pov haum nruab pob khoom -> teeb tsa Bundler, uas paub yuav ua li cas lis cov Gemfile. $> bundle install -> Bundler txheej txheem Gemfile thiab teeb tsa kev vam khom. $> rackup config.ru -> Rackup yog cov cuab yeej uas tuaj yeem ua cov txheej txheem config.ru. Nws ib txwm los nrog cov ntawv tom qab ntawm Ruby, yog tias nws tsis 'teeb tsa nws zoo li no: lub pov haum teeb tsa khib.
Kauj ruam kawg ua tiav hauv kev pib ua koj daim ntawv thov. Koj yuav tsum pom qhov tseeb tib yam li thaum koj pib nws nrog ruby web.rb ua ntej. Nws yog tib daim ntawv thov khiav, tsuas yog nrog qhov sib txawv uas ob txoj hauv kev yog li cas Heroku pib nws.
Peb yuav luag npaj txhij xa daim ntawv thov no mus rau koj tus lej Heroku. Yog tias koj tseem tsis tau muaj dua, mus tom ntej thiab tsim ib qho tam sim no. Tom qab ntawd, ua raws cov lus qhia pib sai rau teeb tsa koj tus lej nyiaj thiab koj lub tshuab txhim kho hauv cheeb tsam, thiab tshwj xeeb tshaj yog Heroku Toolbelt.
Heroku Toolbelt teeb tsa Heroku cov kab hais kom ua cov neeg siv khoom, Git (qhib qhov chaw tswj hwm qhov system), thiab Foreman (Ruby cov cuab yeej uas pab tswj kev siv Procfile-based applications).
Thaum koj ua tiav kev teeb tsa ntawm Heroku Toolbelt ua raws cov lus qhia ntawm Heroku lub vev xaib, ua raws cov theem no kom tau txais koj daim ntawv thov tso tawm (txhua yam tau sau rau hauv kab lus hais kom ua, hauv daim ntawv teev npe app):
$> heroku ID nkag mus -> Nkag mus rau Heroku ntawm kab hais kom ua $> git init -> Initialise Git repository rau koj daim ntawv thov $> git ntxiv. -> (ceeb toom tus lej!) Ntxiv txhua cov ntaub ntawv hauv cov npe tam sim no rau Git chaw cia $> git cog lus -m "pib" -> Ua cov ntaub ntawv no rau hauv qhov chaw cia khoom, nrog cov lus tshiab $> heroku tsim -> Tsim tshiab app ntawm Heroku. Heroku yuav muab koj lub npe rau npe tsis raug, qee yam xws li "blazing-galaxy-997". Nco tseg lub npe, thiab URL yog li koj tuaj yeem nkag mus ntawm koj lub vev xaib tom qab. Qhov URL no yuav zoo li no: "https://blazing-galaxy-997.herokuapp.com/". Koj kuj tseem yuav tsum luam lub npe hostname ("blazing-galaxy-997.herokuapp.com" ib feem) ntawm koj daim ntawv thov tshiab rau hauv WEBSITE tas li ntawm koj daim duab Arduino. Ua qhov no tam sim no kom koj tsis txhob hnov qab tom qab. $> heroku addons: ntxiv rediscloud -> Ntxiv qib dawb ntawm Rediscloud Redis kev pabcuam rau koj daim ntawv thov. Kev teeb tsa teeb tsa tau tsim thiab ua rau koj li ntawv thov. $> git thawb tus heroku tus tswv -> Tso koj tus lej rau Heroku. Qhov no yuav hloov pauv tus lej, teeb tsa kev vam khom ntawm Heroku, thiab pib daim ntawv thov. Thaum kawg ntawm tus txheej txheem, koj yuav pom qee yam zoo li no: "https://blazing-galaxy-997.herokuapp.com xa mus rau Heroku", uas txhais tau tias koj daim ntawv thov tam sim no nyob ntawm huab huab! Nrog koj zoo siab!
Mus tom ntej, muab nws tig!
Kauj Ruam 13: Muab Txhua Qhov Ua Ke
Nrog rau koj daim ntawv thov web, xa daim duab hloov tshiab mus rau Arduino (nco ntsoov tias koj hloov kho WEBSITE tas li los taw tes rau koj li kev tsim khoom ntawm daim ntawv thov web).
Siv koj tus browser txhawm rau nkag mus rau koj li app ntawm Heroku. Ib yam li hauv kev taw qhia, ntaus koj tus lej kho vajtse hauv thawj kab ntawv, koj cov lus hauv nqe ob, thiab khij lub npov kom qhib lub buzzer.
Koj cov lus yuav tshwm ntawm DMD ib ncig ib pliag tom qab yog txhua yam mus zoo!
Kauj Ruam 14: Muaj peev xwm
Muaj ntau yam ntxiv uas koj tuaj yeem ua nrog koj Lub Tsev Alert system …
Muaj Heroku rov qab kawg txhais tau tias koj tuaj yeem ntxiv ntau qhov laj thawj uas tuaj yeem ntxiv kev ua haujlwm zoo. Piv txwv li, koj tuaj yeem ntxiv lub peev xwm rau daim ntawv thov los tswj cov ntawv ceeb toom rov ua dua, kev lees paub, lossis tswj hwm cov ntawv ceeb toom ntxiv xws li lub teeb nyem thiab lwm yam. Koj tuaj yeem ntxiv ntau DMDs los tso saib cov lus sib txawv hauv txhua qhov lossis ib qho lus hauv qhov ua ke loj dua. Kuv tsuas yog khawb qhov ntawm qhov ua tau ntawm no!
Txaus siab rau!
Pom zoo:
Kev Tsim Qauv Duab Duab/Duab Duab Duab: 4 Kauj Ruam
Kev Tsim Qauv Duab Duab/Duab Duab Duab: Nyob zoo txhua tus, Hauv qhov kev qhia no, Kuv yuav qhia koj cov txheej txheem ntawm yuav ua li cas thiaj tsim 3D qauv siv cov duab digital. Cov txheej txheem hu ua Photogrammetry, tseem hu ua Image-Based Modeling (IBM). Tshwj xeeb, hom txheej txheem no tau siv los rov ua dua
Unifi Controller ntawm Google Cloud Platform (GCP): 6 Cov Kauj Ruam
Unifi Controller ntawm Google Cloud Platform (GCP): Ubiquity's Unifi Controller tso cai rau kev tswj hwm lub vev xaib ntawm lawv cov khoom Unifi suav nrog cov ntsiab lus nkag tau yooj yim, routers, thiab hloov pauv. Lawv muaj cov lus qhia zoo rau teeb tsa tus tswj hwm ntawm Amazon AWS siv qib dawb uas muab VM pub dawb
Cov Duab Duab Duab thiab Cov Duab 1: 4 Cov Kauj Ruam (nrog Duab)
Cov Duab Duab Cubes thiab Cov Duab 1: Thaum sim nrog qee cov ntoo ntoo thiab cov duab los qhia, kuv pom ob peb txoj hauv kev los ua cov voos thiab lwm yam duab los ntawm cov khoom siv yooj yim. Los ntawm kev muab cov no los ua Cov Ntawv Qhia, Kuv vam tias yuav txhawb nqa kev ua si thiab kev kawm. Kev hloov pauv ntawm qhov kev qhia no
Ruaj ntseg SSH / SCP Kev Sib Txuas Los Ntawm Raspberry Pi rau Cloud Server rau Backups thiab Hloov Kho: 3 Cov Kauj Ruam
Ruaj ntseg SSH / SCP Kev Sib Txuas Los ntawm Raspberry Pi rau Cloud Server rau Backups thiab Hloov Kho tshiab: Lub hom phiaj ntawm cov lus qhia no yog los qhia koj yuav ua li cas txuas tau thiab nyab xeeb los ntawm koj li Raspberry Pi mus rau lub server huab huab (thiab rov ua dua) kom ua tiav thim rov qab thiab hloov tshiab thiab lwm yam Txhawm rau ua qhov no, koj siv SSH tus lej tseem ceeb uas obvia
Cov Duab Duab Duab Duab, WiFi Txuas - Raspberry Pi: 4 Cov Kauj Ruam (nrog Duab)
Cov Duab Duab Duab Duab, WiFi Txuas - Raspberry Pi: Nov yog txoj hauv kev yooj yim heev thiab tus nqi qis mus rau cov duab thav duab digital - nrog qhov zoo ntawm kev ntxiv /tshem cov duab hla WiFi ntawm 'nyem thiab luag' siv (pub dawb) xa cov ntaub ntawv . Nws tuaj yeem siv tau los ntawm qhov me me £ 4.50 Pi Zero. Koj tseem tuaj yeem hloov pauv