Cov txheej txheem:

Home_X: 5 Kauj Ruam
Home_X: 5 Kauj Ruam

Video: Home_X: 5 Kauj Ruam

Video: Home_X: 5 Kauj Ruam
Video: "ЭКЗАМЕН" ("EXAM") 2024, Kaum ib hlis
Anonim
Tsev_X
Tsev_X

Kuv yog menyuam kawm ntawv ntawm Howest Kortrijk uas kawm txog Kev Tshaj Tawm Tshiab thiab Kev Sib Txuas Lus Tshuab (NMCT).

Peb txhua tus yuav tsum ua qhov haujlwm uas tau ua nyob ib puag ncig raspberry thiab/lossis Arduino. Peb yuav tsum siv cov ntsuas thiab cov ntaub ntawv los qhia cov ntaub ntawv hauv lub vev xaib, thiab yog thaum kuv tuaj nrog lub tswv yim los tsim lub tsev ntse ntse.

Nrog lub tsev ntse, koj yuav tuaj yeem pom txhua qhov kev nyeem ntawv sensor ntawm lub vev xaib.

Hauv cov lus qhia no kuv yuav coj koj mus dhau txhua kauj ruam yog li koj tuaj yeem rov tsim txoj haujlwm no rau koj tus kheej.

Kauj Ruam 1: Cov Ntaub Ntawv: Koj Xav Tau Dab Tsi

  • Raspberry Pi
  • TSH 22
  • Grove - Huab cua zoo sensor
  • Grove - Roj Sensor (MQ2)
  • Cov qhob cij
  • Raspberry Pi T Cobbler
  • Txiv neej/Poj Niam Jumper Xov
  • 5 hli LEDs
  • Resistors
  • Ntoo thiab cuab yeej
  • Servo Tsav
  • GrovePi+

Koj tuaj yeem yuav cov khoom no online (Ali express, amazon, kiwi electronics …) lossis ntawm koj lub khw khw.

Ib daim ntawv teev cov ncauj lus kom ntxaws nrog qhov txuas rau cov khw tau muab hauv qab no hauv BOM.

Kauj ruam 2: Kev thaiv kab

Thaiv
Thaiv
Thaiv
Thaiv

Kuv siv Fritzing rau cov kab hluav taws xob kom muaj cov ntsiab lus zoo ntawm yuav ua li cas kuv thaiv yuav tsum tau ua. Kuv tus kheej siv GrovePi+ rau 2 ntawm kuv lub ntsuas cua. Yog tias koj npaj yuav ua qhov no yam tsis muaj GrovePi+ ua raws txoj kev Fritzing. Kuv sensors tsis ua haujlwm rau koj, sim siv tus lej sib txawv.

Koj tuaj yeem pom Fritzing cov ntawv hauv qab no.

Kauj Ruam 3: Database Siv MySQL

Database Siv MySQL
Database Siv MySQL

Ib txoj haujlwm tseem ceeb tshaj plaws uas peb yuav tsum tau ua yog kev txuas nrog MySQL database.

Txhua zaus lub ntsuas ntsuas tau nyeem lossis lub teeb mus, koj yuav pom cov kev hloov pauv no hauv lub hauv paus.

Lub database tom qab ntawd xa cov ntaub ntawv no mus rau lub vev xaib yog li tus neeg siv tuaj yeem pom lawv nyob ntawd ib yam.

Hauv qab no koj tuaj yeem pom kuv cov ntaub ntawv.xml qhov twg koj muaj cov ntsiab lus ntawm yuav ua li cas database ua haujlwm, tab sis ua ntej koj yuav tsum teeb tsa MySQL thiab lub hwj ntawm Raspberry Pi.

Cov cim ntawm cov ntsuas tau tshwm sim los ntawm pycharm yog li ua kom ntseeg tau tias tau teeb tsa ib yam (hauv koj lub khoos phis tawj).

Ua ntej koj yuav tsum txheeb xyuas qhov hloov tshiab thiab teeb tsa pob khoom, zoo li no:

sudo apt-tau hloov tshiab & sudo apt-tau hloov tshiab

sudo apt install -y python3-venv python3-pip python3-mysqldb mariadb-server uwsgi nginx uwsgi-plugin-python3

Tam sim no peb yuav siv qhov chaw ib puag ncig virtual:

me@my-rpi: ~ $ python3 -m pip install-upgrade pip setuptools log virtualenvme@my-rpi: ~ $ mkdir project1 && cd project1 me@my-rpi: ~/project1 $ python3 -m venv --system- site-packages env me@my-rpi: ~/project1 $ source env/bin/activate (env) me@my-rpi: ~/project1 $ python -m pip install mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask-MySQL mysql-connector-python passlib

Nws yuav tsum qhia koj tias mariadb.service tau ua haujlwm.

Tam sim no, hauv pycharm mus rau VCS> Ntshuam los ntawm Version Control> GitHub en clone

Tom qab ntawd teeb tsa kev teeb tsa xa mus rau cov npe uas koj nyuam qhuav ua, ex. /tsev/kuv/project1.

Tom qab qhov no ua tiav mus rau tus neeg txhais lus teeb tsa thiab teeb tsa lub chaw virtual uas koj nyuam qhuav ua, ex. /tsev/kuv/project/env/bin/nab hab sej. Kev qhia daim phiaj yuav tsum tau ua kom tiav thiab.

Yog tias koj tau ua txhua qhov no cov ntaub ntawv yuav tsum tau ua haujlwm.

sudo systemctl xwm txheej mysql

Tam sim no peb yuav tsum tsim cov neeg siv rau peb cov database, xws li:

sudo mariadb

Tsim tus neeg siv 'project-admin'@'localhost' IDENTIFIED BY 'adminpassword'; Tsim tus neeg siv 'project-web'@'localhost' IDENTIFIED BY 'webpassword'; Tsim tus neeg siv 'project-sensor'@'localhost' IDENTIFIED BY 'sensorpassword'; Tsim qhov project DATABASE;

YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM RAU HAUV PROJECT.* Rau 'project-admin'@'localhost' NROG QHOV ZOO TSHAJ PLAWS; GRANT SELECT, INSERT, Hloov tshiab, Rho tawm ntawm qhov project.* TO 'project-web'@'localhost'; GRANT SELECT, INSERT, Hloov tshiab, Rho tawm ntawm qhov project.* TO 'project-sensor'@'localhost'; NTSEEG NTAWV QHOV TSEEB;

Tam sim no kom pom peb cov ntaub ntawv khaws cia hauv pycharm peb yuav tsum sib txuas.

Peb tuaj yeem ua qhov no los ntawm kev mus rau View> Tool Windows> Database thiab nyem ntsuab "ntxiv" khawm.

Cov Ntaub Ntawv Qhov Chaw> MySQL thiab nyem (yog tias tam sim no) ntawm Rub tus tsav tsheb khawm uas tshwm.

Tom qab ntawd mus rau SSH/SSL thiab tshawb xyuas SSH. Sau rau tus tswv tsev/tus siv/tus lej nkag mus rau pi thiab siv chaw nres nkoj 22 yog tias tseem tsis tau sau.

Yog tias koj xav kom pycharm nco qab koj tus password kos lub npov "Nco tus password".

Hauv tab "General", sau rau hauv localhost hauv tus tswv tsev, phiaj xwm hauv Database thiab siv qhov project-admin nrog tus password kom tuaj yeem sim qhov kev sib txuas.

Tam sim no ua cov ntaub ntawv siv tau koj yuav tsum tau khiav.sql uas kuv tso rau hauv qab no. Sim siv qhov kev xaiv ntshuam, yog tias koj tsis tuaj yeem nqa cov ntaub ntawv pov tseg, koj yuav tsum ntxiv cov ntxhuav hauv tus kheej.

Tom qab qhov no ua tiav koj yuav tsum nrhiav cov ntawv teev npe sib txuas nrog ob lub.service cov ntaub ntawv. Hauv qhov hloov pauv txhua qhov seb koj pom nrog lub npe ntawm tus neeg siv koj siv ntawm koj tus pi. Tsis tas li, pab pawg yuav tsum yog www-data.

Cov kauj ruam tom ntej yog pib cov kev pabcuam no ntawm koj tus pi, zoo li:

sudo cp conf/project-*. service/etc/systemd/system/

sudo systemctl daemon-reload

sudo systemctl pib qhov project-*

sudo systemctl xwm txheej txoj haujlwm-*

Koj yuav tsum pom ob qhov kev pabcuam nquag thaum txhua yam mus raws txoj kev npaj.

Kauj ruam kawg yog ua kom nginx.

Ua ntej kuaj xyuas apache2 ntawm koj tus pi, yog tias koj tau teeb tsa qhov no, rho tawm nws lossis lov tes taw nws.

Hauv cov ntaub ntawv nginx koj yuav tsum xub hloov uwsgi_pass, tom qab ntawd ua cov lus txib no.

sudo cp conf/nginx/etc/nginx/sites-available/project

sudo rm/etc/nginx/sites-enabled/default

sudo ln -s/etc/nginx/sites-available/project1/etc/nginx/sites-enabled/project

sudo systemctl rov pib dua nginx.service

sudo systemctl xwm txheej nginx.service

Nginx yuav tsum nquag thiab ua haujlwm. Yog tias txhua yam raug, tam sim no koj tuaj yeem nthwv mus rau koj tus pi. Koj yuav pom "Nyob zoo ntiaj teb" thaum xub thawj tab sis koj tseem yuav tau hloov cov ntsiab lus ntawm cov ntawv ntawd nrog kuv cov lej hauv qab no.

Koj tuaj yeem pab cov kev pabcuam kom lawv yuav ua haujlwm tau zoo thaum pib pi.

Thaum koj ua qhov no, xyuas kom tseeb tias koj tso tsawg kawg 1 lub tsev nrog chaw nyob hauv lub database. Koj tuaj yeem ua qhov no nrog qhov yooj yim ntxig rau hauv.

Kauj ruam 4: Coding

Coding
Coding
Coding
Coding

Koj tuaj yeem rub tawm cov cai ntawm Github:

github.com/NMCT-S2-Project-I/project-i-Tib…

Cov cai rau cov ntsuas tau suav nrog hauv cov ntaub ntawv sensor.py.

Tsis txhob hnov qab hloov kuv lub npe rau hauv koj li (lossis tus neeg siv dua li koj siv ntawm koj tus pi) hauv cov ntaub ntawv pabcuam kom lawv tuaj yeem ua haujlwm tau zoo thiab tso kuv tus lej rau hauv cov ntaub ntawv twb muaj hauv koj lub Pycharm.

Kauj Ruam 5: Vaj Tsev

Vaj tse
Vaj tse
Vaj tse
Vaj tse
Vaj tse
Vaj tse
Vaj tse
Vaj tse

Kuv tau kos duab nrawm ntawm qhov kuv xav tau kuv lub tsev, tab sis koj li tuaj yeem zoo sib txawv. Koj tsuas yog yuav tsum ua kom ntseeg tau tias koj muaj tag nrho kom cov servo tuaj yeem qhib thiab kaw lub qhov rai.

Feem ntau kuv siv lub laum me me thiab pom los txiav ntoo. Kuv kuj tau ua kom ntseeg tau tias cov phab ntsa tau tuab txaus kom kuv tuaj yeem tso kuv cov servo sab hauv ntawm lawv.

Thaum koj ua tiav nrog koj tus qauv tsim thiab qhov kev pabcuam nyob hauv qhov chaw, koj tsuas yog yuav tsum txuas lub ntsuas cua thiab tso tus pi sab hauv ntawm lub tsev thiab koj tau npaj mus.

Raws li kuv tau hais ua ntej koj lub tsev tuaj yeem zoo ib yam li kuv li, koj tsuas yog yuav tsum muaj chaw nyob rau servo thiab lub qhov rais.

Thaum kawg koj tau ua tiav nrog txoj haujlwm. Kuv vam tias phau ntawv qhia no meej txaus kom koj ib yam tuaj yeem ua lub tsev smarthouse zoo li kuv tau ua.

Hmoov zoo.

Pom zoo: