Cov txheej txheem:

AirPi - Huab Cua Zoo Sensor: 8 Kauj Ruam
AirPi - Huab Cua Zoo Sensor: 8 Kauj Ruam

Video: AirPi - Huab Cua Zoo Sensor: 8 Kauj Ruam

Video: AirPi - Huab Cua Zoo Sensor: 8 Kauj Ruam
Video: ? Что такое многополосный 6 атомный хронометраж ? То 2024, Kaum ib hlis
Anonim
AirPi - Huab Cua Zoo Sensor
AirPi - Huab Cua Zoo Sensor

Koj puas tau xav tias vim li cas koj thiaj li mob taub hau? Thiab yog tias qhov no yog vim huab cua tsis zoo? Nrog rau cov cuab yeej no koj tuaj yeem tshawb xyuas seb qhov no puas yog. Cov cuab yeej no ntsuas CO2 tus nqi, TVOC-tus nqi, qhov kub thiab txias. Koj tuaj yeem pom huab cua zoo nyob ntawm LCD-zaub thiab pom qhov qhia meej yog tias nws tau txaus ntshai. Txoj kev no koj tuaj yeem qhib koj lub qhov rais kom raws sijhawm.

Yog tias koj nkag mus rau IP -adres - qhia thaum koj pib ntaus ntawv hauv koj tus browser - lub vev xaib yuav qhib. Koj tuaj yeem pom ntau cov ntaub ntawv hais txog ib puag ncig sab hauv tsev, nrog rau cov duab ntawm feeb / teev dhau los. Kuj tseem muaj qhov qhia nyob thiab qee cov ntaub ntawv thiab cov lus qhia ntawm lub dashboard.

Txoj haujlwm no yog tsim los ntawm tus menyuam kawm ntawv ntawm Howest Kortrijk, NMCT (Kev Tshaj Tawm Tshiab thiab Kev Sib Txuas Lus Tshuab).

Kauj ruam 1: Cov ntaub ntawv

Khoom siv
Khoom siv

Nov yog txhua yam kuv yuav los tsim txoj haujlwm no. Nov yog qhov haujlwm pheej yig, nyob ntawm tus nqi ntawm 3D-luam tawm. Yog tias koj tuaj yeem luam nws hauv tsev kawm ntawv qhov no tuaj yeem pheej yig heev. Txwv tsis pub nws nyob ntawm qhov chaw koj luam nws thiab cov khoom koj luam tawm hauv. Koj yuav pom tias kuv yuav ntau heev, tsuas yog vim nws nyuaj rau nrhiav tus neeg tiv thaiv lossis tus coj thiab qhov no ua rau nws pheej yig dua. Yog tias koj muaj sijhawm, koj tuaj yeem xaj khoom feem ntau ntawm aliexpress.com, kev xa khoom tuaj yeem siv sijhawm me ntsis, tab sis txoj hauv kev no koj tuaj yeem txwv koj cov nuj nqis.

Tsis muaj luam tawm, cov nyiaj kuv siv rau txoj haujlwm no yog € 81, 80.

Nov yog cov ntaub ntawv koj xav tau:

Circuit Court:

  • Raspberry Pi 3
  • SD daim npav 8GB (yam tsawg kawg nkaus)
  • CCS811 lub ntsuas cua zoo
  • DHT22 ntsuas kub thiab av noo
  • Potentiometer (sib piv LCD)
  • LCD 16 x 2
  • Poj niam rau poj niam jumper xov hlau
  • Ntsuab thiab liab LED
  • Resistors (2x470ohm thiab 1 4700ohm)

Rooj plaub:

  • 3D-luam tawm
  • Ntsia Hlau
  • 2 cov kua nplaum (lossis lwm cov kua nplaum kub)
  • xov-txiav cuab tam

Tsuas yog koj siv PCB:

  • Soldering hlau
  • Flux (ua kom yooj yim dua)
  • Tin
  • Kev sim pcb 2x4cm

Kauj ruam 2: Kev sib txuas

Kev sib txuas
Kev sib txuas

Txuas cov xov hlau raws li saud. Koj tuaj yeem pom hluav taws xob hluav taws xob hauv cov ntawv fritzing. Nws tsis yog qhov nyuaj hauv Circuit Court, tab sis yog tias koj xav ua kom nws me me li kuv ua tau, koj yuav tsum xav kom tau txais kev sim PCB Board. Txoj hlua yuav zoo ib yam, tshwj tsis yog GND thiab Vin yuav txuas nrog rau PCB pawg thawj coj. Cov ntsuas yuav txuas nrog los ntawm poj niam jumper xov lossis txiv neej nrog cov laug. Tsis txhob hnov qab muab tshuaj txhuam rau ntawm DHT22 sensor.

Kuv kuj pom zoo kom siv cov xov hluav taws xob luv, 10cm yuav tsum ua. Txwv tsis pub lub thawv yuav puv nrog cable ntau dua. Koj tsis xav tau ntev ntev vim tias qhov loj me ntawm cov ntawv luam tawm tau ua me me li sai tau.

Kauj ruam 3: 3D-luam tawm

3D-luam tawm
3D-luam tawm
3D-luam tawm
3D-luam tawm

Thawj qhov kev xav uas tshwm rau hauv kuv lub taub hau thaum kuv xav txog rooj plaub yog 3D-luam tawm. Txij li thaum kuv txiv tau luam tawm lwm yam khoom siv thiab nws tsim lawv tus kheej. Ua ke peb tsim cov qauv no, thiab xav txog txhua yam. Nws yuav tsum tau txias txaus, txhua yam tuaj yeem ntsia tau rau hauv qhov chaw thiab yog tias tsis yog, nws tuaj yeem raug thawb rau hauv qhov chaw.

Peb txawm kos txhua feem los tshuaj xyuas yog tias txhua yam haum rau hauv. Cov ntaub ntawv muaj rau txhua tus thiab peb xav hnov cov lus tawm tswv yim. Peb zoo siab heev nrog qhov tshwm sim.

Kauj ruam 4: Code

Cov cai rau txoj haujlwm no tuaj yeem pom ntawm Github. Yog tias koj tau siv lwm tus pin (piv txwv li lwm tus GPIO-tus pin rau LED's, koj yuav tau kho cov kev hloov pauv no. Yuav muaj ob tus nab nab sau ntawv khiav, web.py rau lub vev xaib thiab sensor.py los nyeem cov cim thiab hloov tshiab Peb yuav xa cov chav kawm LCD los ntawm lcd.py.

Nrog kev teeb tsa raspberry pi koj tuaj yeem pib. Ua ntej tshaj plaws koj yuav tsum tau hloov kho thiab txhim kho txhua pob:

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

Tom qab ntawd koj yuav tsum tau teeb tsa cov pob hauv qab no:

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

Tam sim no tsim ib puag ncig virtual:

kuv@kuv -rpi: ~ $ python3 -m pip nruab -hloov kho pip setuptools log virtualenv

kuv@my-rpi: ~ $ mkdir project1 && cd project1 kuv@my-rpi: ~/project1 $ python3 -m venv --system-site-packages env me@my-rpi: ~/project1 $ source env/bin/ qhib (env) kuv@my-rpi: ~/project1 $ python -m pip nruab mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask-MySQL mysql-connector-python passlib

Txij li qhov no ua tiav, koj tuaj yeem clone tus lej los ntawm kuv GitHub rau hauv koj qhov chaw ib puag ncig. Qhov no tuaj yeem ua tiav hauv ntau txoj kev.

Hauv cov npe conf koj tuaj yeem pom plaub cov ntaub ntawv koj yuav tau kho yog tsim nyog. Koj yuav tsum tau hloov pauv tus neeg siv thiab homedirectory hauv txhua cov ntaub ntawv. UWSGI ini yuav tsum zoo yog tias koj tsis hloov kuv tus lej, nco ntsoov hloov tus neeg siv thiab virtualenv yog tias tsim nyog.

Txij li CCS811 lub cuab yeej tau txhob txwm siv rau arduino, qhov no tsis tuaj yeem sib txuas lus hla lub npav i2c ntawm qhov nrawm ntawm raspberry pi. Koj yuav tsum txo qhov nrawm mus rau baudrate ntawm 10000 (Kuv siv 9600) hauv cov ntawv teeb tsa.

Koj kuj tseem yuav tsum tau txais lub tsev qiv ntawv ntawm adafruit sensor. Kuv tuaj yeem piav qhia qhov no ntawm no tab sis muaj cov lus qhia zoo adafruit uas piav qhia txhua yam no zoo heev.

Vim tias peb xav kom cov nab hab sej sau ua haujlwm thaum lub raspberry txuas nrog, koj yuav tau siv cov kev pabcuam. Lawv yuav tsum zoo yog tias koj khaws kuv cov cai. Txhua yam koj yuav tsum tau ua kom lawv khiav yog pab lawv. Ua ntej koj ua qhov ntawd muaj ib yam kawg.

Txij li thaum peb tab tom siv nginx webserver, peb yuav tau deactivate lub neej ntawd thiab hloov nws los ntawm peb tus kheej teeb tsa. Txhawm rau ua cov kauj ruam no yuav tsum ua raws:

  • luam conf/nginx rau *chaw-muaj *
  • Tshem qhov txuas mus rau qhov default-config
  • Ntxiv qhov txuas mus rau qhov teeb tsa tshiab
  • Rov pib dua nginx kom txuag qhov kev hloov pauv

kuv@kuv-rpi: ~/project1 $ sudo cp conf/project1-*. service/etc/systemd/system/

kuv@kuv-rpi: ~/project1 $ sudo systemctl daemon-reload kuv@my-rpi: ~/project1 $ sudo systemctl pib project1-* kuv@my-rpi: ~/project1 $ sudo systemctl xwm txheej project1-*

Nginx thiab mysql yuav tsum tau khiav txhua lub sijhawm. Lawv pib nrog raspberry pi. Lub vev xaib tsab ntawv thiab cov ntawv ntsuas tsis yog tseem tsis tau.

Txhawm rau ua qhov no koj tseem xav tau los pab ob qhov kev pabcuam no nrog cov lus txib no:

sudo systemctl pab kom project1-flask.service

sudo systemctl pab kom project1-sensor.service

Kauj ruam 5: Database

Database
Database

Kuv lub database muaj peb lub rooj. Tus neeg siv tsis muaj kev cuam tshuam nrog lwm cov ntxhuav. Qhov no tsuas yog siv los nkag rau hauv thiab tso cai nkag mus rau lub vev xaib. Thaum qhib lub cuab yeej, CO2 tus nqi thiab TVOC-tus nqi yuav raug sau rau hauv lub database txhua 50 vib nas this. Qhov kub thiab av noo txhua 5 feeb. Txoj hauv kev no peb tau txais cov ntsiab lus meej txog yav dhau los.

SQL-cov ntaub ntawv tuaj yeem pom nyob ntawm no, tab sis kom tau txais cov ntaub ntawv ntawm raspberry pi, koj yuav tsum ua raws cov theem no:

Tom qab kev teeb tsa pob khoom hauv cov kauj ruam dhau los, mariadb/mysql yuav tsum tau khiav tam sim ntawd. Koj tuaj yeem tshawb xyuas qhov no nrog kab no:

kuv@kuv-rpi: ~ $ sudo systemctl xwm txheej mysql

Txhawm rau tsim cov ntaub ntawv thiab cov neeg siv koj tuaj yeem yooj yim khiav cov sql-script hauv cov cai los ntawm GitHub. Yog tias koj ua qhov no raug koj yuav tsum pom koj cov ntxhuav siv cov lus txib no:

kuv@kuv-rpi: ~ $ ncha 'qhia ntxhuav;' | mysql project1 -t -u project1 -admin -p

Tam sim no peb tau teeb tsa tag nrho, koj tuaj yeem sim qhov no yam tsis muaj rooj plaub kom ntseeg tau tias txhua yam ua haujlwm. Tshwj tsis yog tias koj txuas nrog wifi, koj yuav tsum txuas nws nrog ethernet cable thiab khiav nws tus kheej.

Kauj Ruam 6: Txuas rau Wi-nkaus

Qhib cov ntaub ntawv teeb tsa wpa-supplicant hauv nano (tsis muaj teeb meem tiag tiag, tsuas yog xyuas kom koj tuaj yeem ua haujlwm nrog cov ntawv sau).

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Mus rau hauv qab ntawm cov ntawv thiab ntxiv cov hauv qab no (hloov ssid-name thiab password-name los ntawm koj li):

network = {

ssid = "ssid-name" psk = "password-name"}

Txhawm rau tsim tus lej zais koj tuaj yeem siv wpa_passphrase thiab yooj yim luam nws mus rau hauv wpa_supplicant.conf psk kom ua tej yam muaj kev nyab xeeb dua.

wpa_passphrase "ssid-name" "password-name"

Yog tias koj xav kom nws txuas mus rau Wi-nkaus network tau txais, thiab muaj lwm tus hauv cov ntawv teeb tsa, nco ntsoov tias koj hloov qhov tseem ceeb mus rau qib siab dua los ntawm kev ntxiv kab no rau hauv network hauv cov ntaub ntawv teeb tsa:

qhov tseem ceeb = 2

Tsis txhob hnov qab rov teeb tsa lub interface nrog:

wpa_cli -i wlan0 reconfigure

Tam sim no koj tau teeb tsa thiab txuas nrog lub network wifi.

Kauj Ruam 7: Muab Txhua Yam Ua Ke

Muab Txhua Yam Ua Ke
Muab Txhua Yam Ua Ke
Muab Txhua Yam Ua Ke
Muab Txhua Yam Ua Ke
Muab Txhua Yam Ua Ke
Muab Txhua Yam Ua Ke

Txij li txhua yam tau txuas thiab txuas, peb tuaj yeem mus rau rooj plaub. Qhov no tau tsim, yog li koj tuaj yeem qhib rooj plaub yam tsis muaj xaim xaim. Qhov no txhais tau tias txhua yam raug txuas rau hauv qab. Thawj qhov ua yog kho me ntsis rau raspberry. Nws muaj qhov nyob hauv nws ntawm txhua lub ces kaum, tab sis cov no tsis loj li lawv yuav tsum yog. Txoj kab uas hla yuav tsum txaus kom haum rau 3 hli ntsia hlau sab hauv. Peb yuav tsum txhuam cov qhov kom lawv tau dav dua me ntsis.

Qhov thib ob ua yog txiav cov ntsia hlau xov rau hauv txhua lub qhov. Qhov no yuav hnov nyuaj tab sis tuaj yeem ua tau yooj yim nrog cov cuab yeej raug. Kuv xav kom ua qhov no ntawm lub khw muag khoom kho vajtse hauv ib cheeb tsam, tsuas yog thov cov cuab yeej txiav xov. Txij li thaum kuv txiv yog tus kws tshaj lij hlau nws muaj cov cuab yeej los ua qhov no ntawm haujlwm. Kuv yuav xa cov ntaub ntawv tshiab stl kom qhov no luam tawm tom qab, tab sis qhov no yuav xav tau lub tshuab luam ntawv zoo heev.

Cov kauj ruam thib peb yog ntswj tus pi mus rau hauv qab. Koj yuav xav tau 4 7mm ntsia hlau ntev nrog txoj kab uas hla ntawm 3 hli. Tom qab qhov no koj tuaj yeem thawb PCD lub rooj tsavxwm rau hauv qhov chaw muab rau saum toj ntawm hauv qab. CCS811 lub tshuab tuaj yeem raug thawb mus rau qhov chaw muab rau ntawm sab laug thiab DHT11 tuaj yeem txuas rau sab xis ntawm lub phaj. Ob leeg raug cais tawm thiab tso pa tawm kom txaus, tab sis tom qab ntawd peb pom tias nws tseem tau kub sab hauv. Ntau ntxiv txog qhov ntawd tom qab.

Tom qab ntawd koj yuav tsum xa cov LED mus rau lawv lub raj. Peb tau ua qhov no nrog 2 cov kua nplaum tab sis koj tuaj yeem ua nws txawm li cas los xij koj nyiam. Nco ntsoov tias lawv lo rau ntawd.

Tam sim no koj tuaj yeem txuas lub LCD-zaub, koj yuav xav tau cov ntsia hlau nrog tib txoj kab uas hla zoo li yav dhau los, tab sis ntev me ntsis. Kuv yog 1cm. Yog tias plaub tus ntsia hlau raug ntsia, tsuas muaj ib yam uas yuav tsum tau ua. Txuas rau sab saum toj. Txhua yam koj xav tau yog plaub tus ntsia hlau, nrog tib txoj kab uas hla thiab cov no yog 2cm. Tam sim no txhua yam yuav tsum nyob hauv qhov chaw thiab koj tuaj yeem pib nws.

Kauj ruam 8: Pib Nws

Cov txheej txheem pib ua haujlwm ntawm txoj haujlwm no yooj yim heev:

  1. Muab lub hwj huam txuas rau sab laug ntawm rooj plaub. Nws tsis pom ntau tab sis koj tuaj yeem pom los ntawm lub qhov cua. Yog tias koj tau txais nws ib zaug qhov no yuav tsis muaj teeb meem ntxiv.
  2. Muab nws qee lub sijhawm kom pib.
  3. IP-chaw nyob yuav tshwm rau ntawm lub vijtsam rau kaum vib nas this. Ib yam uas koj yuav tsum tau ua yog xyuas kom koj tau txuas nrog tib lub network thiab sau tus IP-chaw nyob rau hauv qhov chaw nyob bar ntawm koj tus browser.
  4. Tam sim no koj nyob ntawm lub vev xaib. Koj tseem tsis tau muaj tus account yog li tsim tus account.
  5. Yog tias koj tau sau npe, nkag mus.
  6. Ua tiav! Koj tuaj yeem pom txhua cov ntaub ntawv ntawm lub vev xaib thiab LCD-zaub tau qhia txog huab cua zoo tam sim no.

Txij li kev sov siab nce, peb tau pom lub ntsuas cua nyob hauv qab ntawm rooj plaub. Txoj hauv kev no qhov kub thiab txias yuav tsis muaj kev cuam tshuam loj rau cov npe sau cia. Yog li txhawm rau ntsuas qhov zoo tshaj plaws, ua rau lub cuab yeej sawv ntsug lossis koj tuaj yeem yooj yim dai nws rau ntawm phab ntsa.

Pom zoo: