Cov txheej txheem:

Raspberry Pi Zero Garage Door Opener Hardware: 10 Kauj Ruam
Raspberry Pi Zero Garage Door Opener Hardware: 10 Kauj Ruam

Video: Raspberry Pi Zero Garage Door Opener Hardware: 10 Kauj Ruam

Video: Raspberry Pi Zero Garage Door Opener Hardware: 10 Kauj Ruam
Video: Hacking my garage door with the Raspberry Pi Pico W 2024, Kaum ib hlis
Anonim
Raspberry Pi Zero Garage Door Opener Hardware
Raspberry Pi Zero Garage Door Opener Hardware

Ib qho ntawm kev tshoov siab rau txoj haujlwm no yog qhov qhia tau zoo ntawm Raspberry Pi 3 Garage Door Opener, nrog rau ob peb lwm qhov pom hauv Is Taws Nem. Tsis yog tus neeg siv khoom siv hluav taws xob raws caij nyoog, Kuv tau ua ntau qhov kev tshawb fawb ntxiv txog txoj hauv kev los cuam tshuam nrog Raspberry Pi thiab kawm ntau yam txog qhov tseem ceeb ntawm kev tiv thaiv nrog lub qhov muag LED thiab nrog txhua GPIO thaiv. Kuv kuj tau kawm paub txog cov txiaj ntsig ntawm kev rub tawm thiab rub tawm cov khoom siv hluav taws xob sib piv nrog Pi ua haujlwm.

Vim tias qhov phiaj xwm qhov rooj rau lub tsheb tiag tiag yog txheej txheem ntau ntu suav nrog Pi kho vajtse, software, thiab teeb tsa nrog koj lub qhov rooj qhib qhov rooj (s) Kuv xav tias kuv yuav xub tsom mus rau Pi kho vajtse, vim nws xav tau rau txhua lwm kauj ruam.

Kuv txoj hauv kev yog kom yooj yim heev, ua raws cov ntsiab lus ntawm kev kawm kuv tau ua kom muaj peev xwm ua tiav cov cuab yeej kho vajtse. Nws yuav pib tawm nrog qee cov ntaub ntawv, thiab tom qab ntawd peb yuav tsim cov kab hluav taws xob ntawm lub khob cij. Txhua kauj ruam yuav ua kom zoo dua peb cov qauv tsim thiab kev paub, ua kom tiav hauv kev tsim kho cov cuab yeej siv tas mus li txhawm rau cuam tshuam nrog Pi nrog kev xa xov thiab ntsuas ntsuas.

Ib qho ntxiv, tsis zoo li qee qhov haujlwm, Kuv txiav txim siab siv Raspberry Pi Zero W, uas kuv tau muag ntawm qee lub sijhawm dhau los tab sis tseem tau zaum tsis siv rau ntawm kuv lub rooj. Qhov siab tshaj yog qhov ntawd, thaum tsim qauv, yog tias kuv puas ib yam ntawm GPIO cov voj voog nws yog pheej yig thiab yooj yim los hloov thiab khaws cov qauv. Qhov tsis zoo yog tias nws tsuas muaj ARMv6 tus txheej txheem yog li qee yam, zoo li Java, yuav tsis siv tau.

Lwm qhov uas kuv txiav txim siab ua yog tsim kuv tus kheej ntxiv rau ntawm lub rooj tsav xwm, yog li kuv yuav tsum tau hloov lossis hloov kuv tus Pi, tsuav yog pinouts zoo ib yam, pawg thawj coj yuav tsum yooj yim ntsaws rau hauv Pi tshiab. Qhov no vam tias yuav txo qis tus nas lub zes ntawm cov xov hlau.

Kuv qhov kev xav yog:

  • Koj tau yooj yim soldering
  • Koj twb paub yuav siv cov lus txib dav dav hauv Raspberry Pi li cas
  • Koj siv Raspbian Buster lossis tshiab dua.
  • Koj muaj qee qhov cuam tshuam rau Pi kab hais kom ua; ib qho nrog rau kev saib xyuas tshwj xeeb, keyboard, thiab lwm yam THIAB/lossis siv SSH.
  • Koj tau paub txog lub hauv paus ntsiab lus ntawm kev tsim hluav taws xob hluav taws xob; piv txwv li, koj paub qhov sib txawv ntawm lub zog thiab hauv av thiab koj nkag siab lub tswv yim ntawm luv-Circuit Court. Yog tias koj tuaj yeem tso lub qhov hluav taws xob tshiab hauv koj lub tsev, koj yuav tsum muaj peev xwm ua raws.

Khoom siv

Nyob ntawm seb koj mob siab rau rau txoj haujlwm no li cas, koj tuaj yeem pib nrog yam uas xav tau ntawm txhua kauj ruam thiab mus ntawm qhov ntawd. Ntau qhov ntawm no muaj nyob ntawm koj cov khoom siv hluav taws xob hauv zos lossis DIY/Maker khw, tab sis kuv tau suav nrog Amazon txuas los txhim kho cov lus piav qhia.

  • MakerSpot RPi Raspberry Pi Zero W Protoboard (los ua qhov kawg HAT rau Pi)
  • 2 Channel DC 5V Relay Module (tau txais 1-channel yog tias koj muaj ib lub qhov rooj, 2 rau 2 lub qhov rooj, thiab lwm yam)
  • Hloov Lub Qhov Rooj Hloov, Ib Qho Qhib (TSIS YOG) (Yog tias lub sijhawm no koj tsuas yog tsim qauv thiab xav siv qee qhov pheej yig reed hloov pauv kom pib, yog qhov zoo)
  • Cov Khoom Siv Hluav Taws Xob Cov Khoom Siv (qhov no suav nrog txhua tus tiv thaiv kuv xav tau, ntxiv rau lub khob cij thiab lub zog siv los pab ua qauv thiab ntsuas thiab kawm ua ntej kuv ua lub rooj tsav xwm ruaj khov). Yog tias koj muaj tag nrho cov no twb muaj lawm, xyuas kom koj muaj ob peb 10K, 1K, thiab 330 ohm resistors ua ke.
  • Breadboard Jumper Wires (txhua yam yuav ua)
  • Soldering hlau nrog me ntsis taub
  • Rosin-core solder
  • Soldering hlau taub ntxhua khaub ncaws
  • Tshaj tawm 9v fais fab mov (txhawm rau lub zog rau lub khob cij)
  • Pheej yig prototyping boards rau soldering xyaum (yeem)
  • Ua haujlwm Raspberry Pi Xoom lossis Pi ntawm koj xaiv
  • Header pins rau Raspberry Pi (yog tias koj tsis muaj lub taub hau ntawm nws twb)
  • Teeb cov taub hau rau siv rau ntawm protoboard HAT.
  • Me rab koob ntswg qhov ntswg
  • Cov khoom siv ntsia hlau ntsia hlau
  • Cutters me me (rau txiav hlau tom qab siv tas)
  • Tweezers
  • Qee qhov xaim xaim me me (Kuv nyiam cov tub ntxhais muaj zog) rau siv ntawm lub qhov rooj tiv thaiv
  • Me ntsis silicone (yog tias koj xaiv siv 1.8mm nto mount LEDs hloov qhov uas tau muab rau hauv pob khoom)
  • Kuv pom tias lub teeb pom kev zoo yog qhov muaj txiaj ntsig zoo los saib ua haujlwm me me

Kauj Ruam 1: Taw qhia rau Raspberry Pi GPIO

Lub ntsiab lus sib tham peb yuav siv nrog Raspberry Pi yog GPIO (Lub Hom Phiaj Dav Dav Nkag/Tawm Tawm).

Nrhiav koj daim duab qhia chaw kom raug rau koj Pi ntawm no. Cov lus qhia no yuav tsom mus rau Pi Zero W v1.1.

Peb yuav siv tsuas yog tus pin GPIO ntsuab, zam SDA, SCL, MOSI, MISO, thiab lwm yam pins. (Kuv pom tias qee tus GPIO pins muaj lub hom phiaj tshwj xeeb, ib qho txiaj ntsig ntawm kev tsim qauv ntawm lub khob cij, yog li kuv nyam rau GPIO pins 17 (tus pin #11), 27 (tus pin #13), thiab 12 (#32) raws li lawv tau ua hauv txoj haujlwm zoo rau kuv daim ntawv qhia zaub mov.

GPIO pins tau tsim los ua haujlwm raws li digital (binary) hloov pauv; lawv muaj logic raws li ib ntawm ob lub xeev: 1 lossis xoom. Cov xeev no nyob ntawm seb seb tus pin muab khoom lossis tau txais qhov hluav taws xob siab dua qhov tshwj xeeb pib (1) lossis cov khoom siv lossis tau txais qhov hluav taws xob qis dua qhov pib tshwj xeeb. (Peb yuav tham txog qhov pib pib tom qab.)

Nws yog ib qho tseem ceeb kom nco ntsoov tias, thaum Raspberry Pi tuaj yeem muab ob qho tib si 5V thiab 3.3V (3V3), GPIO pins ua haujlwm siv txog 3.3V. Ntau tshaj qhov ntawd thiab koj ua rau GPIO puas tsuaj thiab tejzaum nws yog tus tswj tag nrho. (Qhov no yog vim li cas peb ua qauv rau ntawm lub khob cij, thiab siv Pi pheej yig tshaj plaws!)

Lub xeev ntawm tus pin tuaj yeem tswj tau los ntawm software (tso tawm) lossis los ntawm lwm yam khoom siv pub mis hauv lub xeev (nkag).

Cia peb txhaj qhov no siv qee qhov yooj yim SYSFS cov lus txib. Kuv tsis paub tseeb tias qhov no xav tau WiringPi, tab sis yog tias koj ua teeb meem koj yuav xav teeb tsa nws yog tias koj siv cov duab Raspbian tsawg heev.

Ua ntej, cia peb muab peb tus kheej nkag mus rau GPIO 17:

sudo echo "17">/sys/class/gpio/xa tawm

Tam sim no cia peb txheeb xyuas tus nqi ntawm GPIO:

sudo miv/sys/chav kawm/gpio/gpio17/tus nqi

Tus nqi yuav tsum yog xoom.

Txij ntawm no mus, GPIO tsis paub tias nws yog tswv yim lossis tso tawm. Xws li, yog tias koj sim tswj tus nqi GPIO, koj yuav tau txais "sau yuam kev: Ua haujlwm tsis raug tso cai". Yog li cia peb qhia tus pin nws yog qhov tsim tawm:

sudo echo "tawm">/sys/class/gpio/gpio17/direction

Thiab tam sim no teeb tus nqi rau 1:

sudo echo "1">/sys/class/gpio/gpio17/tus nqi

Txheeb tus nqi dua kom pom … thiab tus nqi yuav tsum yog 1.

Nrog koj zoo siab, koj nyuam qhuav tsim tawm GPIO thiab hloov lub xeev!

Tam sim no, muaj me ntsis ntxiv rau nws, tab sis cia peb kawm ob peb yam ntxiv ua ntej.

Kauj Ruam 2: Nkag Siab Cov Neeg Tiv Thaiv

Yog li, koj tuaj yeem saib cov neeg tawm tsam ntawm Wikipedia, tab sis lawv txhais li cas rau peb? Feem ntau lawv tiv thaiv peb cov khoom.

Nco qab thaum peb tham txog GPIOs uas lawv ua haujlwm txog 3.3V? Qhov ntawd txhais tau tias yog tias koj muab tus pin GPIO ntau dua qhov ntawd, koj tuaj yeem kib nws. Vim li cas qhov no tseem ceeb? Qee zaum muaj qhov nce me me hauv ib qho kev sib tw thiab yog qhov siab tshaj yog 3.3V, ib qho me me hiccup tuaj yeem ua teeb meem. Kev ua haujlwm ntawm qhov siab tshaj qhov hluav taws xob yog qhov kev pheej hmoo.

Qhov no tshwj xeeb tshaj yog rau LEDs. LED yuav kos lub zog ntau npaum li nws tuaj yeem ua tau. Thaum kawg LED yuav hlawv tawm, tab sis qhov tseem ceeb kos tam sim no tuaj yeem siv tag nrho lub zog muaj nyob hauv ib lub voj voog, ua rau nws ua haujlwm tsis zoo.

Piv txwv li: yuav muaj dab tsi tshwm sim yog tias koj muab rab diav rawg rau hauv ob sab ntawm lub qhov hluav taws xob? Muaj tsawg-rau-tsis muaj kev tiv thaiv, thiab koj yuav tshuab lub tshuab hluav taws xob tawg. (Thiab tej zaum yuav ua rau koj tus kheej raug mob.) Vim li cas tus toaster tsis ua qhov no? Vim tias nws cov cua sov ua kom muaj kev tiv thaiv, thiab zoo li tsis kos tag nrho cov khoom thauj ntawm Circuit Court.

Yog li peb yuav khaws qhov no li cas los ntawm LED? Los ntawm kev txwv tus nqi tam sim no siv los tsav lub LED siv lub resistor.

Tab sis dab tsi me me resistor? Yog, Kuv tau nyeem ob peb kab lus hauv web thiab thaum kawg txiav txim siab ntawm 330Ω resistor rau 3.3V nrog LED. Koj tuaj yeem nyeem tag nrho lawv cov kev suav thiab xam nws tus kheej, tab sis kuv tau sim ob peb ntawm lub khob cij thiab 330 ua haujlwm zoo xwb. Ib qhov kev siv uas kuv tshawb xyuas yog nyob ntawm Raspberry Pi cov rooj sib tham, tab sis kev tshawb fawb hauv Google yuav pom ntau ntxiv.

Ib yam nkaus, Pi GPIO pins xav tau kev tiv thaiv los ntawm overvoltage. Nco qab li cas kuv hais tias lawv siv UP TO 3.3V? Zoo, tsawg me ntsis yuav tsis ua mob. Feem ntau cov haujlwm siv 1KΩ resistors thiab kuv tau ua ib yam. Ib zaug ntxiv, koj tuaj yeem suav qhov no rau koj tus kheej tab sis qhov no yog qhov kev xaiv nrov heev. Ib zaug ntxiv, Raspberry Pi cov rooj sib tham muab qee cov ntaub ntawv.

Yog tias koj tsis nkag siab qhov no tag, ua qee qhov nyeem ntxiv. Lossis tsuas yog ua raws cov lus qhia. Qhov twg ua haujlwm rau koj.

Ntau tus tiv thaiv tau sau rau hauv lub ntim tab sis thaum koj tshem tawm lawv, koj tuaj yeem qhia lawv sib nrug li cas? Cov kab xim me me ntawm tus tiv thaiv tuaj yeem qhia koj.

Tom ntej no, peb yuav xaim ib qho yooj yim LED ntawm lub khob cij nrog lub zog kom pib ua haujlwm.

Kauj Ruam 3: Txuas lub LED

Kev tiv thaiv LED
Kev tiv thaiv LED

Thawj kauj ruam yog xaim ib qho LED ntawm lub khob cij. Thaum peb tau txais qhov ua haujlwm nyab xeeb, peb yuav txuas nws mus rau Raspberry Pi thiab tswj nws los ntawm tus pin GPIO.

Cia siab tias koj lub khob cij tuaj nrog lub zog rau 3.3v. Yog tias tsis yog, koj tuaj yeem xaim txhua yam thiab txuas nws ncaj qha rau Pi.

Nrhiav ib qho LED thiab xaim nws mus rau lub khob cij raws li qhia siv 330Ω resistor. Cov ceg ntev dua ntawm LED yog anode, ceg luv dua yog cathode. Lub anode txuas rau 3.3V lub zog thaum lub cathode txuas rov qab rau hauv av. Lub resistor tuaj yeem yog ua ntej LED; nws tsis muaj teeb meem. Cov xim hlau txheem yog:

  • Liab = 5V
  • Txiv kab ntxwv = 3.3V
  • Dub = av

Thaum koj muaj lub khob noom cookie txuas thiab muab lub zog, LED yuav tsum ci. Tsis txhob mus ntxiv tshwj tsis yog tias koj tau txais txoj haujlwm no.

Kauj Ruam 4: Txuas lub LED mus rau GPIO

Txuas lub LED mus rau GPIO
Txuas lub LED mus rau GPIO

Yog li tam sim no peb muaj LED ua haujlwm nrog tus tiv thaiv. Tam sim no nws yog lub sijhawm los txuas qhov LED rau Raspberry Pi. Peb lub hom phiaj yog tsim kom muaj GPIO tso tawm thiab txuas GPIO ntawd mus rau lub LED kom thaum peb qhib lub GPIO, lub teeb yuav ci. Hloov pauv, thaum peb DISABLE GPIO, LED yuav tua. (Qhov no yuav raug siv tom qab raws li lub Circuit Court uas yuav "nias" lub pob kom qhib lub qhov rooj rau tsheb.)

Tshem lub hwj chim los ntawm daim ntawv tais thiab txuas Pi raws li qhia. (Nws yog qhov zoo tshaj plaws los ua qhov no thaum Pi tau txhawb zog ib yam nkaus.) Peb tau txuas nrog 3.3V cov khoom siv los ntawm GPIO 17 thiab hauv av mus rau ib qho ntawm cov pins hauv av.

Tam sim no khau raj Pi thiab LED yuav tsum tawm. Ua tib cov lus txib peb tau ua yav dhau los teeb tsa GPIO tus pin thiab tso tawm tus nqi:

sudo echo "17">/sys/class/gpio/xa tawm

sudo echo "tawm">/sys/class/gpio/gpio17/kev taw qhia sudo miv/sys/class/gpio/gpio17/tus nqi

Tus nqi yuav tsum yog xoom.

Tam sim no cia peb qhib GPIO:

sudo echo "1">/sys/class/gpio/gpio17/tus nqi

Qhov no yuav tsum qhib lub LED. Txhawm rau tua LED, tsuas yog lov tes taw GPIO raws li hauv qab no:

sudo echo "0">/sys/class/gpio/gpio17/tus nqi

Ib yam uas MAY tshwm sim yog, nrog kev cuam tshuam txaus lossis qhib/tawm ntawm LED, koj yuav pom tias LED tseem nyob me ntsis. Muaj qhov laj thawj rau qhov no, thiab peb yuav tham txog qhov ntawd yav tom ntej.

Kauj Ruam 5: Siv Relay los Tsav LED

Siv Relay los Tsav LED
Siv Relay los Tsav LED

Raws li tau hais hauv kauj ruam dhau los, LED yog sawv ntsug rau lub qhov rooj qhov rooj "khawm." Txawm li cas los xij, thaum GPIO tuaj yeem ua haujlwm rau peb cov LED, nws tsis tuaj yeem "nias" peb lub qhov rooj qhov rooj qhov rooj. Ib lub pob nyem qhov tseem ceeb tsuas yog txuas ob lub khawm txuas, ua haujlwm tau zoo ua lub pob nyem. Yam koj yuav tsum tau ua qhov "nias" no yog kev xa tawm.

Kev xa tawm tsis muaj dab tsi ntau dua li qhov hloov pauv los ntawm qee yam. Hauv qhov no, peb Raspberry Pi tuaj yeem qhia qhov txuas mus rau "nias" lub qhov rooj qhov rooj qhov rooj. Rau peb tus qauv, Raspberry Pi yuav qhia qhov txuas mus qhib lub LED… tsuas yog li ntawd peb tuaj yeem sim peb qhov Circuit.

Peb yuav tsum paub dab tsi txog peb qhov kev tshaj tawm:

  • Lub relay ua haujlwm ntawm 5V. Nov yog lub zog tsuas yog ua haujlwm txuas thiab tsis siv rau hauv lwm qhov ntawm kev sib tw.
  • Peb xav xaim peb qhov kev xa xov raws li "ib txwm qhib." Qhov ntawd txhais tau tias qhov txuas txuas tseem qhib (tsis txuas ob lub xov hlau, lossis "nias lub pob", kom txog thaum qhib.
  • Qhov kev tshaj tawm tshwj xeeb no tau qhib thaum GPIO muab lub zog xoom rau 3.3V txuas ntawm qhov txuas. Qhov tseeb, qhov no zoo li rov qab. Thaum muab 3.3V tso tawm, cov xa tawm raug tso tawm. Nrog peb nyob ntawm txoj haujlwm no thiab koj yuav pom tias qhov no ua haujlwm li cas.
  • Ob qhov kev sib txuas ntawm lub davhlau ya nyob twg txuas sib cais los ntawm Raspberry Pi. Qhov no txhais tau li cas yog tias koj tuaj yeem hloov xaim nrog txhua qhov ntsuas tam sim no vim nws tau txais nws tam sim no los ntawm lwm lub zog siv. Qhov yooj yim me me Raspberry Pi nrog 3.3V thiab 5V tuaj yeem ua haujlwm tiag tiag relay uas tswj hwm qhov hluav taws xob loj dua. Nov yog yuav ua li cas me ntsis khawm me me ntawm koj lub dashboard tuaj yeem ua rau koj lub zog loj rub cov rooj zaum kom sov.

Yog li cia peb pib.

Ua ntej, rov txuas dua (tab sis txhawb nqa) chav fais fab sab nraud rau koj lub khob cij. Lub zog no yuav ua haujlwm LED Circuit, thaum Raspberry Pi tswj kev xa xov.

Tom ntej no, tsim kev so hauv kab 3.3V txhawb lub zog LED. (Nrog cov hloov pauv thiab xa rov qab, peb ib txwm xav hloov qhov "kub", tsis yog hauv av.) Cov no tau qhia ua txiv kab ntxwv thiab xiav ntawm daim duab.

Txuas Raspberry Pi raws li qhia nrog 5V txhawb lub zog xa tawm, 3.3V ua lub luag haujlwm, thiab hauv av rov qab mus rau Raspberry Pi. Hauv qhov piv txwv no kuv tau txuas 3.3V rau GPIO 17. Kuv pom zoo txuas 1KΩ resistor rau GPIO xaim raws li qhia, txhawm rau tiv thaiv GPIO los ntawm teeb meem. (Qhov no tau hais hauv kauj ruam Resistors.)

Fais fab lub khob cij thiab tam sim no txhawb koj li Pi. LED yuav tsum tau lit.

Tam sim no khiav cov lus txib hauv qab no ntawm Pi:

sudo echo "17">/sys/class/gpio/xa tawm

sudo echo "tawm">/sys/class/gpio/gpio17/kev taw qhia sudo miv/sys/class/gpio/gpio17/tus nqi

Tus nqi yuav tsum yog xoom.

Tam sim no cia peb qhib GPIO:

sudo echo "1">/sys/class/gpio/gpio17/tus nqi

Qhov no yuav tsum tua LED.

Kauj Ruam 6: Ntxiv Lub Pull-Up Resistor

Ntxiv ib Pull-Up Resistor
Ntxiv ib Pull-Up Resistor

Txij ntawm no mus, txhua yam khoom koj yuav tsum ua haujlwm. Tab sis muaj ib yam uas peb tsis tau tham txog GPIOs, thiab qhov ntawd yog "ntab" qhov hluav taws xob uas tuaj yeem ua tau raws qhov pib uas peb tau hais yav tas los.

Thaum GPIOs feem ntau muaj ob lub xeev (1 thiab xoom), nws txiav txim siab cov xeev no raws li nws muaj qhov hluav taws xob siab dua lossis qis dua qhov ntsuas hluav taws xob, raws li peb tau hais hauv ntu GPIO. Tab sis qhov teeb meem hauv feem ntau GPIOs yog qhov muaj peev xwm ntawm qhov "ntab" qhov hluav taws xob; nyob rau hauv rooj plaub ntawm Raspberry Pi, qhov chaw nruab nrab ntawm xoom thiab 3.3V. Qhov no tuaj yeem tshwm sim los ntawm kev cuam tshuam lossis los ntawm qhov hluav taws xob nce/poob thoob plaws hauv Circuit Court.

Peb tsis xav tau qhov xwm txheej uas peb lub qhov rooj tso tsheb tso rau qhov rooj qhib tsuas yog qhib los ntawm ntab ntab. Qhov tseeb, peb xav kom nws qhib tsuas yog thaum peb qhia nws rau.

Cov xwm txheej zoo li no tau daws los ntawm kev siv rub tawm thiab rub cov neeg tawm tsam kom tswj hwm qhov tshwj xeeb thiab zam kev ntab ntab. Hauv peb qhov xwm txheej, peb xav kom paub tseeb tias muab hluav taws xob los tiv thaiv kev xa tawm los ntawm kev ua haujlwm. Yog li peb xav tau lub zog rub tawm kom coj qhov hluav taws xob nce siab dua qhov pib. (Thresholds yog yam lom zem… Kuv sim nyeem txog lawv thiab saib seb lawv tau txhais zoo thiab tau txais ntau cov ntaub ntawv uas tau hla kuv lub taub hau, thiab qee qhov uas zoo li yooj yim dhau. Suffice nws hais tias nrog lub multimeter kuv tuaj yeem pom qhov ntawd qhov hluav taws xob qis dua 3.3V, tab sis txij li txhua yam ua haujlwm raws li kuv tau tsim nws, Kuv nyuam qhuav txav mus los. Koj li kev ncua deb yuav txawv, thiab qhov no yog vim li cas peb thiaj li muab lub khob noom cookie tso ua ntej siv peb cov khoom kawg.)

Tseeb, Raspberry Pi muaj ob qho tib si rub tawm sab hauv thiab rub tawm sab hauv koj tuaj yeem teeb tsa tus lej lossis ntawm khau raj. Txawm li cas los xij, nws muaj kev cuam tshuam loj heev rau cuam tshuam. Thaum nws muaj peev xwm siv tau lawv, txij li peb twb tau ua haujlwm nrog cov neeg tawm tsam hauv Circuit Court, nws yuav tsim nyog rau kev ruaj ntseg los siv sab nraud.

Tseem ceeb dua, qhov no tsim qhov rub tawm thiab ntxiv qhov hluav taws xob txaus uas GPIO tus pin lub xeev tsis ua haujlwm rau 1 ua ntej Pi pib ua ntej. Nco ntsoov li cas peb qhov kev rov qhib qhib LED tau teeb thaum peb xub pib Pi txog thaum peb kaw nws? Kev siv rub tawm tiv thaiv kev xa tawm los ntawm kev qhib thaum pib vim tias kev xa tawm 3.3V tau txais hluav taws xob nyob rau tib lub sijhawm 5V cov tswv yim tau txais hluav taws xob. Peb kuj tseem tuaj yeem ua qhov no hauv Pi teeb tsa yog tias peb xav tau, tab sis ntxiv, txij li peb tab tom txuas nrog cov tiv thaiv ib qho ntxiv, nws zoo li tsis muaj kev phom sij rau kev ua haujlwm hloov tshiab thiab faib khoom.

Kev teeb tsa sib txawv yuav xav tau cov neeg tawm tsam sib txawv, tab sis 10kΩ resistor ua haujlwm nrog kev sib txuas uas kuv muaj. LED ntawm kuv qhov kev sib txuas tau tsaus heev ntawm khau raj, tab sis rub tawm tau muab qhov hluav taws xob txaus los tiv thaiv kev ua haujlwm ntawm kev xa tawm.

Cia peb ntxiv qhov rub tawm tus neeg tawm tsam rau peb lub Circuit Court. Hauv daim duab qhia lub khob cij, Kuv ntxiv 10kΩ resistor ntawm 3.3V cov tswv yim ntawm kev xa tawm thiab 3.3V qhov chaw.

Tam sim no peb muaj lub Circuit tsim nyog rau "nias" khawm lub qhov rooj qhov rooj; hloov lub LED thiab 330Ω resistor nrog khawm khawm tiag tiag yuav tsum yooj yim.

Kauj Ruam 7: Reed Hloov Sensor

Reed Hloov Sensor
Reed Hloov Sensor

Yog li ntawd zoo, peb paub tias peb li cas hauv Circuit Court zoo li qhib lub qhov rooj qhib qhov rooj rau tsheb. Txawm li cas los xij, yuav tsis yog qhov zoo kom paub tias lub qhov rooj qhov rooj kaw, lossis seb nws puas qhib? Txhawm rau ua qhov ntawd, koj xav tau yam tsawg ib qho hloov pauv. Qee qhov haujlwm pom zoo ob, tab sis lawv ob leeg yuav siv tib lub qauv tsim.

Peb tab tom siv "ib txwm qhib" (NO) reed hloov teeb tsa. Qhov ntawd txhais tau tias peb lub Circuit Court qhib kom txog thaum lub reed hloov nyob hauv qhov sib thooj ntawm cov hlau nplaum, uas yuav kaw lub Circuit Court thiab tso cai rau hluav taws xob ntws.

Qhov sib txawv tseem ceeb ntawm kev teeb tsa lub teeb tsa thiab teeb tsa txuas yog:

  • GPIO txuas nrog lub ntsuas hluav taws xob yuav tshuaj xyuas lub zog, yog li nws yuav yog qhov nkag mus GPIO (thaum lub chaw xa khoom siv qhov tso tawm GPIO uas muab hluav taws xob)
  • Vim tias lub xeev tsis muaj nyob raws li ib txwm qhib, uas txhais tau tias peb lub Circuit Court yuav tsis ua haujlwm. Xws li, GPIO lub xeev yuav tsum yog 0. Hloov pauv mus rau lub tswv yim ntawm qhov rub tawm tus neeg tiv thaiv ntawm kev xa xov hluav taws xob, peb yuav xav kom paub tseeb tias peb qhov hluav taws xob qis dua qhov pib thaum qhib lub Circuit Court. Qhov no yuav xav tau rub tawm tus tiv thaiv. Qhov no yeej yog tib yam li rub tawm, tab sis txuas nrog hauv av tsis siv lub zog.

Ntau yam zoo li kev xa xov hluav taws xob, peb tab tom xaim cov khoom ntawm lub khob cij ua ntej nqes nws mus rau Pi.

Cia peb siv peb lub zog ua mov ci thiab xaim ib qho LED, 330Ω resistor, thiab hauv av xaim. Tom qab ntawd nqes 3.3V mus rau ib sab ntawm lub reed hloov thiab lub jumper los ntawm lwm sab ntawm reed hloov mus rau LED. (Yog tias koj muaj lub reed hloov uas txhawb NO thiab NC, siv NO txoj haujlwm.) Tsiv cov hlau nplaum kom deb ntawm tus pas nrig thiab qhib lub hwj huam mov. LED yuav tsum nyob twj ywm. Tsiv cov hlau nplaum mus rau tus pas nrig thiab LED yuav tsum ci. Yog tias nws ua qhov txawv, koj tau siv nws rau NC (ib txwm kaw)

Kauj Ruam 8: Txuas Reed Hloov mus rau Pi

Txuas tus Reed Hloov mus rau Pi
Txuas tus Reed Hloov mus rau Pi

Yog li tam sim no uas peb muaj kev sib txuas ua haujlwm yam tsis muaj Pi, peb tuaj yeem tshem lub zog los ntawm lub khob cij thiab peb yuav txuas tus Pi.

Peb yuav siv GPIO17 dua vim peb twb paub lawm tias nws nyob qhov twg.

Ntau yam zoo li kev xa xov hluav taws xob, peb tab tom yuav tiv thaiv GPIO tus pin nrog 1KΩ resistor; txawm li cas los xij, peb yuav siv 10kΩ resistor rau hauv av los tsim qhov rub tawm.

Thaum peb tau xaim txhua yam, cia peb tshem cov hlau nplaum tawm ntawm tus ntoo thuv hloov, khau raj P, kuv thiab coj peb tus kheej mus rau kab hais kom ua thiab pib ua GPIO, sau tseg tias lub sijhawm no peb tab tom tsim cov tswv yim GPIO:

sudo echo "17">/sys/class/gpio/xa tawm

sudo echo "hauv">/sys/class/gpio/gpio17/kev taw qhia sudo miv/sys/class/gpio/gpio17/tus nqi

Tus nqi yuav tsum yog xoom. Tsiv cov hlau nplaum mus rau qhov hloov pauv. LED teeb yuav tsum teeb, thiab tus nqi yog 1.

Voila! Peb tau xaim peb lub reed hloov mus rau Pi!

Kauj Ruam 9: Ua Kev Ruaj Ntseg Ruaj Ntseg ntawm Pawg Thawj Coj

Ua Kev Ruaj Ntseg Ruaj Ntseg ntawm Pawg Thawj Coj
Ua Kev Ruaj Ntseg Ruaj Ntseg ntawm Pawg Thawj Coj
Ua Kev Ruaj Ntseg Ruaj Ntseg ntawm Pawg Thawj Coj
Ua Kev Ruaj Ntseg Ruaj Ntseg ntawm Pawg Thawj Coj
Ua Kev Ruaj Ntseg Ruaj Ntseg ntawm Pawg Thawj Coj
Ua Kev Ruaj Ntseg Ruaj Ntseg ntawm Pawg Thawj Coj
Ua Kev Ruaj Ntseg Ruaj Ntseg ntawm Pawg Thawj Coj
Ua Kev Ruaj Ntseg Ruaj Ntseg ntawm Pawg Thawj Coj

Tam sim no peb paub tias peb lub voj voog yuav tsum zoo li cas, nws yog lub sijhawm los muab cov ntawv hloov pauv mus tas li rau ntawm pawg thawj coj ua qauv. Txij li thaum kuv tab tom siv Pi Zero W, Kuv tau txais cov ntawv pov thawj me me.

Kuv xav tias nws yuav zoo siv Zero hom thiab tuaj yeem teeb ib lossis ntau lub laug cam, ib qho ntxiv-ntxiv uas Raspberry Pi hu HAT (Kho vajtse Txuas rau saum). Zoo, thev naus laus zis vim nws tsis muaj hom EEPROM thiab tsis sau npe nws tus kheej, nws tsis yog HAT tab sis kuv yuav tsum hu nws qee yam. Tab sis cov txheej txheem teeb tsa tau zoo thiab tshem tawm cov nas zes ntawm thaiv, yog li ntawd zoo.

Qhov kev sib tw yog tias cov laug cam proto yog yam me me, yog li koj tsis tuaj yeem haum ntau rau lawv. Tsis tas li, tsis muaj ib lub qhov txuas hauv kab zoo li cov laug cam loj dua. Thaum qhov no yuav zoo li tsis yooj yim, nws yeej yog tus cawm neeg txoj sia.

Qhov kuv xav yog tias kuv tuaj yeem tsim HAT rau txhua lub qhov rooj qhov rooj kuv xav tswj. Txoj kev no, koj tuaj yeem nthuav txoj haujlwm no kom haum rau koj xav tau.

Ntawm lub rooj sib tham proto, kuv pom tias tsuas muaj chav txaus los tsim peb txoj kab hluav taws xob:

  1. relay Circuit
  2. sensor Circuit Court
  3. thib ob sensor Circuit Court

Qhov ntawd zoo nkauj heev rau txhua qhov chaw nres tsheb qhov rooj.

Yog li qhov kuv tau ua yog siv GPIO17 thiab 27 rau cov ntsuas, thiab GPIO12 rau kev xa tawm. Qhov zoo nkauj tiag tiag txog ntawm pawg thawj coj no yog tias koj tuaj yeem xaim mus rau GPIO yam tsis tau kov lub taub hau. Tab sis yog, koj yuav tsum tau muab lub taub hau sib dhos ntxiv rau koj cov neeg tawm tsam (thiab, xaiv tau, LEDs).

Kuv zoo nkauj heev rov tsim cov kab hluav taws xob uas peb tau tsim qauv ntawm lub rooj tsavxwm. Koj tuaj yeem qhia tias kuv cov khoom siv tsis zoo tab sis nws tseem ua haujlwm. (Cov laug cam tom ntej yuav zoo dua txij li kuv tau xyaum.) Kuv muaj Aoyue 469 thiab tsuas yog plaub hau saum toj no teeb 4 yog qhov ntsuas kub zoo tshaj plaws raws li cov lus pom zoo rau kev siv lub taub hau GPIO.

Kuv siv kab sib txuas sab nraud rau hauv av thiab sab hauv rau 3.3V. Thiab kuv tau siv cov xaim hluav taws xob los ua tus choj txij li thaum peb tsis muaj kab sib txuas. Tus so tag nrho yog kab pheeb ces kaum thiab ib sab vim qhov ntawd yog txoj hauv kev zoo tshaj plaws uas kuv tuaj yeem pom kom haum lawv ntawm lub rooj tsavxwm.

Los ntawm LR (saib rau pem hauv ntej, sab resistor), cov pins tso tawm kuv ntxiv yog rau lub sensor GPIO xaim, lub sensor thib ob GPIO xaim, thiab txuas GPIO xaim. Hloov chaw ntawm kev txuas ncaj qha mus rau GPIO, uas peb tuaj yeem ua los ntawm lub taub hau, cov pins txuas rau txhua qhov peb tiv thaiv thiab, nyob rau hauv rooj plaub ntawm lub ntsuas cua, kuv ntxiv rau hauv microLED. (Nco ntsoov yuav ua li cas LED nyob hauv ib lub voj sib cais kiag li, yog li yog nws kub hnyiab tawm hauv Circuit Court tseem ua haujlwm.)

Cov ntawv txuas yog Fritzing cov ntaub ntawv, tab sis txij li Cov Ntawv Qhia muaj teeb meem nrog kev xa cov ntawv, Kuv yuav tsum muab nws qhov cuav txuas ntxiv ntawm "txt" txhawm rau txhawm rau kos nws.

Kauj ruam 10: Cov neeg ua tim khawv

Raspberry Pi Garage Door Opener Project (kev tshoov siab)

Idiot Phau Ntawv Qhia rau Raspberry Pi Lub Nkoj Qhov Rooj Qhib

iPhone lossis Android Lub Qhov Rooj Nkag Qhov Rooj

Kuv puas yuav tsum tau siv lub resistor lossis tsis?

Siv Pullup thiab Pulldown Resistors ntawm Raspberry Pi

Teeb tsa SSH

Raspberry Pi Pin Diagrams.

SYSFS cov lus txib

WiringPi

Resistors thiab LEDs

Kev tiv thaiv (sic) GPIO Pins

Resistor Xim Xim Tshuab Luam Ntawv thiab Daim Duab

Rub-Up thiab Rub Tawm Resistors

GPIO Voltage Thresholds

GPIO Cov Khoom Siv Hluav Taws Xob Qib

GPIO Tswj hauv config.txt

GPIO Rub Tawm Qhov Nyob (sic)

Vim li cas peb thiaj xav tau kev rub sab nraud sab nraud thaum lub microcontrollers muaj kev rub sab hauv?

Raspberry Pi HAT yog dab tsi?

Yuav ua li cas txhawm rau txhawm rau Raspberry Pi Zero W GPIO txuas

Pom zoo: