Cov txheej txheem:

DIY Huab Cua Pab: 6 Kauj Ruam
DIY Huab Cua Pab: 6 Kauj Ruam

Video: DIY Huab Cua Pab: 6 Kauj Ruam

Video: DIY Huab Cua Pab: 6 Kauj Ruam
Video: Tlow Trifft korrektesten Rentner 2024, Lub Xya hli ntuj
Anonim
DIY Huab Cua Pab
DIY Huab Cua Pab

Lub sijhawm kawg kuv siv ESP32 los ua chaw tshaj tawm huab cua, uas tuaj yeem tshaj tawm huab cua tam sim no. Yog tias koj txaus siab, koj tuaj yeem tshawb xyuas cov lus qhia yav dhau los. Tam sim no kuv xav hloov kho dua tshiab, uas kuv yuav xaiv lub nroog los tshuaj xyuas huab cua hauv lub nroog no. Tsis yog tsuas yog ua si huab cua hauv ib lub nroog, nws tseem nug thiab tshaj tawm huab cua hauv lwm lub nroog raws li kuv cov lus txib.

Khoom siv

Kho vajtse:

  1. Raspberry Pi 3B+ (nrog daim npav SD)
  2. Lub suab sib cuam tshuam lub kaus mom
  3. PIR Tsab ntawv tsa suab Sensor Module
  4. Micro USB kab
  5. Dupont Kab

Kauj Ruam 1: Yuav Ua Li Cas

Yuav Ua Li Cas
Yuav Ua Li Cas
  • Peb npaj yuav siv cov haujlwm no nrog Raspberry Pi. Tab sis Raspberry Pi tsis muaj lub microphone kom tau txais lub suab, thiab tsis muaj lub cuab yeej los ua suab yog tias tus neeg hais lus tsis ntsaws. Pi tuaj yeem paub qhov ua haujlwm ntawm lub suab tawm tswv yim, thiab ua suab tsis txuas nrog tus hais lus.
  • Peb xav tau peb API, uas yog hais lus-rau-ntawv, huab cua, thiab ntawv-rau-hais lus. Tom qab ntawd ua lub suab.

Hais lus-rau-ntawv:

Huab cua: https://rapidapi.com/community/api/open-weather-map/endpoints Text-to-speech:

Ib qho ntxiv, peb tab tom txuas lub ntsuas pa kom pom tias RasPi pib ua haujlwm thaum ib tus neeg mus txog

Kauj ruam 2: Kev sib txuas

Kev sib txuas
Kev sib txuas
Kev sib txuas
Kev sib txuas
Kev sib txuas
Kev sib txuas

Lub suab sib cuam tshuam lub kaus mom yog Raspberry Pi nthuav dav pawg thawj coj saib. Tsuas yog ntxig Raspberry Pi raws li tus pin. Peb kuj yuav tsum tau siv ntau lub xov tooj cua DuPont los txuas cov ntsuas. Tus pin txuas yog raws li hauv qab no:

Lub suab sib cuam tshuam lub kaus mom ------ PIR

5V ------ VCC GND ------ GND GPIO27 ------ Tawm

Kauj Ruam 3: Txhim Kho Tus Tsav Tsheb ntawm Pawg Thawj Coj Loj

  • Txij li lub rooj nthuav dav nthuav dav tau tsim nrog siv rau cov khoom ntawm pom, peb tuaj yeem siv tus tsav tsheb ntawm seeed los tsav nws mus ua haujlwm.
  • Nkag mus rau cov lus txib hauv qab no hauv Raspberry Pi lub davhlau ya nyob twg lub qhov rais txhawm rau nruab tus tsav tsheb:

git clone

cd pom-voicecard sudo./install.sh sudo reboot

Cov ncauj lus qhia ntxaws siv tau tuaj yeem mus rau nplooj ntawv (https://www.makerfabs.com/wiki/index.php?title=Voice_Interaction_Hat) los saib

Kauj ruam 4: Code

  • Github:
  • Tom qab tau txais cov cai, koj yuav tsum hloov API KEY nrog koj li hauv asr.py, weather.py, thiab tts.py.

r = thov.post ('https://speech.googleapis.com/v1/speech:recognize?key='+api_key, data = data, headers = headers) headers = {' x-rapidapi-host ': "zej zog-qhib-huab cua-daim ntawv qhia.p.rapidapi.com ", 'x-Rapidapi-key':" ************************************* ***** "} r = thov.post ('https://texttospeech.googleapis.com/v1/text:synthesize?key='+api_key, data = data, headers = headers)

Sau lub npe ntawm qhov chaw hauv weather.py thiab nws yuav raug lees paub los ntawm cov npe chaw nyob no. Yog lawm, koj tuaj yeem sau cov npe ntawm cov nroog thoob plaws lub tebchaws thiab txawm tias lub ntiaj teb yog tias huab cua API tuaj yeem lees paub lawv

chaw nyob = ['Beijing', 'London']

Yog tias koj tsis siv tus neeg hais lus ntawm lub rooj nthuav dav, tab sis siv koj tus kheej hais lus, koj yuav tsum hloov "hw: 0, 0" hauv cov cai hauv qab no nrog "hw: 1, 0" hauv qhov test1.py

os.system ("aplay -Dhw: 1,0 output1.wav")

Luam tag nrho cov ntaub ntawv hauv Raspi-Voice-Interaction-Hat/ weather_workSpace/ rau cov npe ua haujlwm ntawm Raspberry Pi

Kauj Ruam 5: Ua Lub Thawv Ntim

Ua Ib Lub Thawv Ntim
Ua Ib Lub Thawv Ntim

Txhawm rau saib kom zoo nkauj dua, peb tau ntim nws hauv lub thawv. Txiav kom tsim nyog kom nthuav tawm tus neeg hais lus thiab lub microphone, thiab siv cwjmem xim los pleev xim rau ntawm lub thawv ntawv los kho nws.

Kauj Ruam 6: Yuav Siv Li Cas

Siv USB cable los txuas lub zog Raspberry Pi, tswj Raspberry Pi kom khiav test1.py, thiab ua rau lub ntsuas ntsuas. Tom qab nws tshaj tawm lub suab, peb pib tham txog ib qho chaw thiab tom qab ntawd tos nws tshaj tawm huab cua. Tus Pab Huab Cua tau ua tiav.

Pom zoo: