Cov txheej txheem:

WeatherCar: 6 Kauj Ruam
WeatherCar: 6 Kauj Ruam

Video: WeatherCar: 6 Kauj Ruam

Video: WeatherCar: 6 Kauj Ruam
Video: Tshuav 6 Lub Hlis (A HeartBreaking Story That Will Make You Cry) 2024, Kaum ib hlis
Anonim
Huab Cua
Huab Cua

WeatherCar, qhov haujlwm me hauv tsev uas tuaj yeem tsav tsheb thaum tseem khaws cov ntaub ntawv muaj txiaj ntsig!

Kuv tau ua txoj haujlwm no ua zaum kawg rau kuv thawj xyoo hauv Howest of Kortrijk. Txoj haujlwm no tseem tsis tau ua tiav zoo tab sis daim ntawv no hais txog txhua sab hauv ntawm lub tsheb no, yam tsis tau ua lub thav duab puv.

Kauj ruam 1: Yuav tsum tau ua

Koj yuav xav tau tag nrho cov khoom no rau qhov haujlwm no:

  • Raspberry PI PIB
  • 2 x lub cev muaj zog (12v)
  • Servo
  • DHT11
  • NPE 280
  • GY-NEO6MV2 GPS module
  • 4 x NPN Transistors
  • 2 x Resistors (1k thiab 2k)
  • Tsav tsheb
  • 2x6v roj teeb pob
  • Prototyping board
  • Step-down voltage regulator
  • Rwb thaiv tsev tooj liab hlau
  • Tiaj tus cable
  • Qub Micro-USB cable
  • Plywood

Kauj ruam 2: Soldering / Txuas

Soldering / Txuas
Soldering / Txuas
Soldering / Txuas
Soldering / Txuas
Soldering / Txuas
Soldering / Txuas

Rau thawj kauj ruam peb yuav mus ncaj rau txuas txhua lub xov hlau. (PS. Koj tuaj yeem siv lub khob cij rau kev sim ua ntej ua txhua yam)

Kuv tau muab cov phiaj xwm uas qhia koj li cas kuv txuas txhua yam, txawm tias kuv nrhiav tsis tau qhov zoo rau kuv tus tsav tsheb. Rau kuv tus neeg tsav tsheb kuv siv 4 NPN transistors los hloov kuv 3.3v teeb liab mus rau 12v teeb liab los tswj tus tsav tsheb. Qhov no vim tias qhov kuv siv tsuas yog txhawb 1 qhov hluav taws xob (12v vim tias kuv lub cav yog 12v).

Kauj Ruam 3: Teeb Raspberry Pi

Yog tias koj tsis muaj teeb tsa twb tau ua tiav lawm, koj yuav tsum ua qhov no ua ntej, txwv tsis pub koj tuaj yeem hla cov kauj ruam no yog tias koj muaj cov haujlwm xav tau los ntawm cov lej kawg ntawm ntu ntu hauv qib no.

Ua ntej tshaj plaws koj yuav tsum rub tawm Raspbian desktop version, qhov twg tuaj yeem pom ntawm no:

Tom qab koj tau rub tawm qhov no koj yuav tsum tau siv Etcher lossis WinDiskImager txhawm rau muab daim duab tso rau hauv daim npav SD los ntawm koj tus raspberry Pi. (Qhov no tuaj yeem siv sijhawm me ntsis).

Thaum qhov haujlwm tau ua tiav, qhib cov ntawv tshawb nrhiav thiab qhib lub zog hu ua "boot". Hauv no koj yuav pom cov ntawv sau "cmdline.txt". Qhib qhov no thiab ntxiv ip = 169.254.10.1 mus rau qhov kawg ntawm cov ntawv. Ceev faj tsis txhob ntxiv ib qho nkag rau hauv cov ntaub ntawv vim qhov no tuaj yeem ua rau muaj teeb meem.

Tam sim no tias PI muaj qhov chaw nyob tsis yog IP, peb tseem yuav xav kom SSH tuaj yeem txuas rau nws. Koj tuaj yeem ua qhov no los ntawm kev ua cov ntaub ntawv tshiab hu ua "SSH" yam tsis muaj kev txuas ntxiv, qhov no yuav qhia rau raspberry pi kom pab ssh ntawm thawj khau raj.

Nrog rau qhov no peb tam sim no tuaj yeem txuas rau raspberry pi siv lub ethernet cable. Txuas lub xov tooj ntawm koj lub pc thiab raspberry PI. Tam sim no peb yuav xav tau tus neeg siv SSH. Rau qhov no kuv tau siv putty (https://www.putty.org/). Qhib cov putty thiab muab 169.254.10.1 ua lub npe hostname. Nws yuav siv sijhawm me ntsis ua ntej koj tuaj yeem txuas tau.

Thaum koj txuas nrog, nkag mus nrog cov ntawv pov thawj no:

ID nkag mus: piPassword: raspberry

Tam sim no peb tuaj yeem teeb tsa kev sib txuas hauv is taws nem, ua qhov no. Ua qhov lus txib no thiab hloov SSID thiab Network password nrog koj lub wifi lub npe thiab tus password.

ncha "password" | wpa_passphrase "SSID" >> /etc/wpa_supplicant/wpa_supplicant/wpa_supplicant.conf

wpa_cli -i wlan0 reconfigure

Tam sim no peb muaj kev sib txuas hauv is taws nem peb tuaj yeem teeb tsa nab hab sej thiab lwm yam haujlwm xav tau siv cov lus txib hauv qab no

sudo apt hloov tshiab

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

python3 -m pip nruab -hloov kho pip setuptools log virtualenv

mkdir huab cua && cd huab cua

python3 -m venv-system-site-packages env

qhov chaw env/bin/qhib

nab hab sej -m pip nruab mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask-MySQL mysql-connector-python passlib flask-socketio

Kauj ruam 4: Teeb Database

Tam sim no koj nyob nraum raspberry pi muaj txhua qhov kev xav tau, peb tseem yuav xav tau teeb tsa lub database. Wich peb tuaj yeem ua tau los ntawm thawj zaug pib Mysql

sudo mariadb

thiab ces

CREATE USER 'project1-admin'@'localhost' IDENTIFIED BY 'adminpassword'; CREATE USER 'project1-web'@'localhost' IDENTIFIED BY 'webpassword'; CREATE USER 'project1-sensor'@'localhost' IDENTIFIED BY 'sensorpassword';

Tsim DATABASE weathercar_db;

ZOO TSHAJ PLAWS YOOJ YIM TSHWJ XEEB ntawm huab cua.* Rau 'project1-admin'@'localhost' NROG QHOV ZOO TSHAJ PLAWS; GRANT SELECT, INSERT, hloov kho tshiab, tshem tawm ntawm qhov project1.* TO 'project1-web'@'localhost'; ZOO SIAB, Xaiv, Ntxiv, Hloov tshiab, RAWS LI QHOV project1.* TO 'project1-sensor'@'localhost'; FLUSH PRIVILEGES;

Kauj ruam 5: Code

Hauv qib no peb yuav cloning cov cai xav tau rau koj li raspberry pi. Qhov no peb yuav ua los ntawm kev ua qhov no:

Ua ntej tshaj plaws kom ntseeg tau tias koj nyob hauv koj phau ntawv teev npe hauv tsev los ntawm kev nkag mus "cd"

ua cd

tam sim no peb yuav clone lub chaw cia khoom siv

git clone

Tam sim no peb tuaj yeem ntshuam cov chaw teeb tsa siv:

sudo mariadb weathercar_db </weathercar/sql/weathercar_db_historiek.sql sudo mariadb weathercar_db </weathercar/sql/weathercar_db_sensoren.sql

Tam sim no peb tau ua tiav cov ntaub ntawv khaws cia peb tuaj yeem mus tom ntej thiab teeb tsa peb cov kev pabcuam

sudo cp weathercar/conf/project1-*. service/etc/systemd/system/sudo systemctl daemon-reloadsudo systemctl pib project1-*sudo systemctl qhib qhov project1-*

Kauj ruam 6: Txuas

Txuas!
Txuas!

Peb yuav luag nyob ntawd, tsuas yog ib kauj ruam ntxiv. Thiab qhov ntawd tau txais tus IP chaw nyob uas wifi muab rau peb.

Peb yuav ua qhov no los ntawm kev tso

ip addr ib

pawg ntawm crap yuav tshwm sim, tab sis koj yuav tsum muaj peev xwm nrhiav "wlan0" thiab tom qab ntawd ob peb kab ntxiv "inet 192.168.x.x"

muab tus IP chaw nyob ntawd rau hauv koj tus browser thiab tawm mus. Koj tau txuas nrog lub vev xaib.

Pom zoo: