Cov txheej txheem:

Ntxiv Kev Cai Alexa Tswj rau Raspberry Pi Project: 5 Cov Kauj Ruam
Ntxiv Kev Cai Alexa Tswj rau Raspberry Pi Project: 5 Cov Kauj Ruam

Video: Ntxiv Kev Cai Alexa Tswj rau Raspberry Pi Project: 5 Cov Kauj Ruam

Video: Ntxiv Kev Cai Alexa Tswj rau Raspberry Pi Project: 5 Cov Kauj Ruam
Video: Xyw By Nquab Tsab New Song 2022-2023 2024, Kaum ib hlis
Anonim
Ntxiv Custom Alexa Control rau Raspberry Pi Project
Ntxiv Custom Alexa Control rau Raspberry Pi Project

Txoj haujlwm no yog npaj rau txhua tus uas muaj Raspberry Pi qhov haujlwm uas siv Python uas xav ntxiv kev tswj lub suab ntawm lawv cov khoom siv Amazon Echo uas twb muaj lawm. Koj tsis tas yuav yog tus kws paub dhau los, tab sis koj yuav tsum xis nyob siv kab hais kom ua thiab hloov kho cov cai uas twb muaj lawm kom haum rau koj cov kev xav tau.

Kuv tau pib tawm ntawm qhov haujlwm kom pab kuv Raspberry Pi kom tswj tau lub suab nrog Alexa kom nws tuaj yeem ua kom dej sov hauv lub lauj kaub rau qhov kub tshwj xeeb. Txawm hais tias kev sib cuam tshuam kuv xav tau yooj yim heev (dhau ib tus lej los ntawm Alexa mus rau Raspberry Pi), nws tau ua haujlwm ntau kom tau mus rau lub xeev ntawd los ntawm cov kev qhia uas twb muaj lawm. Kuv vam tias qhov kev qhia no yuav ua rau cov txheej txheem ntawd nrawm li sai tau rau lwm tus.

Hauv kuv qhov piv txwv, Kuv pib nrog Raspberry Pi Zero W nrog Raspbian. Kuv muaj qhov program Python3 ntawm kuv tus Pi uas muaj peev xwm sau ntawv mus rau SPI zaub, thiab kuv muaj lub ntsuas kub ntsuas kub uas kuv tuaj yeem nyeem tau. Rau koj, txoj haujlwm no yuav luag txhua yam, tab sis lub tswv yim yog tias koj yuav muaj qee yam khoom siv uas koj xav nyeem ntawm Alexa thiab/lossis qee yam khoom siv tso tawm uas koj xav tswj siv Alexa.

Lub hom phiaj yog mus los ntawm txoj haujlwm yooj yim xws li qhov tau piav qhia saum toj no mus rau lub cuab yeej uas koj tuaj yeem tswj tau yooj yim nrog kuv Echo. Piv txwv tias koj muaj cov cuab yeej kho mob no lawm, txoj haujlwm no yuav tsum tsis txhob them nyiaj rau koj. Thaum kawg, koj yuav mus txog qhov chaw uas koj tuaj yeem hais tej yam xws li:

Kuv: "Alexa, nug kuv lub cuab yeej los ntsuas qhov ntsuas kub ntawm lub ntsuas 1."

Alexa cov lus teb: "Qhov kev sojntsuam nyeem 72.31 degrees."

los yog

Kuv: "Alexa, qhia kuv lub cuab yeej sau George Washington"

Lus Teb: Cov zaub txuas nrog kuv Raspberry Pi tam sim no nyeem "George Washington"

Hauv ntu tom ntej, Kuv yuav piav qhia qhov yuav tsum tau tshwm sim nyob tom qab lub luag haujlwm kom ua txoj haujlwm no. Yog tias koj tsuas yog xav kom qhov no ua haujlwm ntawm koj txoj haujlwm thiab tsis quav ntsej nws ua haujlwm li cas, tsis txhob hla nws (txawm hais tias nws yuav ua rau nws nyuaj dua yog tias muaj qee yam tsis raug).

Kauj ruam 1: Tom qab

Keeb kwm yav dhau
Keeb kwm yav dhau

Hauv daim duab no (credit: https://developer.amazon.com/en-US/docs/alexa/alex… peb tuaj yeem pom cov qauv dav dav rau Alexa Gadgets.

Thaum koj hais qee yam rau koj lub cuab yeej Echo, nws xa lub suab mus rau Alexa Cloud, qhov twg nws tau ua tiav thiab qhov twg cov lus teb tau tsim los teb rau koj. Thaum koj nug tias huab cua yog dab tsi, nws tsuas yog ob qho no hauv kev sib tham. Tam sim no xav tias koj xav ntxiv kev tswj lub suab rau ib qho ntawm koj txoj haujlwm me me ntawm Raspberry Pi. Kev ua txhua yam onboard yuav xav tau cov cuab yeej tseem ceeb thiab lub codebase ntse heev kom tau txais yam mus. Kev daws teeb meem zoo dua yuav yog siv Alexa Cloud, uas yog qhov ntse heev thiab tau txais txiaj ntsig zoo ntawm kev tuav cov lus nyuaj. Alexa Gadgets muab txoj hauv kev zoo rau koj los ua qhov no.

Alexa Gadget sib txuas lus nrog Echo ntaus ntawv siv bluetooth. Thaum qhov kev sib txuas no tau tsim, ob leeg sib txuas lus siv UTF-8 encoding. Thaum Echo hla qee yam mus rau lub cuab yeej, nws hu ua kev qhia. Lwm qhov kev taw qhia raug xa mus ua qhov xwm txheej. Ua ntej nkag mus rau qhov tseeb ntws ntawm txhua qhov no, peb yuav tsum qhia lwm qhov tseem ceeb: kev cai Alexa Kev Txawj Ntse.

Alexa tso cai rau cov tsim khoom los tsim lawv tus kheej kev txawj ntse, uas tso cai rau lawv los tsim lawv tus kheej kev sib cuam tshuam thiab tus cwj pwm coj los siv rau txhua yam khoom siv Echo. Piv txwv li, tus tsim tawm tuaj yeem tsim cov txuj ci tshwj xeeb los qhia koj txog qhov deb ntawm ob lub tshav dav hlau hauv Asmeskas. Ib tus neeg siv yuav hais tias: "Alexa, nug kuv tus lej kev suav nrug deb li cas ntawm LAX thiab JFK" thiab nws tuaj yeem teb nrog "2475 mais". Nws ua li no li cas? Thaum tus tsim tawm tsim cov txuj ci tshwj xeeb, lawv txheeb xyuas dab tsi hu ua "kev cai xav tau" nrog "piv txwv cov lus hais" uas muaj "qhov qhib". Piv txwv li, hauv qhov txuj ci no kuv yuav muaj lub hom phiaj "calc_dist" los xam qhov deb ntawm ob lub ntsiab lus. Ib qho piv txwv hais yuav yog "qhov kev ncua deb nruab nrab ntawm {slot1} thiab {slot2}" lossis "deb npaum li cas ntawm {slot1} thiab {slot2}". Cov kab lus qhia hauv kab zauv muaj hom tshwj xeeb. Hauv qhov no cov hom no yuav yog lub tshav dav hlau lis dej num xws li LAX, JFK, BOS, ATL. Thaum ib tus neeg siv nug txog qhov kev txawj ntse, Alexa Cloud sim ua kom zoo li cas tus neeg siv hais rau qhov kev cai ua raws li siv cov lus piv txwv muab thiab sim nrhiav qhov txiaj ntsig qhov txiaj ntsig rau qhov kev thov ntawd. Hauv qhov piv txwv no, nws yuav pom tias tus neeg siv xav tau "calc_dist" lub siab thiab qhov slot1 yog LAX thiab slot2 yog JFK. Txij ntawm no mus, Alexa Cloud dhau qhov haujlwm mus rau tus tsim tawm tus kheej txoj cai. Yeej, nws qhia tus tsim tawm txoj cai dab tsi nws tau txais thiab dab tsi txhua qhov txiaj ntsig qhov yog, ntawm lwm cov ntsiab lus.

Tus tsim tawm tau txiav txim siab qhov twg lawv cov cai nyob, tab sis qhov kev xaiv nrov heev yog siv AWS Lambda ua haujlwm. Yog tias koj tsis paub tias yog dab tsi, nws yog qhov tseem ceeb kev pabcuam uas tso cai rau koj rub cov lej uas tuaj yeem ua haujlwm tau txhua lub sijhawm thiab tom qab ntawd tsub koj tsuas yog rau lub sijhawm uas koj cov cai tau khiav. Yog tias peb txuas ntxiv nrog peb tus piv txwv, tus tsim tawm txoj cai yuav yog Python ua haujlwm uas tau txais ob lub tshav dav hlau cov cai, saib lawv qhov chaw, suav qhov nrug deb, thiab tom qab ntawd xa cov lus teb rov qab rau Alexa Cloud los tham qee yam rau tus neeg siv. Alexa Cloud yuav xa cov lus hais ntawd rov qab rau tus neeg siv lub cuab yeej, thiab lawv yuav tau txais cov lus teb.

Tam sim no peb tuaj yeem rov qab mus rau lub gadget. Peb tuaj yeem tsim cov kev txawj uas tsim los ua haujlwm tshwj xeeb nrog cov khoom siv. Tus tsim tawm tuaj yeem sau qhov txuj ci uas xa tawm cov lus qhia rau lub cuab yeej txuas nrog. Cov lus qhia ntawd muaj kev them nyiaj uas tuaj yeem siv tau txawm li cas los xij nws xav tau los ntawm lub cuab yeej. Qhov txuj ci ntawd tseem tuaj yeem xa cov lus qhia thiab tom qab ntawd mloog qhov xwm txheej los ntawm lub cuab yeej kom cov txuj ci muaj peev xwm nkag tau cov ntaub ntawv xa los ntawm lub cuab yeej.

Kev tsim cov dej ntws no tso cai tsim cov cuab yeej muaj zog heev vim tias cov cuab yeej pheej yig tuaj yeem muaj peev xwm sib txuas lus nrog cov cai hauv huab thiab teb cov lus txib siv qee qhov kev paub lub suab zoo tshaj plaws muaj.

Nws yuav tsum raug sau tseg tias feem ntau cov txuj ci tso cai rau ntau txoj hauv kev los cuam tshuam nrog lawv. Piv txwv li, tus neeg siv tuaj yeem dhia ncaj qha mus rau lub hom phiaj los ntawm kev hais "Alexa, nug kuv qhov kev suav nrug deb li cas ntawm LAX thiab JFK" (hu ua kev txhaj tshuaj ib zaug) lossis lawv tsuas yog siv lub hom phiaj pib: "Alexa, qhib kuv tus kheej kev suav nrug deb ". Qhov piv txwv kawg no feem ntau yuav ua raws los ntawm Alexa teb nrog rau qhov xav paub ntxiv. Cov ntawv qhia no txhob txwm tso tseg kev txhawb nqa rau tom kawg. Tshwj xeeb tshaj yog, yam tsis hloov kho txoj haujlwm Lambda, koj tsuas tuaj yeem hais tawm qhov txuj ci siv kev txhaj tshuaj ib zaug. Qhov kev xaiv tsim no tso cai rau tus qauv kom yooj yim dua (tsis tas yuav txhawb nqa lub hom phiaj lossis kev sib tham), thiab kuv tau pom tias kuv feem ntau xav sib cuam tshuam nrog kuv cov cuab yeej siv ib qho kev txhaj tshuaj ib txwm hais vim lawv feem ntau nrawm dua.

Kauj Ruam 2: Sau npe Gadget ntawm Alexa Voice Service Developer Console

Cov hauv qab no yog cov lus piav qhia ntawm cov kauj ruam xav tau. Kuv tau tsim cov vis dis aus sib npaug uas qhia tias yuav ua li cas txhua qib no. Koj tuaj yeem siv ib qho, lossis ob qho tib si, ua kom tiav cov theem no.

  1. Nkag mus rau
  2. Yog tias koj tseem tsis tau muaj tus as khauj dawb, ua ib qho
  3. Nyem rau ntawm "Cov Khoom"
  4. Sau cov ntawv lo thiab xaiv "Alexa Gadget"
  5. Sau txhua yam uas koj xav tau rau lwm qhov chaw
  6. Nyem tag

Kauj Ruam 3: Tsim AWS Lambda Ua Haujlwm thiab Kev Txawj Ntse

Tsim Kev Txawj Ntse ntawm Alexa Skills Kit Developer Console

Code rau qhov kev qhia no tuaj yeem pom ntawm no

Ua ntej ua tiav cov theem no, koj yuav tsum tsim cov ntaub ntawv.zip uas muaj pob xa mus rau AWS Lambda ua haujlwm raws li tau qhia hauv kev qhia ntawm no.

  1. Rub lub nplaub tshev "lambda" los ntawm kuv Github uas muaj "lambda_function.py" thiab "requirements.txt"
  2. Qhib lub davhlau ya nyob twg thiab hloov cov npe tam sim no kom nyob hauv daim nplaub tshev no.
  3. Khiav cov kab hauv qab no:

pip nruab -r requirements.txt -t skill_env

cp lambda_function.py skill_env cd skill_env zip -r../../skill-code.zip

Koj cov ntaub ntawv.zip tam sim no yuav nyob hauv phau ntawv teev npe uas yog cov ntawv tais ceev tseg lambda thiab yuav raug hu ua "skill-code.zip".

Ib tsab ntawv ntawm tus nqi ntawm kev tuav ntawm AWS: Phau ntawv qhia no xav kom koj muaj AWS tus lej (pub dawb los tsim). Lambda ua haujlwm tau them nyiaj, txawm li cas los xij, lawv cov nqi tam sim no hauv cheeb tsam N. Virginia yog $ 0.000000208 rau 100ms siv nrog 128MB nco. Txog kev siv, txhua qhov kev thov ntawm kuv cov txuj ci nqi txog 800ms ntawm kev siv ntawm qib no. Txhawm rau khaws cov nqi ntawm $ 1.00USD, koj yuav tsum tau thov qhov haujlwm no txog 600, 000 zaug uas (yog tias nws siv koj li 5 vib nas this ib qhov kev thov) yuav coj koj hla 34 hnub ntawm kev hu tsis tau koj li haujlwm. Tus nqi yuav tsum tsis yog qhov teeb meem tseem ceeb tshwj tsis yog koj tshaj tawm koj cov txuj ci thiab muaj coob tus neeg pib siv nws. Yog tias koj txhawj xeeb txog kev tau txais cov nqi ntawm AWS, txiav txim siab teeb tsa lub tswb siv uas ceeb toom rau koj yog tias kev siv hla dhau qhov pib txhais.

Cov hauv qab no yog cov lus piav qhia ntawm cov kauj ruam xav tau. Kuv tau tsim cov vis dis aus sib npaug uas qhia tias yuav ua li cas txhua qib no. Koj tuaj yeem siv ib qho, lossis ob qho los ua kom tiav cov theem no.

  1. Nkag mus rau https://aws.amazon.com/ thiab kos npe rau hauv lub console lossis tsim tus as khauj dawb yog tias koj tsis muaj
  2. Tshawb nrhiav thiab nyem rau ntawm Lambda hauv qab cov kev pabcuam
  3. Nyem "Tsim muaj nuj nqi"
  4. Xaiv "Tus Sau los ntawm kos", muab nws lub npe, thiab xaiv qhov tseeb Python 3 version rau runtime
  5. Hloov "hloov kho kab hauv kab" rau "upload cov ntaub ntawv.zip" thiab xaiv cov ntaub ntawv.zip tsim saum toj no
  6. Hauv lub qhov rai tshiab, mus rau https://developer.amazon.com/alexa/console/ask thiab kos npe rau hauv
  7. Nyem rau ntawm "Tsim Kev Txawj Ntse"
  8. Label nws, xaiv "Custom" qauv thiab "Provision your own" thiab nyem "Create Skill"
  9. Nyem "Pib los ntawm Kos" thiab nyem "Xaiv"
  10. Hauv qab "Kev Xav", nyem "Ntxiv"
  11. Tsim lub hom phiaj kev cai hu ua "alexa_to_pi" thiab sau "sau {tus neeg}" raws li tus qauv hais lus
  12. Ua qhov kev npaj siab hu ua "tus neeg" nrog hom "AMAZON. Person"
  13. Tsim lub hom phiaj kev cai hu ua "pi_to_alexa" thiab sau rau hauv "txheeb xyuas qhov ntsuas kub los ntawm sensor {sensor_num}
  14. Ua qhov kev npaj siab hu ua "sensor_num" nrog hom "AMAZON. NUMBER"
  15. Hauv qab Interfaces, qhib rau "Custom Interface Controller"
  16. Hauv qab qhov kawg, xaiv "AWS Lambda ARN" thiab luam tawm "Koj Tus Kheej Skill ID"
  17. Rov qab mus rau AWS Console
  18. Nyem "Ntxiv Trigger"
  19. Xaiv "Alexa Skills Kit", kos "Enable" hauv Skill ID pov thawj, muab tshuaj txhuam rau hauv Skill ID koj nyuam qhuav theej thiab nyem ntxiv
  20. Luam Lambda ARN nyob rau sab xis saum toj
  21. Rov qab mus rau Alexa Developer Console thiab muab Lambda ARN rau hauv "Thaj Chaw Thaj Chaw"
  22. Nyob rau hauv Invocation, teeb tsa Lub Npe Kev Txawj Ntse los ua "kuv lub cuab yeej"
  23. Nyem "Txuag Qauv" thiab tom qab ntawd "Tsim Qauv"
  24. Nyem "Test" nyob rau sab saum toj tab thiab hloov tus xaiv los ntawm "Off" rau "Development"
  25. Nco ntsoov tias cov cav rau Lambda ua haujlwm tau pom hauv "CloudWatch" kev pabcuam ntawm AWS.

Kauj Ruam 4: Teeb Txoj Cai ntawm Koj Raspberry Pi

Rau koj Raspberry Pi sib txuas lus nrog Alexa lub cuab yeej, nws xav tau qee txoj cai los pab txhawb kev xa xov xwm hla bluetooth thiab tswj kev sib txuas, ntxiv rau ob peb lwm cov ntaub ntawv. Txoj hauv kev yooj yim tshaj plaws los pib nrog cov ntaub ntawv hloov tshiab tshaj plaws los ntawm Amazon yog txhawm rau lawv cov Raspberry Pi Gadgets chaw cia khoom. Nkag mus rau cov npe ntawm koj qhov haujlwm tam sim no thiab khiav

git clone

Qhov no yuav thauj lawv tag nrho cov chaw cia khoom nrog txhua tus lej tsim nyog rau koj Pi. Nws muaj qee qhov haujlwm piv txwv uas qhia tawm qee qhov peev xwm ntawm Alexa Gadgets. Yog tias koj xav tau cov ntaub ntawv ntau ntxiv, saib cov ntawv nyeem ntawm lawv nplooj Github.

Khiav lawv cov teeb tsa kom tau txhua yam teeb tsa.

cd/tsev/pi/Alexa-Gadgets-Raspberry-Pi-Samples

sudo python3 launch.py --setup

Ua raws li cov lus qhia thiab teb "y" thaum nug yog tias koj xav teeb tsa siv koj li ntawv pov thawj Gadget. Nco qab Amazon ID thiab Gadget Secret los ntawm teeb koj lub cuab yeej ntawm tus tsim tawm console txij li nws yuav raug nug rau ntawm no. Kuv xaiv "bt" hom kev xa mus rau kuv Raspberry Pi Zero W. BLE tsis txaus siab los ntawm txhua lub cuab yeej Echo qub, tab sis koj tuaj yeem saib seb koj lub cuab yeej muaj peev xwm ua dab tsi. Yog tias koj tab tom siv koj li Pi hauv Desktop, Amazon pom zoo kom nyem rau ntawm lub cim bluetooth nyob rau sab saum toj sab xis thiab nyem "Tshem" Bluetooth "los ntawm Vaj Huam Sib Luag" kom tsis txhob muaj teeb meem kev sib txuas.

Nco tseg: cov kauj ruam no yuav siv sijhawm me ntsis nyob ntawm seb yuav tsum tau teeb tsa ntau npaum li cas.

Tam sim no koj yuav muaj txhua cov ntaub ntawv txhawb nqa uas yuav tsum tau rov qab mus rau koj qhov haujlwm thiab pib ntxiv hauv kev ua haujlwm kom tso cai sib txuas lus nrog koj li Echo.

Yog tias koj xaiv, koj tuaj yeem tshem tawm "piv txwv" nplaub tshev hauv "Alexa-Gadgets-Raspberry-Pi-Samples/src"

Koj tuaj yeem muaj koj tus lej txoj haujlwm nyob qhov twg koj nyiam, tab sis kuv yuav ua daim nplaub tshev hauv cov npe hauv tsev rau nws, hloov koj tuaj yeem rub daim nplaub tshev nrog tus lej los ntawm kuv Github, tsuas yog nco ntsoov kho cov ntaub ntawv.ini raws li tau piav qhia hauv qab no.

cd /home /pib

mkdir my_project cd my_project kov my_gadget.py kov my_gadget.ini

Tam sim no kuv tau tsim ob daim ntawv hauv daim nplaub tshev hu ua "my_project". Cov ntaub ntawv.ini tseem ceeb heev. Nco ntsoov tias nws muaj cov hauv qab no thiab hloov pauv hauv koj li Amazon ID thiab Gadget Secret:

[GadgetSettings]

amazonId = INSERT_AMAZON_ID_HERE alexaGadgetSecret = INSERT_ALEXA_GADGET_SECRET_HERE [GadgetCapabilities] Custom. MyGadget = 1.0

Tam sim no, cia saib cov ntaub ntawv nab hab sej ua ntej nkag mus rau hauv cov ntsiab lus:

ntshuam json

los ntawm agt ntshuam AlexaGadget

chav kawm MyGadget (AlexaGadget):

def _init _ (tus kheej):

super ()._ init _ ()

def on_custom_mygadget_alexatopi (tus kheej, kev qhia):

payload = json.loads (directive.payload.decode ("utf-8")) print ("Tau txais cov ntaub ntawv:" + str (payload)) write_text (str (payload ['data'] ['person'] ['value '])))

def on_custom_mygadget_pitoalexa (tus kheej, kev qhia):

payload = json.loads (directive.payload.decode ("utf-8")) print ("Tau txais cov ntaub ntawv:" + str (payload)) payload = {'data': "Qhov kev sojntsuam nyeem" + str (get_temp (them nyiaj) ['data'] ['sensor_num'] ['value'])) + "degrees."} self.send_custom_event ('Custom. MyGadget', 'PiToAlexa', payload) MyGadget (). lub ntsiab ()

Ua ntej koj yuav pom tias nws hu ob txoj haujlwm: write_text () thiab get_temp (). Hauv kuv tus lej, kuv txhais cov haujlwm no hauv tib cov ntaub ntawv, tab sis lawv nyob ntawm kuv cov cuab yeej yog li kuv tau xaiv los rho tawm lawv. Kuv tau txuas cov ntaub ntawv no nrog cov haujlwm uas tau hais tseg kom tsuas yog luam tawm thiab xa cov ntaub ntawv dummy hauv qhov xwm txheej koj xav khiav cov cai no. Kuv yuav hais qhia ntsuas nrog tus lej tseeb no ua ntej koj hloov kho nws ua haujlwm nrog koj txoj haujlwm. Kuv kuj tau txuas cov ntaub ntawv.ini, tab sis nco ntsoov tias koj nkag mus thiab hloov tus ID thiab khoom siv zais cia. Lub luag haujlwm saum toj kawg nkaus tau txais cov ntaub ntawv dhau los ntawm Alexa. Kev ua haujlwm hauv qab tau txais cov ntaub ntawv hauv tib hom ntawv, tab sis Alexa lub cuab yeej yuav tos tsib feeb rau qhov xwm txheej yuav rov qab los nrog nws tus kheej them nyiaj. Qhov kev them nyiaj no tshwj xeeb hauv qhov Alexa lub cuab yeej yuav hais nws cov ntsiab lus.

Thaum koj muaj cov ntaub ntawv no, mus rau "my_project" nplaub tshev thiab khiav cov ntaub ntawv nab npawb.

sudo rov pib dua

cd/tsev/pi/my_project sudo python3./my_gadget.py

Yog tias qhov no yog thawj zaug koj tab tom ua haujlwm, koj yuav tsum tau muab nws txuas rau koj lub cuab yeej Echo. Nco ntsoov tias koj lub cuab yeej Echo nyob ze ntawm Raspberry Pi, txij li peb xav tau kev tso cai rau kev sib txuas bluetooth.

Hauv Alexa app ntawm koj lub xov tooj ntawm tes, nyem "khoom" nyob hauv qab txoj cai kaum.

Nyem "Echo & Alexa" nyob rau sab saud.

Nyem rau ntawm koj lub cuab yeej Echo.

Hauv qab "WIRELESS", coj mus rhaub "Bluetooth Devices".

Coj mus rhaub "PAIR TSHUAB TSHIAB" thiab koj yuav tsum pom koj lub cuab yeej ntawm cov npe.

Coj mus rhaub ntawm koj lub gadget. Koj yuav tsum pom Pi qhia tias nws ua tiav ua ke.

Thaum saib cov zis ntawm koj Pi, sim muab lub suab hais kom Echo:

Koj: "Alexa, nug kuv lub cuab yeej los ntsuas qhov ntsuas kub los ntawm ib qho sensor"

Yog tias txhua yam ua haujlwm tau zoo, koj yuav tsum hnov:

Ncha: "Kev sojntsuam nyeem 120.505 degrees."

Koj: "Alexa, qhia kuv lub cuab yeej sau George Washington."

Pi yuav tsum luam tawm:

Tau txais cov ntaub ntawv: {'cov ntaub ntawv': {'tus neeg': {'lub npe': 'tus neeg', 'tus nqi': 'George Washington', 'kev lees paubStatus': 'NONE'}}}

George Washington yog

Kauj Ruam 5: Ua kom tiav

Cov vis dis aus qhia ntawm no yog piv txwv ntawm lub cuab yeej ua haujlwm nrog nyeem ntawv ntsuas kub (tib qho kev sojntsuam hauv F vs. C) thiab sau cov npe mus rau qhov yooj yim tso saib.

Tam sim no koj vam tias yuav muaj qee yam ua haujlwm, koj yuav tsum sim mus thiab kho qhov no kom ua rau koj tus kheej txoj haujlwm muaj peev xwm dua. Nco ntsoov tias koj tuaj yeem hloov kho qhov xav tau yooj yim hauv Alexa Developer Console thiab tias txhua qhov ntawm qhov koj siv yuav raug xa mus rau koj Pi hauv kev them nyiaj. Ib qho ntxiv, koj tuaj yeem muaj Alexa hais txhua yam uas koj xav tau los ntawm kev kho cov nyiaj them koj rov qab los ntawm qhov xwm txheej los ntawm koj li Raspberry Pi code.

Thov nco ntsoov tias qhov kev qhia no tsis yog lub hom phiaj los daws qhov kawg rau txhua lub peev xwm uas koj tuaj yeem xav tau nrog Alexa Gadget. Nws yog txhob txwm txwv kom muab ob txoj haujlwm yooj yim rau koj hla cov ntaub ntawv hauv txhua qhov kev taw qhia ntawm Alexa thiab Gadget. Yog tias koj txaus siab los tsim cov qauv sib cuam tshuam ntau dua, Kuv xav txhawb koj kom nyeem tag nrho cov ntawv nyeem hauv https://github.com/alexa/Alexa-Gadgets-Raspberry-P… thiab sim txhua qhov piv txwv uas lawv muab. Kuv kuj tseem xav kom koj nyeem cov ntaub ntawv rau Alexa Gadgets Toolkit thiab Alexa Skills Kit.

Pom zoo: