Cov txheej txheem:

Tus Tswj Tsheb Loj: 5 Cov Kauj Ruam
Tus Tswj Tsheb Loj: 5 Cov Kauj Ruam

Video: Tus Tswj Tsheb Loj: 5 Cov Kauj Ruam

Video: Tus Tswj Tsheb Loj: 5 Cov Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Ntse Chaw Tso Tsheb
Ntse Chaw Tso Tsheb

Txoj haujlwm no tau los txog thaum kuv yuav tawm hauv tsev mus ua haujlwm thiab mus txog ib nrab txoj kev, tsuas yog kom muaj lub sijhawm txaus ntshai nyob qhov twg kuv tsis tuaj yeem nco qab yog tias kuv tau kaw lub qhov rooj rau tsheb. Qee lub sij hawm kuv ntseeg kuv tsis tau, thiab tig rov los, tsuas yog kom paub tseeb tias kuv tau kaw qhov rooj rau tsheb. Tam sim no kuv tau tuaj lig 30 feeb los ua haujlwm… zoo kawg. Thaum kuv yuav kuv tus kheej lub tsev, Kuv xav tam sim no yog thaum kuv tuaj yeem ua txhua yam kuv xav tau rau kuv lub qhov rooj qhib qhov rooj tsheb, thiab lub tswv yim no tau yug los.

Khoom siv

  • Raspberry Pi - Kuv xav tias tsuas yog hais txog txhua tus qauv yuav tsum ua haujlwm, tsuav nws tuaj yeem khiav Django, NGINX, thiab phom. Kuv siv Raspberry Pi 3 B+. Tej zaum koj yuav tsum tau hloov qee yam yog tias koj muaj qhov txawv version. - (https://www.adafruit.com/product/3775)
  • microSD daim npav (rau
  • 40 -pin ribbon cable rau GPIO pins - (https://www.adafruit.com/product/1988)
  • 4 -pin GPIO breakout board - (https://www.adafruit.com/product/2029)
  • Opto -Isolated relay board ntsuas rau> 20v DC - (https://www.amazon.com/gp/product/B07M88JRFY)
  • Perma-Proto ib nrab-pawg thawj coj saib-(https://www.adafruit.com/product/1609)
  • hlau txuas (~ 24-20 AWG) - (https://www.amazon.com/dp/B01LH1FYHO)
  • Sib Nqus Reed Hloov - (https://www.amazon.com/gp/product/B076GZDYD2)
  • Raspberry Pi HDMI plua plav npog - (https://www.amazon.com/gp/product/B07P95RNVX)
  • Raspberry Pi Ethernet hmoov av npog - (https://www.amazon.com/gp/product/B01I814D0U)
  • Raspberry Pi USB plua plav npog (4) - (https://www.amazon.com/gp/product/B074NVHTF9)
  • Raspberry Pi lub zog siv hluav taws xob (nyob ntawm tus qauv ntawm raspberry pi koj siv)
  • Cov ntaub ntawv Raspberry Pi - (https://www.amazon.com/gp/product/B07QPCPK8G)
  • 3.5 hli nkaus - (https://www.amazon.com/gp/product/B00OGLCR3W)
  • M2.5 ntsia hlau/standoffs rau cov laug cam - (https://www.amazon.com/dp/B0721SP83Q)
  • 18 AWG cable - (https://www.amazon.com/gp/product/B07TL9XK2K)
  • 3mm ntshiab acrylic - (https://www.amazon.com/gp/product/B07RY4X9L3)
  • nkag mus rau laser cutter

Kauj Ruam 1: Sib sau RPi

Sib dhos RPi
Sib dhos RPi
Sib dhos RPi
Sib dhos RPi
Sib dhos RPi
Sib dhos RPi

sau daim npav microsd nrog cov duab raspbian kawg ntawm koj xaiv. (https://www.raspberrypi.org/documentation/installation/installing-images/) tom qab ntawd sib sau ua ke lub rooj tsavxwm hauv rooj plaub, thiab txuas daim kab xev ua ntej ruaj ntseg lub hau ntawm rooj plaub. Tom qab ntawd ntxiv cov plua plav chaw nres nkoj.

Kauj Ruam 2: Txiav thiab Sib Sau Cov Thawv

Txiav thiab Sib Sau Ua Ke Lub thawv
Txiav thiab Sib Sau Ua Ke Lub thawv
Txiav thiab Sib Sau Ua Ke Lub thawv
Txiav thiab Sib Sau Ua Ke Lub thawv
Txiav thiab Sib Sau Ua Ke Lub thawv
Txiav thiab Sib Sau Ua Ke Lub thawv

Koj yuav tsum nrhiav qhov chaw uas yuav cia koj txiav koj lub thawv rau ntawm lub tshuab txiav laser, saib rau lub chaw tsim khoom hauv online lossis online rau cov chaw uas tuaj yeem txiav acrylic. Xwb, koj tuaj yeem siv lwm yam ntawm lub npov qhov project nrog qhov tsim nyog. Nco ntsoov ntxiv 330 Ohm resistor nruab nrab ntawm 3.3v kab thiab COM davhlau ya nyob twg ntawm tus ntoo qhib. N. O. lub dav hlau rov qab mus rau GPIO tus pin xaiv.

Hlau txuas nrog 5v mus rau DC+, GND rau DC-, thiab GPIO tus pin xaiv rau IN.

Lub qhov rooj qhib lub qhov rooj tsheb yuav mus txuas nrog txuas ntawm COM thiab NO

Kauj Ruam 3: Mount Reed Hloov thiab Khiav Cable

Mount Reed Hloov thiab Khiav Cable
Mount Reed Hloov thiab Khiav Cable
Mount Reed Hloov thiab Khiav Cable
Mount Reed Hloov thiab Khiav Cable
Mount Reed Hloov thiab Khiav Cable
Mount Reed Hloov thiab Khiav Cable

Nco ntsoov tias koj lub cable tsis cuam tshuam kev mus los ntawm koj lub qhov rooj. Hlau rau tib ob tus ntsia hlau uas koj cov phab ntsa khawm txuas kom qhib lub qhov rooj.

Kauj Ruam 4: Txuas Koj Raspberry Pi rau Koj Lub Wifi

Txuas koj Raspberry Pi rau koj Wifi
Txuas koj Raspberry Pi rau koj Wifi

thiab xyuas kom koj tuaj yeem SSH rau koj tus raspberry pi yog li koj tuaj yeem teeb tsa lub web server. koj tuaj yeem teeb nws hauv koj lub nkas -las thiab tus so tuaj yeem ua tiav los ntawm koj lub khoos phis tawj.

Kauj ruam 5: Nruab thiab teeb tsa Software

Nruab thiab teeb tsa Software
Nruab thiab teeb tsa Software
Nruab thiab teeb tsa Software
Nruab thiab teeb tsa Software
Nruab thiab teeb tsa Software
Nruab thiab teeb tsa Software

ntawm Raspberry Pi, nruab Django nrog cov lus txib:

  • `sudo apt hloov tshiab`
  • `sudo apt nruab python3-pip`
  • `sudo pip3 nruab django`

Tom qab ntawd teeb tsa NGINX thiab rab phom

  • `sudo apt nruab nginx`
  • `sudo pip3 nruab gunicorn`

Txhim kho tus nab npawb nab npawb tsim qhov project django, tsim kev tsiv teb tsaws chaw, thiab teeb tsa settings.py

  • luam daim npav tarball rau /srv
  • nruab siv 'sudo pip3 nruab django-smart-carhole-0.1.tar.gz`
  • tsim django project nrog `sudo django-admin startproject my_smart_garage`
  • `cd my_smart_garage/`

  • kho cov ntawv settings.py pom ntawm /srv/my_smart_garage/my_smart_garage/setting.py
  • ntxiv IP chaw nyob ntawm raspberry pi lossis nws lub npe host hauv ALLOWED_HOSTS
  • ntxiv 'door_control', rau INSTALLED_APPS daim ntawv teev npe
  • Kho TIME_ZONE rau koj lub sijhawm
  • Ntxiv cov kev teeb tsa hauv qab no mus rau qhov kawg ntawm cov ntaub ntawv: RPI_SENSOR_PIN, RPI_RELAY_PIN, IP_WHITELIST_DOORCONTROL thiab sau nrog nws cov txiaj ntsig. Saib cov duab ua piv txwv.
  • Ntxiv "txoj kev ('door_control/', suav nrog ('door_control.urls'))," rau /srv/my_smart_garage/my_smart_garage/urls.py hauv cov npe urlpatterns
  • ntxiv ', suav nrog' rau kab kev ntshuam nyob rau saum toj rau django.urls lub tsev qiv ntawv. Saib cov duab ua piv txwv.
  • migrate lub app nrog 'sudo python3 manage.py migrate'
  • sim kom paub tseeb tias txhua yam ua haujlwm los ntawm kev ua haujlwm ntsuas server nrog: `python3 manage.py runerver 0.0.0.0: 8000`
  • Nkag mus rau koj tus raspberry pi zoo li: https:// [ipaddress]: 8000/door_control
  • Koj yuav tsum tau ntsib nrog nplooj ntawv zoo li qhia.

Tam sim no nws yog lub sijhawm los teeb tsa nws kom lub web server ua haujlwm tau zoo.

  • Ua ntej lov tes taw debug hom hauv cov ntawv setting.py
  • tsis pom zoo rau server_names_hash_bucket_size 64 hauv /etc/nginx/nginx.conf
  • luam cov ntawv gunicorn rau /etc/systemd/system/gunicorn.service
  • luam cov ntawv nginx rau /etc/nginx/conf.d/smart_carhole.conf
  • pib ob txheej txheem
  • systemctl pab gunicorn.service
  • systemctl pib gunicorn.service
  • systemctl pab kom nginx.service

Pom zoo: