Cov txheej txheem:

Tiag Tiag GPS Taug Qab: 3 Kauj Ruam
Tiag Tiag GPS Taug Qab: 3 Kauj Ruam

Video: Tiag Tiag GPS Taug Qab: 3 Kauj Ruam

Video: Tiag Tiag GPS Taug Qab: 3 Kauj Ruam
Video: Kuv Raug Koj Xa Rov Qab Nplog Teb.3/17/23 2024, Hlis ntuj nqeg
Anonim

Los ntawm elizabethnaFollow Ntxiv los ntawm tus sau:

Pumpkin Pi Trick-or-Treat Tracker
Pumpkin Pi Trick-or-Treat Tracker
Pumpkin Pi Trick-or-Treat Tracker
Pumpkin Pi Trick-or-Treat Tracker
Yuav Ua Li Cas Tsim Raspberry Pi Qhov Ntsuas Kub
Yuav Ua Li Cas Tsim Raspberry Pi Qhov Ntsuas Kub
Yuav Ua Li Cas Tsim Raspberry Pi Qhov Ntsuas Kub
Yuav Ua Li Cas Tsim Raspberry Pi Qhov Ntsuas Kub
Kwj Cov Ntaub Ntawv Los Ntawm Google Cov Ntawv rau Dashboard
Kwj Cov Ntaub Ntawv Los Ntawm Google Cov Ntawv rau Dashboard
Kwj Cov Ntaub Ntawv Los Ntawm Google Cov Ntawv rau Dashboard
Kwj Cov Ntaub Ntawv Los Ntawm Google Cov Ntawv rau Dashboard

Hauv qhov kev qhia no, peb yuav qhia koj yuav ua li cas thiaj li ua tiav qhov chaw taug qab siv BerryGPS-GSM, Raspberry Pi Zero, thiab Lub Xeev Pib. Peb yuav xa qhov ntev, latitude thiab nrawm ntawm 3G nrog BerryGPS-GSM rau Lub Xeev Pib.

Khoom siv

  • Raspberry Pi Zero
  • BerryGPS-GSM
  • Lub Xeev Thawj

Kauj Ruam 1: Thawj Xeev

Lub Xeev Thawj
Lub Xeev Thawj

Peb xav kom tshaj tawm tag nrho peb qhov ntev, kab rov tav, thiab cov ntaub ntawv nrawm rau cov kev pabcuam huab thiab muaj qhov kev pabcuam ntawd tig peb cov ntaub ntawv mus rau hauv lub dashboard zoo uas peb tuaj yeem nkag tau los ntawm peb lub khoos phis tawj lossis lub xov tooj ntawm tes. Peb yuav siv Thawj Lub Xeev.

Kauj Ruam 1: Sau npe rau Tus Thawj Xib Fwb Hauv Xeev

Mus rau https://iot.app.initialstate.com thiab tsim tus as khauj tshiab. Koj tau txais 14 hnub kev sim pub dawb thiab txhua tus neeg nrog edu email chaw nyob tuaj yeem tso npe rau txoj kev npaj kawm dawb.

Kauj ruam 2: Nruab ISStreamer

Txhim Kho Thawj Lub Xeev Python module rau koj li Raspberry Pi. Hauv qhov hais kom ua, khiav cov lus txib hauv qab no:

$ cd/tsev/pi/

$ / curl -sSL https://get.initialstate.com/python -o -| sudo tsoo

Kauj Ruam 3: Ua qee Automagic

Tom qab Kauj Ruam 2 koj yuav pom qee yam zoo ib yam li cov hauv qab no tso rau ntawm qhov screen:

pi@raspberrypi ~ $ / curl -sSL https://get.initialstate.com/python -o -| sudo bashPassword: Pib ISStreamer Python Yooj Yim Txhim Kho! Qhov no yuav siv ob peb feeb los teeb tsa, rub qee lub kas fes:) Tab sis tsis txhob hnov qab rov qab los, Kuv yuav muaj lus nug tom qab! Pom yooj yim_install: setuptools 1.1.6 Pom pip: pip 1.5.6 los ntawm /Library/Python/2.7/site-packages/pip-1.5.6- py2.7.egg (sej 2.7) pip loj version: 1 pip me me version: 5 ISStreamer pom, hloov kho… Yuav tsum tau hloov kho tshiab tas li: ISStreamer hauv Tsev Qiv Ntawv/Python/2.7/site-packages Tu tu… Koj puas xav tau automagically tau txais ib qho piv txwv tsab ntawv? [y/N] Koj xav khaws qhov piv txwv nyob qhov twg? [lub neej ntawd:./is_example.py] Thov xaiv qhov Xeev Lub Xeev app uas koj siv: 1. app.initialstate.com 2. [TSHIAB!] iot.app.initialstate.com Nkag mus xaiv 1 lossis 2: Nkag mus rau iot.app.initialstate.com tus neeg siv lub npe: Nkag mus rau iot.app.initialstate.com lo lus zais:

Thaum nug yog tias koj xav tau automagically tau txais ib qho piv txwv tsab ntawv muab "y" rau yog thiab nias sau kom txuag tau koj cov ntawv hauv qhov chaw nyob. Txog cov lus nug txog app twg koj tab tom siv, xaiv 2 (tshwj tsis yog koj tau kos npe ua ntej lub Kaum Ib Hlis 2018) thiab sau koj lub npe siv thiab tus password.

Kauj Ruam 4: Khiav Cov Piv Txwv

Khiav cov ntawv xeem kom paub tseeb tias peb tuaj yeem tsim cov ntaub ntawv xa mus rau koj Tus Thawj Xeev tus as khauj. Sau cov lus txib hauv qab no:

$ python is_example.py

Kauj Ruam 5: Piv Txwv Cov Ntaub Ntawv

Rov qab mus rau koj lub Xeev Thawj tus lej hauv koj lub vev xaib. Ib lub thoob cov ntaub ntawv tshiab hu ua "Python Stream Piv txwv" yuav tsum tau tshwm nyob rau sab laug hauv koj lub txee rau khoom (koj yuav tau rov ua nplooj ntawv tshiab). Nyem rau ntawm lub thoob no txhawm rau saib koj cov ntaub ntawv.

Kauj Ruam 2: BerryGPS-GSM & Raspberry Pi Zero

BerryGPS-GSM & Raspberry Pi Zero
BerryGPS-GSM & Raspberry Pi Zero

Yog tias koj siv BerryGPS-GSM, koj tuaj yeem ua raws phau ntawv qhia no kom tau txais GPS ua haujlwm thiab tau txais koj tus Pi txuas nrog 3G siv PPP.

Cov ntawv qhia txuas tseem qhia tau tias yuav ua li cas thiaj ua rau koj Pi txuas rau lub network thauj khoom tau txais thaum khau raj. Koj yuav xav tau qhov no yog tias koj npaj yuav ua haujlwm taug qab.

Nruab Libraries

Koj yuav tsum tau teeb tsa cov tsev qiv ntawv hauv qab no:

$ sudo apt-tau nruab sej-pip

$ sudo pip nruab pynmea2 $ sudo pip nruab ISStreamer

Main Python Script

Ntawm no peb yuav tsim tsab ntawv tseem ceeb uas yuav xa cov ntaub ntawv GPS mus rau Lub Xeev Thawj. Qhov cai hauv qab no tsim cov xov sib cais uas yog siv los saib xyuas qhov chaw nres nkoj. Qhov no xav tau vim tias peb tau ncua hauv lub voj loj. Qhov kev ncua yog muaj los txwv ntau npaum li cas cov ntaub ntawv peb upload ntau dua 3G.

Yog tias peb tau ua txhua yam hauv tib txoj xov thaum lub sijhawm ncua, qhov tsis tuaj yeem ua tiav (nws yog FIFO) thiab thaum peb tau txais tus nqi tom ntej los ntawm qhov tsis, nws yuav laus dua los ntawm ob peb feeb. Qhov no tshwm sim txhua lub voj thiab thaum kawg cov ntaub ntawv yuav yog feeb lossis teev tom qab.

Txhawm rau tsim cov ntawv nab hab sej thiab qhib cov ntawv sau sau cov lus txib hauv qab no:

$ nano GPStracker.py

Luam thiab paste cov cai hauv qab no rau hauv cov ntawv sau. Koj yuav tsum tau nkag mus rau koj Thawj Lub Xeev Nkag Mus Nkag Mus Rau Tus lej ntawm kab 11 qhov twg yog hais tias "ENTER YOUR ACCESS KEY":

#! /usr/bin/pythonfrom gps ntshuam * los ntawm lub sijhawm ntshuam * ntshuam xov ntshuam ntshuam lub sijhawm los ntawm ISStreamer. Streamer ntshuam Streamer gpsd = Tsis muaj #Setup thoob ntiaj teb tsis sib xws #teeb tsa Lub Xeev Thawj kwj, nkag mus rau koj tus yuam sij nkag hauv qab streamer = Streamer (bucket_name = "GPS_Tracker ", bucket_key =" GPS_TRACKER ", access_key =" ENTER YOUR ACCESS KEY ") chav kawm GPSDcollector (threading. Thread): def _init _ (self, threadID): threading. Thread._ init _ (self) self.threadID = threadID ntiaj teb gpsd #bring nws nyob hauv qhov dav gpsd = gps (hom = WATCH_ENABLE) #Pib GPSD tus kheej.running = Muaj tseeb #Pib khiav cov xov no def khiav (tus kheej): thoob ntiaj teb gpsd thaum gpsdThread.running: gpsd.next () yog _name_ == '_main_': gpsdThread = GPSDcollector (1) # tsim xov los sau cov ntaub ntawv sim: gpsdThread.start () # pib nws thaum muaj tseeb: luam tawm 'GPS', gpsd.utc, 'CPU time->', datetime.datetime.now ().time (), yog (gpsd.fix.longitude0) thiab (gpsd.fix.longitude'nan '): streamer.log ("Qhov chaw", "{lat}, {lon}". format (lat = gpsd.fix.latitude, lon = gpsd.fix.longitu de)) streamer.log ("speed", gpsd.fix.speed) print 'lat', gpsd.fix.latitude, print 'lon', gpsd.fix.longitude, print 'speed', gpsd.fix.speed pw tsaug zog (5) tshwj tsis yog (KeyboardInterrupt, SystemExit): # thaum koj nias ctrl+c print "\ nKilling Thread …" gpsdThread.running = Cuav gpsdThread.join () # tos rau xov kom tiav qhov nws ua luam "Ua tiav. / N."

Txuag thiab tawm ntawm cov ntawv nyeem kuv nyem CTRL + X, Y, nkag mus.

Pib tsab ntawv txiav rau khau raj

Yog tias koj tab tom saib xyuas tej thaj chaw deb, koj xav kom tsab ntawv khiav ntawm khau raj. Txhawm rau ua qhov no, peb yuav tsim tsab ntawv me uas yuav pib ua haujlwm tseem ceeb ntawm nab nab. Nkag mus rau cov lus txib hauv qab no:

$ nano GPStrackerStart.sh

Luam kab rau hauv kab ntawv editor:

#!/bin/tsoo

tsaug zog 15 python /home/pi/GPStracker.py &

Qhov kev ncua saum toj no nyob ntawd kom muab sijhawm Pi rau khau raj thiab txuas ntawm PPP.

Ua kom tsab ntawv ua tiav:

$ chmod +x ~/GPStrackerStart.sh

Peb yuav siv cron los pib tsab ntawv txhua lub sijhawm Pi khau raj:

$ crontab -e

Ntxiv kab hauv qab no mus rau hauv qab:

@reboot /home/pi/GPStrackerStart.sh &

Kauj Ruam 3: Qhov Chaw & Ceev Dashboard

Qhov Chaw & Ceev Dashboard
Qhov Chaw & Ceev Dashboard

Tam sim no koj muaj koj txoj haujlwm nce thiab khiav cov ntaub ntawv yuav tsum raug xa mus rau Lub Xeev Pib. Koj yuav muaj GPS cov ntaub ntawv thiab cov ntaub ntawv nrawm. Koj tuaj yeem siv GPS cov ntaub ntawv hauv daim duab qhia chaw Pobzeb los taug qab qhov chaw. Txog daim ntawv qhia Pobzeb, nco ntsoov txheeb xyuas Kab Kos kos lub thawv kom koj qhov chaw taug qab tau teeb tsa tawm zoo li lub dashboard saum toj no. Koj tuaj yeem tso koj cov ntaub ntawv nrawm hauv kab kab kom pom nrawm dua lub sijhawm.

Pom zoo: