Cov txheej txheem:

Teeb-Hloov: 7 Kauj Ruam
Teeb-Hloov: 7 Kauj Ruam

Video: Teeb-Hloov: 7 Kauj Ruam

Video: Teeb-Hloov: 7 Kauj Ruam
Video: Nkauj Tawm Tshiab 2022-2023 Thaiv tsab Sonie thoj Khwv los rau koj hloov 2024, Kaum ib hlis
Anonim
Teeb-Hloov
Teeb-Hloov

Hauv qhov haujlwm no kuv yuav ua piv txwv yuav ua li cas thiaj tsim tau lub kaw lus tswj lub teeb wireless nrog rau ntxiv nyiaj ntxiv thaum kawg. Ua raws nrog rau cov lus qhia ua tiav.

Yuav tsum:

- Raspberry Pi (ib qho tsw zoo, tab sis kuv siv 3B+ qauv)

- Ob lub 2n2222 transistors (Kuv pom zoo yuav tsawg kawg tsib vim tias muaj txoj hauv kev zoo koj yuav luv ob peb los ntawm qhov yuam kev)

-Txiv neej-rau-Txiv neej thiab Txiv neej-rau-Poj niam jumper cables

- Cov qhob cij

- (xaiv tau tab sis pom zoo) Breadboard 5V fais fab mov

- Ob ntawm txhua 1k thiab 10k resistors

Dual-Relay module

- Ob lub teeb qub hauv tsev lossis lwm yam khoom siv teeb pom kev zoo (siv cov qij coj los ua cov roj teeb uas zoo li yuav hlawv thaum ntsuas)

- Cov kab xev thiab kab xev txiav rau txuas

Kauj Ruam 1: Teeb Tus Neeg rau zaub mov thiab kev vam khom ntawm Raspberry Pi

Rau kuv qhov haujlwm kuv siv NGiNX, txawm hais tias koj tuaj yeem siv qhov twg koj xav tau server (Apache2, thiab lwm yam). Lub vanilla nruab nrog tus thawj tswj hwm pob tsuas yog zoo, tsis tas yuav suav peb tus kheej qhov chaw lossis lwm yam zoo li ntawd. Peb tseem yuav xav tau PHP, Python3 thiab Composer.

- SSH rau hauv koj tus PI thiab ntaus $ sudo nano /etc/dhcpcd.conf

- Kho tus IP tsis zoo li qub

- Reboot koj PI

- Txheeb xyuas seb txhua yam ua haujlwm los ntawm kev ntaus {the_ip_you_chose} hauv qhov chaw nyob ntawm koj tus browser (koj yuav tsum pom nplooj ntawv txais tos ntawm nginx)

Kauj Ruam 2: Nruab Web Framework thiab Kev teeb tsa rau NGiNX

Peb xav kom muaj lub vev xaib peb tuaj yeem nkag tau los ntawm peb lub xov tooj ntawm tes lossis lub browser thiab txhawm rau tshem tawm peb tus kheej ntawm kev sau php/html code yooj yim uas tsis yog thaj tsam ntawm qhov kev qhia no, peb yuav siv PHP moj khaum hu ua Yii2 los tswj cov hauv paus styling thiab styling rau peb.

- Mus rau Yii2 teeb tsa nplooj ntawv thiab siv tus kws sau los nruab nws hauv/var/www/html/teeb-hloov

- Peb yuav tsis pom dab tsi tsuas yog raws li peb tseem tsis tau muab tso rau hauv peb cov ntaub ntawv teeb tsa rau tus neeg rau zaub mov

- Kuv txuas cov ntawv (lub neej ntawd) rau cov kauj ruam no

- Siv nws zoo ib yam nrog cov txheej txheem no lossis saib lwm qhov online yog tias koj xav tau qhov sib txawv tom qab

- Koj yuav tsum muab cov ntawv no tso rau hauv/etc/nginx/sites-available/

- Reload NGiNX nrog $ sudo systemctl rov nginx

- Yog tias qee yam tsis ua haujlwm koj tuaj yeem khiav $ sudo nginx -t kom debug cov ntaub ntawv teeb tsa

Kauj Ruam 3: Teeb tsa Python Cov Ntawv Uas Yuav Sib Tham nrog GPIO

Raws li PHP tsis nyiam ua qhov zoo nrog runtime-type script zoo li GPIO API thiab nab hab sej tsis zoo nrog rau web apps, peb yuav siv txhua tus ntawm lawv hauv lawv cov txiaj ntsig zoo. Txuas nrog cov kauj ruam no koj yuav pom 4 qhov tsim nyog cov nab hab sej ntawv uas cuam tshuam nrog tus pin thiab ua rau lub teeb ci. Muab cov ntawv sau rau txhua qhov chaw koj xav tau, tab sis nco ntsoov lawv qhov chaw raws li peb yuav xav tau nws hauv qib tom ntej thaum peb teeb tsa php sab ntawm yam.

Kauj Ruam 4: Ua tiav ntawm Php Sab Ntawm Yam

Ua tiav ntawm Php Sab Ntawm Yam
Ua tiav ntawm Php Sab Ntawm Yam

Txhua yam peb yuav tsum tau ua yog tshem qee txoj hauv kev tsis raug thiab nplooj ntawv los ntawm cov txheej txheem tseem ceeb thiab ntxiv ob peb kab ntawm txoj cai hauv SiteController ntxiv rau txoj hauv kev tshiab hu ua actionLightswitch (). Tom qab qhov no, nws yuav ua kom cov ntawv sau nab los ntawm cov kauj ruam dhau los uas yuav tig los hais kom ua GPIO pins.

Kauj Ruam 5: Tsim Circuit Court

Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court

Vim yog qhov xwm txheej tshwj xeeb ntawm cov qauv xa tawm no (nws hloov pauv thaum txuas nrog GND) peb yuav tsum tsim kom muaj kev sib txuas siv cov transistors. PI tsuas yog qhib lub transistor uas yuav tso cov dej ntws tam sim no los ntawm cov ntaub ntawv xa xov txuas mus rau GND yog li ua rau lub kauj thiab kaw qhov Circuit Court rau lub teeb. Ua raws cov duab hauv cov duab txuas thiab koj yuav zoo mus.

Txog rau ntu tom ntej no, koj yuav tsum tau ceev faj tiag tiag li nws yog lub sijhawm los txuas qhov txuas. Tshem txhua yam ua ntej! Cov relay muaj 3 chaw nres nkoj ib qhov txuas. Peb yuav txuas peb cov cuab yeej siv hluav taws xob mus rau ib nrab thiab ib qho uas qhib lub cim rau nws. Ua tib zoo txuas cov hlua kom nthuav tawm cov tooj liab coj mus thiab tso lawv rau hauv cov chaw hais los saum toj no. Qhov kev txiav txim tsis muaj teeb meem li tam sim no peb tab tom ua haujlwm nrog lwm txoj hauv kev.

Kauj Ruam 6: Xeem Kawg

Txheeb xyuas koj lub Circuit thiab muab tus pin tsawg kawg ob zaug thiab tom qab ntawd txuas PI rau lub zog thiab ntaus {the_chosen_ip} hauv qhov browser qhov chaw nyob bar. Thawj nplooj ntawv yuav muaj ob peb tus tes hloov qhov. Nyem rau lawv thiab saib lub teeb qhib/tua.

Kauj Ruam 7: Tshooj Ntxiv: Qub Tsev Kawm Qub Clapper Trigger

Yuav tsum:

- ib lub usb microphone (nws tsis tas yuav yog qhov zoo tshaj)

- ALSA pob (txheej txheem teeb tsa yuav txawv nyob ntawm koj qhov kev faib khoom)

PyAudio module

Luam cov ntawv nab hab sej txuas nrog thiab ntsaws koj lub microphone. Reboot PI. Ua cov ntawv thiab ua raws li cov lus qhia console. Mus ze ntawm lub mic thiab npuaj teg ob zaug. Koj yuav tsum pom cov npuaj tau sau npe hauv lub console tso tawm thiab yog tias ua tiav, ob lub teeb yuav qhib tom qab 2 vib nas this.

Pom zoo: