Cov txheej txheem:

Kev Pom Kev Ceeb Toom Kev Ceeb Toom: 9 Kauj Ruam
Kev Pom Kev Ceeb Toom Kev Ceeb Toom: 9 Kauj Ruam

Video: Kev Pom Kev Ceeb Toom Kev Ceeb Toom: 9 Kauj Ruam

Video: Kev Pom Kev Ceeb Toom Kev Ceeb Toom: 9 Kauj Ruam
Video: Tseem Ev Lub Kawm - Koos Loos 2024, Hlis ntuj nqeg
Anonim

Phau ntawv qhia no qhia koj yuav ua li cas txhawm rau qhia rau Phillips Hawj kom ceeb toom. Nws yuav muaj txiaj ntsig zoo rau cov neeg lag ntseg thiab tsis hnov lus zoo, muaj lub zeem muag qis lossis tsis hnov lus zoo. Kev Pom Kev Pom Kev Ceeb Toom yog qhia rau cov neeg siv tom qab tau txais ntawv ceeb toom los ntawm e-mail, Facebook, Trello, lossis zoo sib xws. Hue LED teeb pib ceeb toom los ntawm lub teeb ci.

Photon Particle yog qhov me me, tuaj yeem tsim kho tau Wi-nkaus cov cuab yeej txhim kho rau kev tsim qauv thiab ntsuas koj li Internet ntawm Yam Khoom.

Kauj Ruam 1: Daim Ntawv Teev Npe Kho Vajtse thiab Software

Koj yuav tsum tau kho vajtse thiab software txhawm rau txhim kho cov lej rau Kev Pom Kev Pom Kev Ceeb Toom.

Kho vajtse

  • Cov Khoom Siv Particle
  • Philips Hawj txawm - Starter Kit (3 LED teeb thiab 1 Hue Choj)

Software

  • Cov ntaub ntawv dav dav ntawm Particle Photon
  • Particle Web IDE (Tsim) *Yuav tsum tau nkag mus *
  • IFTTT (Yog Qhov No Yog Li No)

Kauj ruam 2: Kev teeb tsa

Koj yuav tsum muaj koj Cov Khoom Siv Particle Maker, uas suav nrog txhua yam, xws li cov ntsuas hluav taws xob, cov xov txuas hluav taws xob, LEDs, cov tiv thaiv, thiab ntau ntxiv. Koj tuaj yeem nyeem cov ntaub ntawv ntau ntxiv txog Particle Photon.

Ua ntej koj txuas koj lub photon, koj yuav tsum paub cov xwm txheej ntawm LEDs ntawm Photon. Nov yog cov ntaub ntawv hais txog LED xwm txheej.

Txuas koj Photon

  1. Txuas lub USB cable rau hauv koj lub hwj chim. (Koj lub khoos phis tawj ua haujlwm zoo rau lub hom phiaj no). Koj lub cuab yeej me me tsis xav tau koj lub computer txuas rau wifi.
  2. Thaum nws tau ntsaws, RGB LED ntawm koj lub cuab yeej photon yuav tsum pib ntsais muag xiav. Yog tias koj lub cuab yeej tsis ntsais muag xiav, tuav lub pob SETUP li 10 vib nas this, tom qab ntawd tso lub khawm SETUP.
  3. Nkag mus rau Teeb Teeb Yog tias koj twb muaj tus as khauj lawm. Yog tias koj tsis muaj tus as khauj, tsim tus as khauj rau Photon.
  4. Nyem rau Photon/P Series.
  5. Tom qab nyem rau NEXT, koj yuav tsum tau nthuav tawm nrog cov ntawv (photonsetup.html)
  6. Nyem txuas nrog QHOV TSEEB TSEV KAWM NTAWV txhawm rau rub tawm cov ntawv.

Tom qab qhib ib daim ntawv

  1. Txuas koj lub PC rau Photon, los ntawm kev txuas mus rau lub network npe PHOTON-…
  2. Kho koj li ntaub ntawv pov thawj Wi-FI. Nco tseg: yog tias koj ua yuam kev koj li ntawv pov thawj, Photon yuav ntsais qhov xiav lossis ntsuab. Koj yuav tsum mus dhau cov txheej txheem dua los ntawm kev rov ua nplooj ntawv lossis nyem rau ntawm qhov txheej txheem rov ua dua.
  3. Hloov koj lub cuab yeej. Koj yuav pom qhov kev lees paub yog tias lub cuab yeej raug foob lossis tsis yog.

Ua ntej yuav txav mus rau ntu tom ntej, yog tias koj lub cuab yeej Photon muaj qhov nqus pa, tom qab ntawd nws ua tiav hauv Internet thiab Photon Cloud! Peb tab tom txav mus rau Particle IDE, Tsim.

Kauj Ruam 3: Coding hauv Particle Web IDE

Koj yuav tsum tsim koj tus lej nyiaj rau Particle IDE, Tsim. Yog tias koj twb muaj tus as khauj lawm, zoo heev! Kos npe rau hauv Particle IDE.

Peb xav sim ntsuas seb LED ntsais ntsais ntawm lub rooj tsavxwm. Muaj qhov me me xiav LED ntawm koj daim ntawv Photon. Nws nyob ib sab ntawm D7. Koj tuaj yeem rub tawm cov ntawv, tau pib-blinknet.ino, thiab pom cov lej nyob ntawd. Muaj lus piav qhia. Nyem qhov txuas no los qhib qhov chaws hauv Particle Web IDE. Yog tias D7 (me me LED xiav) ntsais muag, zoo siab, koj tsuas yog ntsais muag LED siv koj lub cuab yeej Particle! Yog tias koj xav kawm paub ntau ntxiv txog Photon, xws li ntsais ntsais sib txawv LED, nyeem daim duab sensor, thiab lwm yam, ntawm no yog qhov txuas.

Tam sim no, peb yuav txav mus rau Philips Hawj txawm.

Kauj Ruam 4: Philips Hawj txawm

Image
Image
Philips Hawj
Philips Hawj
Philips Hawj
Philips Hawj

Rau kev siv: Nyem rau ntawm Phillips Hue API.

Ua ntej koj tuaj yeem nkag mus rau Philips Hue API cov ntaub ntawv, koj yuav tsum tau sau npe ua tus tsim tawm. Nws yog pub dawb, tab sis koj yuav tsum lees txais cov lus thiab cov xwm txheej.

1. Ua ntej, xyuas kom koj lub Philips Hawj Choj (thawj daim duab) txuas nrog koj lub network ua haujlwm tau zoo. Test Hue App (Hue App muaj nyob ntawm iOS thiab Android) uas tswj lub teeb ntawm tib lub network.

Yog tias koj sim nws ua tiav, tom qab ntawd koj yuav tsum tshawb pom tus IP chaw nyob ntawm tus choj ntawm koj lub network. Siv Philips tus broker nrhiav pom los ntawm kev mus xyuas www.meethue.com/api/nupnp.

Thaum koj pom koj tus IP chaw nyob, ntaus nws rau hauv koj tus browser chaw nyob bar nrog debug/clip.html txuas ntxiv mus rau URL: https:// choj IP Chaw Nyob/debug/clip.html. Koj yuav tsum pom lub ntsej muag (duab thib ob) zoo li no. Nco tseg: Hloov "choj IP Chaw Nyob" rau koj tus IP chaw nyob.

2. Cia peb ua cov lus txib yooj yim thiab tau txais cov ntaub ntawv hais txog koj li hue system. Sau cov ntsiab lus hauv qab no tawm hauv lub cev tsis muaj dab tsi thiab nias GET khawm. Koj yuav tsum pom lub interface (daim duab thib peb) zoo li no. Koj yuav tsum tau txais cov lus yuam kev. Nco tseg: Hloov "choj IP Chaw Nyob" rau koj tus IP chaw nyob.

Chaw Nyob: https:// choj IP Chaw Nyob/api/newdeveloperBody: Txoj Kev: GETCong Congratulation! Koj tsuas yog xa koj thawj lo lus txib! 3. Tom ntej no, sau cov ntaub ntawv hauv qab no thiab nias lub khawm POST. Nco tseg: Hloov "tus IP chaw nyob" rau koj tus IP chaw nyob thiab "lub npe lub npe" rau koj lub xov tooj.

Chaw Nyob: https:// choj IP chaw nyob/apiBody: {"devicetype": "my_hue_app#phonetype name"} Txoj Kev: POST

Qhov txuas txuas pab tsim nws rau koj. Thaum koj nias POST khawm, koj yuav tsum tau rov qab cov lus yuam kev (daim duab plaub) qhia rau koj paub tias koj yuav tsum nias lub pob txuas ntawm Hue Bridge. Nov yog qib ruaj ntseg kom tsuas yog cov apps lossis servers koj xav tswj koj lub teeb. Los ntawm nias qhov txuas ntawm Hue Choj, nws ua pov thawj tias tus neeg siv muaj lub cev nkag mus rau tus hue choj.

Thaum koj tau txais cov lus teb tiav (daim duab thib tsib), nrog koj zoo siab! Koj tsuas yog tsim tus neeg siv tso cai, uas peb yuav siv txij tam sim no.

4. Piv txwv zaum kawg ua ntej peb muab nws tso rau hauv Photon Particle, xyuas kom tseeb tias ib qho ntawm koj lub teeb pom kev thiab nyob ntawm, thiab koj yuav tsum paub tus lej xov tooj yog qhov twg. Hloov qhov URL mus rau/api/username/teeb/teeb tus lej/lub xeev (hloov lub teeb pom kev [nws tuaj yeem yog 1, 2, 3, lossis?]), Thiab xa lub khawm PUT nrog cov ntaub ntawv hauv qab no:

Nco tseg: Nco ntsoov tias koj hloov tus IP chaw nyob tus choj, lub npe siv, thiab tus lej pom

Chaw Nyob: https:// choj IP chaw nyob/api/username/teeb/teeb tus lej/xeev

Lub cev: {"ntawm": tseeb, "zaum": 254, "bri": 254, "hue": 10000}

Txoj Kev: PUT Koj yuav tsum pom koj lub teeb hloov xim:

Kauj Ruam 5: Teeb Photon Nrog Khawm thiab Xov Tooj

Teem Photon Nrog Lub Khawm thiab Xov Tooj
Teem Photon Nrog Lub Khawm thiab Xov Tooj
Teem Photon Nrog Khawm thiab Xov Tooj
Teem Photon Nrog Khawm thiab Xov Tooj

Ua ntej peb txhim kho cov lej ntau ntxiv rau hauv Photon Web IDE, peb xav teeb tsa peb lub Photon nrog lub pob thiab cov xov hlau. Koj muaj ob peb lub nyees khawm thiab ntau lub xov hlau los ntawm koj Cov Khoom Qub Pib. Kuv tau txuas ob daim duab, ib qho yog daim duab duab thiab ib qho yog daim duab tseeb

  1. Nco ntsoov tias koj tso koj daim photon rau ntawm daim ntawv qhia zaub mov.
  2. Muab lub pob rau hauv qab ntawm daim ntawv qhia zaub mov raws li qhia hauv daim duab.
  3. Muab qhov kawg ntawm cov xaim dub hauv J4 (GND) thiab tso lwm qhov kawg ntawm tib cov xaim dub hauv J30.
  4. Muab qhov kawg ntawm cov xaim daj hauv J7 (D5) thiab tso lwm qhov kawg ntawm tib lub xov hlau daj hauv J28.

Yog tias lawv phim kuv cov duab kuv qhia koj, tom qab ntawd koj zoo!

Kauj Ruam 6: Sau Codes hauv Photon Particle

Sau Codes hauv Photon Particle
Sau Codes hauv Photon Particle

Peb yuav tsim peb thawj daim ntawv thov hauv Photon Particle - Web IDE.

  1. Mus rau https://build.particle.io/build thiab nkag mus (sau npe yog tias koj tseem tsis tau tsim)
  2. Ntaus "Pom Kev Ceeb Toom Ceeb Toom" hauv App Tam Sim No.
  3. Nias lub pob Enter (saib thawj daim duab).

Daim ntawv thov raug cawm hauv Photon Particle Cloud. Kev teeb tsa () muaj nuj nqi yog hu thaum daim ntawv thov pib thiab khiav ib zaug. Lub voj () muaj nuj nqi ua qhov tseeb nws ua dab tsi thiab txuas ua ntu zus, tso cai rau koj daim ntawv thov hloov pauv thiab teb.

Txhawm rau ntxiv HttpClient rau Photon Particle:

  1. Nyem Cov Tsev Qiv Ntawv los ntawm hauv qab sab laug ntawm Web IDE.
  2. Ntaus "HttpClient" hauv kab tshawb nrhiav.
  3. Nyem "suav nrog hauv qhov haujlwm" hauv lub pob xiav.
  4. Nyem qhov VisualNotificationAlert (nws tshem tawm qhov chaw tom qab koj tsim lub app).
  5. Nyem Paub

Tam sim no, Nws ntxiv HttpClient thaum pib ntawm Web IDE.

/ Cov lus #suav nrog no tau txiav ntxiv los ntawm Particle IDE. #Suav nrog

/*** Kev teeb tsa rau Philip Hawj ***

/ 1. Hloov qhov no nrog koj tus lej API siv los ntawm Kauj Ruam 1 const String API_USERNAME = "Koj li API siv lub npe"; // 2. Hloov qhov no nrog koj tus choj IP chaw nyob ntawm Kauj Ruam 1 IPAddress hueIP (x, x, x, x); // 3. Hloov nrog txoj kev mus rau lub teeb uas koj xav tswj. Siv lub vev xaib los ntawm Kauj Ruam 1 txhawm rau txheeb xyuas nws ua haujlwm. // Nco ntsoov tias koj paub tus lej ntawm Philip Hue lub teeb ///teeb/NUMBER/lub xeev const String LIGHT_PATH = "/teeb/Naj npawb/xeev"; // 4. Hloov qhov no nrog lub cev ntawm qhov koj thov kom qhib lub teeb. const String REQUEST_BODY_ON = "{" on / ": tseeb, \" bri / ": 254}"; // 5. Hloov qhov no nrog lub cev ntawm koj qhov kev thov kom tig lub teeb tawm. const String REQUEST_BODY_OFF = "{" on / ": cuav, \" bri / ": 254}"; / *** END Configuration for Philip Hue *** / Khawm const int BUTTON_PIN = D5; // HttpClient khoom siv los ua HTTP thov mus rau Hue choj HttpClient http; // Default header for HTTP thov http_header_t headers = {{"Txais", "*/*"}, {NULL, NULL} // NCO TSEG: Ib txwm txiav cov headers yuav NULL}; // Thov thiab teb cov khoom http_request_t thov; http_response_t teb; teeb tsa tsis muaj dab tsi () {Serial.begin (9600); thov.ip = hueIP; thov.port = 80; // Onboard LED ua qhov taw qhia lub teeb rau nkag siab kais pinMode (D7, OUTPUT); // Rau kev tawm tswv yim, peb txhais BUTTON_UP ua qhov nkag-rub tawm. Qhov no siv qhov rub tawm sab hauv sab hauv // los tswj kev nyeem zoo ib yam los ntawm lub cuab yeej. pinMode (BUTTON_PIN, INPUT_PULLUP); // teeb tus pin raws li kev nkag // Peb "Sau npe" rau peb qhov kev tshwm sim IFTTT hu ua Khawm kom peb tau txais cov xwm txheej rau nws Particle.subscribe ("RIT_Gmail", myHandler); Particle.subscribe ("Trello", myHandler); } // teeb tsa () ua haujlwm tsis muaj dab tsi voj () { / * * Qhov no yog ntu ntawm kev ntsuas seb lub teeb ceeb toom * / // pom tias lub pob raug thawb lossis tsis nyeem los ntawm nws. int buttonState = digitalRead (BUTTON_PIN); // Thaum khawm raug thawb, peb yuav tau txais LOW teeb liab. // Thaum lub pob tsis raug thawb, peb yuav tau txais HIGH. yog (buttonState == LOW) gmailAlert (); } // loop () function void printInfo () {Serial.print ("Application> / tResponse xwm txheej:"); Serial.println (teb.status); Serial.print ("Daim ntawv thov> / tHTTP Lub Cev Teb:"); Serial.println (teb.body); } // printInfo () muaj nuj nqi int i = 0; // Kev ua haujlwm uas ua haujlwm rau qhov xwm txheej los ntawm IFTTT tsis muaj dab tsi myHandler (const char *kev tshwm sim, const char *cov ntaub ntawv) {// Kuaj rau luam ntawv hauv cov ntawv Serial.print (xwm txheej); Serial.print (", cov ntaub ntawv:"); yog (cov ntaub ntawv) Serial.println (cov ntaub ntawv); lwm tus Serial.println ("NULL"); yog (strcmp (xwm txheej, "Trello") == 0) {trelloAlert (); } lwm tus yog (strcmp (xwm txheej, "Gmail") == 0) {gmailAlert (); }} // myHandler () muaj nuj nqi /** Tus hue tus nqi teeb lub teeb rau. * Tus hue muaj nuj nqis yog qhwv ntawm 0 thiab 65535. * Ob qho 0 thiab 65535 yog xim liab, * 25500 yog ntsuab thiab 46920 yog xiav. * / / *** Nws yuav ceeb toom siv Philips Hawj Hawj Ntse Qij siv xim xiav. Nws yuav ceeb toom rau 15 vib nas this. */ void trelloAlert () {String trello_body_alert = "{" on / ": tseeb, \" bri / ": 255, \" sat / ": 255, \" hue / ": 46920, \" alert / ": / "lselect \"} "; sendHttpPut (trello_body_alert); } /*** Nws yuav ceeb toom siv Philips Hawj Hawj Smart Bulb siv xim liab. Nws yuav ceeb toom rau 15 vib nas this. */ void gmailAlert () {String gmail_body_alert = "{" on / ": true, \" sat / ": 254, \" bri / ": 254, \" hue / ": 65535, \" alert / ": / "lselect \"} "; sendHttpPut (gmail_body_alert); }/** * Peb yuav xa PUT mus rau Philips Hawj txawm * @param httpPutBody lub cev ntawm txoj hlua */tsis muaj qhov xa sendHttpPut (String httpPutBody) {request.path = "/api/" + API_USERNAME + LIGHT_PATH; thov.body = httpPutBody; http.put (thov, teb, headers); }

Thaum koj ua tiav kev luam lossis theej cov cai rau koj li Photon Particle Web IDE, nyem qhov cim (Txheeb xyuas) nyob rau sab saud sab laug ntawm kab ntawv Yog tias nws ua tiav zoo, tom qab ntawv peb yuav mus rau kauj ruam tom ntej!

Kauj Ruam 7: Tshaj Tawm Txoj Cai rau Photon

Cov kauj ruam no yooj yim heev. Ua ntej peb xa cov lej rau Photon:

  1. Txuas lub USB cable rau hauv koj lub zog siv (Kuv xav kom lub laptop).
  2. Nco ntsoov tias koj lub photon muaj cov pa nqus pa LED. Yog tias nws tsis ua pa cyan lossis muaj xim txawv, mus rau Kauj Ruam 2: Kev teeb tsa
  3. Nyem Teeb pom kev zoo los ntawm Photon Particle Web IDE.
  4. Thaum nws upload cov lej rau Photon, koj yuav tsum pom magenta. Nws txhais tau tias cov cai pib raug xa mus rau cov cai. Tom qab ntawd, nws yuav ntsais ntsuab sai, tom qab ntawd rov qab los ua pa cyan.
  5. Nias lub pob kom pom tias koj li Philips Smart Bulb flashes (lossis ceeb toom).

Yog tias Philips Smart Bulb ceeb toom, tom qab ntawv zoo siab! Peb yuav luag tiav!

Peb yuav txav mus rau ntu software.

Kauj Ruam 8: Tsim Applets Los Ntawm IFTTT (Yog Qhov No, Tom Qab Ntawd)

Peb yuav tsim cov applets los ntawm IFTTT (Yog Qhov No, Tom Qab Ntawd) lub vev xaib. Cov applets yuav tshaj tawm ib qho xwm txheej rau Photon, thiab tom qab ntawd Photon xa cov lus txib mus rau Philips Hawj Choj kom ceeb toom lub qhov muag ntse.

Txog qhov haujlwm no, peb yuav siv Trello thiab Gmail tshaj tawm cov xwm txheej rau Photon.

Mus rau https://ifttt.com/ thiab sau npe.

Trello

  1. Nyem Kuv Applets nyob rau saum.
  2. Nyem Tshiab Applet.
  3. Nyem + qhov no hauv cov ntawv xiav.
  4. Ntaus Trello hauv kab ntawv tshawb fawb thiab nyem.
  5. Nyem Daim Ntawv Muab Rau Kuv.
  6. Xaiv koj lub rooj tsavxwm los ntawm Trello.
  7. Nyem +uas nyob rau hauv cov ntawv xiav.
  8. Ntaus Particle hauv qhov chaw tshawb nrhiav thiab nyem.
  9. Nyem Luam tawm ib qho kev tshwm sim.
  10. Ntaus "Trello" hauv Tom qab ntawv tshaj tawm (Lub Npe Lub Npe).
  11. Xaiv pej xeem.

Gmail (Nco tseg: lawv yuav siv koj tus email chaw nyob thaum koj sau npe)

  1. Nyem Kuv Applets nyob rau saum.
  2. Nyem Tshiab Applet.
  3. Nyem + qhov no hauv cov ntawv xiav.
  4. Ntaus Gmail hauv kab tshawb nrhiav thiab nyem
  5. Xaiv Ib qho email tshiab hauv inbox
  6. Nyem +uas nyob rau hauv cov ntawv xiav.
  7. Ntaus Particle hauv qhov chaw tshawb nrhiav thiab nyem
  8. Nyem Luam tawm ib qho kev tshwm sim.
  9. Ntaus "Gmail" hauv Tom qab ntawv tshaj tawm (Lub Npe Lub Npe).
  10. Xaiv pej xeem.

Thaum koj muaj ob lub applets, Trello thiab Gmail ua haujlwm, peb tab tom txav mus rau theem kawg.

Kauj Ruam 9: Thaum kawg, Xeem

Peb yuav sim tshaj tawm cov xwm txheej los ntawm Applets rau Photon. Xyuas kom koj cov applets nyob.

Trello

Thaum ib tus neeg tsim daim npav tshiab hauv Trello, lawv yuav muab (cim npe) rau koj hauv daim npav. IFTTT mloog qhov ntawd thiab pib tshaj tawm ib qho xwm txheej rau Photon. Tom qab ntawd Photon xa cov lus txib mus rau Philip Hue Choj kom ceeb toom cov teeb ci ntse.

Gmail

Thaum koj tau txais ib qho email tshiab hauv koj lub inbox, IFTTT mloog qhov ntawd thiab pib tshaj tawm ib qho xwm txheej rau Photon. Tom qab ntawd Photon xa cov lus txib mus rau Philip Hue Choj kom ceeb toom cov teeb ci ntse.

Kev sib tw

  • Thaum twg los xij peb tau txais ntawv ceeb toom tshiab los ntawm Trello thiab Gmail, muaj qhov ncua sij hawm loj heev rau xa ib qho xwm txheej los ntawm IFTTT thiab xa cov lus txib los ntawm Photon. Nws yuav tsum siv sijhawm tsawg dua 5 feeb los ceeb toom rau lub qhov muag ntse.
  • Gmail Applet qee zaum tua los ntawm nws tus kheej vim tias applet xav tau rov txuas lossis hloov kho tshiab.

Pom zoo: