Cov txheej txheem:

RPi Weatherstation Nrog Lub Vev Xaib Teb: 5 Cov Kauj Ruam
RPi Weatherstation Nrog Lub Vev Xaib Teb: 5 Cov Kauj Ruam

Video: RPi Weatherstation Nrog Lub Vev Xaib Teb: 5 Cov Kauj Ruam

Video: RPi Weatherstation Nrog Lub Vev Xaib Teb: 5 Cov Kauj Ruam
Video: tinyML Summit 2021: Edge ML hardware for every application 2024, Kaum ib hlis
Anonim
RPi Weatherstation Nrog Lub Vev Xaib Zoo
RPi Weatherstation Nrog Lub Vev Xaib Zoo
RPi Weatherstation Nrog Lub Vev Xaib Zoo
RPi Weatherstation Nrog Lub Vev Xaib Zoo

Txog rau tsev kawm ntawv txoj haujlwm peb yuav tsum ua IoT ntaus ntawv nrog lub vev xaib kom pom kev sib sau cov ntaub ntawv hauv txoj hauv kev zoo. Kuv tau xaiv los ua huab cua huab cua uas siv los ntawm Raspberry Pi 3 khiav Flask rau lub vev xaib teb, MySQL (MariaDB) rau kuv lub database thiab tsab ntawv nab nab rau sib sau ua ke cov ntaub ntawv nrog txhua yam kuv lub sensor. Nws coj kuv li 2 lub lis piam txij thaum pib kom tiav kom tiav.

Peb tau txhawb kom ua cov lus qhia los qhia peb qhov kev nce qib nrog rau lwm qhov ntawm DIY zej zog, yog li ntawm no yog!

Kauj Ruam 1: Xaiv Ib Feem, Cov Cuab Yeej thiab Cov Khoom

Ua ntej kuv xav tau los txheeb xyuas seb hom kev ntsuas dab tsi yog qhov tseem ceeb rau chaw nres tsheb huab cua. Kuv txiav txim siab kuv xav ntsuas txhua yam ntawm cov ntaub ntawv hauv qab no:

  • Kub
  • Huab cua siab
  • Vaum
  • Cua hlob
  • UV Index

Nov yog tag nrho Cov Cuab Yeej, Cov Khoom Siv thiab Cov Khoom Kuv tau siv

Qhov:

  • DHT22/AM2302 rau ntsuas kub thiab noo noo. (15 EUR)
  • Adafruit BMP280 rau Barometric Siab thiab ntsuas kub. (12 EUR) Nqe lus piav qhia
  • Adafruit SI1145 rau ntsuas UV Index. (10 EUR)
  • Adafruit Analog Anemometer rau ntsuas cua cua (50 EUR)
  • MCP3008 rau kev hloov pauv cov cim sib piv rau digital.
  • 10kOhm Resistor li rub tawm rau kuv AM2302.
  • A 9V Adapter rau 'ua kom lub zog' Anemometer
  • A 5V Adapter rau Raspberry Pi
  • Raspberry Pi 3 (Txhua Pi yuav tsum txaus)

Cov ntaub ntawv:

Lub thawv yas rau khaws cia txhua yam thiab ua rau nws los nag

Cov Cuab Yeej:

  • Soldering Hlau thiab Tin
  • Multimeter
  • Silicone
  • Ib co kab xev

Yog li tag nrho txhua qhov ntsuas tau raug nqi kuv txog 85 Euro's, uas yog ntxhab heev tab sis kuv yeej xav suav nrog lub ntsuas cua cua kom raug yog li kuv xav tias nws tsim nyog nws.

Koj tuaj yeem pom cov npe ntxaws ntxaws nrog cov khw koj tuaj yeem yuav txhua yam ntawm, hauv pdf hauv qab no:)

Kauj Ruam 2: Txuas Peb Cov Khoos Phis Tawj

Txuas Peb Kho Vajtse
Txuas Peb Kho Vajtse
Txuas Peb Kho Vajtse
Txuas Peb Kho Vajtse

Yog lawm peb yuav xav txuas peb lub ntsuas hluav taws xob mus rau peb Raspberry Pi.

Ntawm cov txheej txheem koj tuaj yeem pom lub roj teeb 9V tau siv los ua lub zog siv rau peb lub ntsuas cua, qhov no yog qhov siv tau zoo tshaj plaws rau kev sim tsuas yog vim nws yuav tsis nyob ntev dhau, koj tuaj yeem hloov lub roj teeb 9V rau ib qho 7-12V lub zog siv rau koj xaiv

Peb lub SI1145 thiab BMP280 cov ntsuas yuav ob qho tib si tswj hwm siv I2C raws tu qauv vim qhov no yog qhov yooj yim tshaj plaws los ua haujlwm nrog thiab xav tau xov tooj tsawg dua.

Lub ntsuas hluav taws xob ntawm lub ntsuas hluav taws xob tau qhia ua LDR ntawm no vim tias nws muaj cov kab hluav taws xob zoo ib yam li lub ntsuas hluav taws xob thiab kuv tsis tuaj yeem pom lub ntsuas cua tiag tiag los tso rau hauv kuv qhov kev sib tw schematic:)

Kauj Ruam 3: Txuas Txhua Yam: Teeb Tus Pi

Txuas Txhua Yam: Teeb Tus Pi
Txuas Txhua Yam: Teeb Tus Pi

Ua ntej tshaj plaws, peb yuav tsum paub tseeb tias peb tau txuas nrog internet.

Txhawm rau ua qhov no hauv lub davhlau ya nyob twg koj tuaj yeem mus rau koj cov ntaub ntawv wpa_supplicant los ntawm kev ua cov lus txib hauv qab no: sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Hauv cov ntawv koj tuaj yeem ntxiv qhov no:

network = {ssid = "Your_Wifi_SSID" psk = "Your_Wifi_Password" key_mgmt = WPA-PSK

}

Koj kuj tseem tuaj yeem xaiv teeb tsa koj tus IP-chaw nyob zoo li qub kom nkag tau yooj yim dua yav tom ntej.to ua qhov no koj yuav tsum mus rau dhcpcd.conf cov ntaub ntawv los ntawm kev ua cov lus txib no: sudo nano /etc/dhcpcd.conf

Ntxiv qhov no hauv cov ntawv:

interface wlan0static ip_address = 192.168.0.100/24

Tom qab ntawd peb yuav ua kom ntseeg tau tias cov pob uas twb tau teeb tsa ntawm peb Pi tau hloov kho tshiab:

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

Qhov no yuav siv sijhawm me ntsis, yog li tsis txhob txhawj

Koj yuav xav tau los pab I2C thiab SPI raws tu qauv hauv raspi teeb tsa.you tuaj yeem ua qhov no los ntawm kev ua cov lus txib no:

sudo raspi-teeb tsa

Tom qab ntawd mus rau cov kev xaiv cuam tshuam, thiab ua kom ob qho tib si, I2C thiab SPI

Ua ntej koj yuav tsum ua cov npe uas koj xav muab koj txoj haujlwm rau hauv (peb yuav lub npe nws 'weatherstation'):

cd ~ mkdir weatherstationcd weatherstation

Tom qab ntawd peb teeb tsa peb li nab nab 3 virtual enviroment:

python3 -m pip install-upgrade pip setuptools log virtualenvpython3 -m venv --system-site-packages envsource env/bin/activatepython -m pip install mysql-connector-python Flask-mysql mysql-connector-python passlib mysql-connector -pib-rf

Tom qab ntawd peb yuav tsum tau teeb tsa qee lwm pob khoom uas xav tau los ua kom txhua yam ua haujlwm tau raug:

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

Tam sim no peb tab tom ua peb li database:

Peb tseem yuav tsum teeb tsa peb cov ntaub ntawv txawm hais tias koj tuaj yeem ua qhov no los ntawm kev ua cov cai/sql cov ntaub ntawv nyob hauv 'sql' nplaub tshev zoo li no:

sudo mariadb <sql/db_init.sql

Cov lus nug sql yuav ua rau cov ntxhuav peb xav tau thiab tseem ua rau ob peb tus neeg siv los ua peb cov ntaub ntawv ruaj ntseg me ntsis.

Qhov no tseem yuav muab qee cov piv txwv keeb kwm cov ntaub ntawv tso rau hauv peb lub database kom ntseeg tau tias peb lub vev xaib qhia txhua yam kom raug thaum tseem tsis tau muaj cov ntaub ntawv sau tseg tiag.

Txhawm rau nruab Adafruit_GPIO thiab MyPyDHT koj yuav tsum tau ua qee yam ntxiv.

git clone https://github.com/adafruit/Adafruit_Python_GPIO.gitcd Adafruit_Python_GPIO sudo python3 setup.py nruab

cd..git clone -recursive https://github.com/freedom27/MyPyDHTsudo python3 setup.py nruab

Kauj ruam 4: Software / Code

Software / Code
Software / Code
Software / Code
Software / Code
Software / Code
Software / Code

Peb yuav tsum teeb tsa lub nraub qaum rau huab cua, uas suav nrog:

- Ib qhov chaw khaws ntaub ntawv mariadb rau khaws kuv lub ntsuas nyeem ntawv thiab qee yam lwm yam me- Cov kev pabcuam lub raj dej rau kev khiav lub vev xaib.- Lwm qhov kev pabcuam uas khiav cov ntaub ntawv nab hab sej uas nyeem tawm txhua lub cim xeeb. tsis tsim nyog, tab sis txij li kuv xav tau kev nkag mus vim kuv (txawm tias tag nrho cov ntaub ntawv zoo ib yam rau txhua tus neeg siv) Kuv txiav txim siab suav nrog hauv kuv cov ntaub ntawv khaws tseg.

Koj tuaj yeem mus tom ntej thiab clone kuv txoj haujlwm tus lej los ntawm Github rau hauv koj cov ntawv tais ceev tseg. Koj mus rau koj cov neeg siv ntawv tais ceev tseg thiab khiav: git clone https://github.com/BertVanhaeke/Weatherstation/ tempmv -v temp/* weatherstation/

Tom qab ntawv mus rau daim nplaub tshev conf hauv huab cua thiab txhua cov ntaub ntawv hauv daim nplaub tshev.

Hloov txhua qhov tshwm sim ntawm 'USERNAME' rau koj lub npe siv

Koj kuj tseem yuav tsum luam ob qho ntawm.service cov ntaub ntawv rau systemd thiab sim lawv zoo li no:

sudo cp conf/weatherstation-*. service/etc/systemd/system/sudo systemctl daemon-reloadsudo systemctl pib weatherstation-flask.servicesudo systemctl pib weatherstation-sensor.service

sudo systemctl xwm txheej huab cua-*

Tom qab ntawd peb yuav tsum hloov kho nginx teeb tsa.

sudo cp conf/nginx/etc/nginx/sites-available/weatherstationsudo rm/etc/nginx/sites-enabled/defaultsudo ln -s/etc/nginx/sites-available/weatherstation/etc/nginx/sites-enabled/weatherstationsudo systemctl rov pib dua nginx.servicesudo systemctl xwm txheej nginx.service

Yog tias txhua yam mus tau zoo koj yuav tsum tuaj yeem ua qhov no thiab tau txais qee qhov html luam tawm hauv lub davhlau ya nyob twg:

wget -qO - localhost

Txhua yam yuav tsum ua haujlwm tau zoo tam sim no. Koj tuaj yeem nkag mus rau koj tus raspberry Pi tus IP-chaw nyob peb tau teeb tsa thaum pib thiab tos txais nrog tus ID nkag mus.

Kauj Ruam 5: Qhov Kev Ruaj Ntseg

Cov ntaub ntawv kaw
Cov ntaub ntawv kaw
Cov ntaub ntawv kaw
Cov ntaub ntawv kaw
Cov ntaub ntawv kaw
Cov ntaub ntawv kaw

Tam sim no txhua yam ua haujlwm, peb yuav tsum muab tag nrho rau hauv ib yam dab tsi.

Kuv tau xaiv lub thawv yas yooj yim nrog lub hau zoo sib xws. Qhov ntsuas cua ntsuas tau muab tso rau saum nws, thiab yog li yog lub thawv me me thib ob uas muaj DHT22 thiab BMP280 lub ntsuas.

Cov ntsuas no tau teeb tsa sab hauv lub thawv cais vim tias lawv xav tau nyob hauv huab cua qhib (yam tsis tau los nag), tab sis raspberry pi tsis xav tau.

Raws li koj tuaj yeem pom kuv ntxiv qee cov silicone nyob ib ncig ntawm ntug kom nws tsis muaj dej. Kuv kuj tau nqus qee qhov hauv lub thawv ntim sab saud kom tau txais huab cua ntshiab hauv nws.

Kuv vam tias koj txaus siab rau kuv phau ntawv qhia yuav ua li cas tsim lub chaw huab cua, nws yuav nyuaj me ntsis ib puag ncig txij li nws yog kuv thawj zaug sau phau ntawv qhia zoo li no, tab sis kuv vam tias koj nyiam nws txawm li cas los xij:)

Pom zoo: