Cov txheej txheem:

Raspberry Pi, Android, IoT, thiab Bluetooth Powered Drone: 7 Kauj Ruam (nrog Duab)
Raspberry Pi, Android, IoT, thiab Bluetooth Powered Drone: 7 Kauj Ruam (nrog Duab)

Video: Raspberry Pi, Android, IoT, thiab Bluetooth Powered Drone: 7 Kauj Ruam (nrog Duab)

Video: Raspberry Pi, Android, IoT, thiab Bluetooth Powered Drone: 7 Kauj Ruam (nrog Duab)
Video: 10 самых АТМОСФЕРНЫХ мест Дагестана. БОЛЬШОЙ ВЫПУСК #Дагестан #ПутешествиеПоДагестану 2024, Hlis ntuj nqeg
Anonim
Raspberry Pi, Android, IoT, thiab Bluetooth Powered Drone
Raspberry Pi, Android, IoT, thiab Bluetooth Powered Drone
Raspberry Pi, Android, IoT, thiab Bluetooth Powered Drone
Raspberry Pi, Android, IoT, thiab Bluetooth Powered Drone
Raspberry Pi, Android, IoT, thiab Bluetooth Powered Drone
Raspberry Pi, Android, IoT, thiab Bluetooth Powered Drone
Raspberry Pi, Android, IoT, thiab Bluetooth Powered Drone
Raspberry Pi, Android, IoT, thiab Bluetooth Powered Drone

Siv Raspberry Pi rau lub logic on-board logic, lub khoos phis tawj, lub khoos phis tawj mobile, yuav tsim lub chaw nres nkoj hauv zos uas tso cov vis dis aus nyob rau lub sijhawm tiag tiag thaum ib txhij tsim Bluetooth nyob rau hauv kom nyeem qhov tseem ceeb xa los ntawm kev cai hauv app. Lub app sib txuas nrog lub drone thiab siv cov neeg siv nkag los xa cov lus qhia rau lub drone tam sim.

Qhov haujlwm no nyuaj ua los ntawm kos. Vam tias, cov ntaub ntawv hauv qab no yuav muab kev nkag siab rau ntau daim ntawv thov drone. Txhua qhov software thiab kev tsim vaj tsev hais txog qhov haujlwm no tau muab. Xav tias dawb los hloov kho thiab qhia cov cai rau koj nyiam. Thov siv cov ntaub ntawv muab lub luag haujlwm thiab xav tawm hauv cov lus hauv qab no.

Kauj ruam 1: Kho vajtse

Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse

Hauv qab no yog cov npe khoom kho vajtse uas kuv tau siv.

  • Raspberry Pi 3 Qauv B.
  • Raspberry PI Lub Koob Yees Duab Module
  • L298N Tsav Tsav Tsheb
  • 2, DC Tsav
  • Cov Keyboard, Txhua Tus Saib Xyuas, Nas, Ethernet Cable, thiab HDMI Cable (rau pi)
  • 8GB MicroSD daim npav
  • Screws, Daim kab xev, thiab lwm yam.
  • 2 Log
  • Android Bluetooth Device (Kuv lub xov tooj)
  • 2,18650 Xovtooj
  • Ib qho 5 Volt Regulator
  • Lub khoos phis tawj los teeb tsa lub app

Raspberry Pi: Rau qhov kev daws teeb meem siab dua (lossis rau cov pib), Kuv xav pom qhov tshiab tshaj plaws ntawm tus qauv B thaum ntau qhov kev cog lus me me tuaj yeem siv tus qauv tshiab A+ lossis Pi Zero (Lub Koob Yees Duab). Nco ntsoov tias yog tias koj siv raspberry pi xoom, koj yuav xav tau Bluetooth thiab/lossis WiFi dongle rau nws. Cov ntawv qhia no yuav xav tias koj siv Raspberry Pi 3 B.

Tus Tsav Tsheb: Kuv siv L298N, txawm hais tias txhua tus tsav tsheb yuav tsum ua haujlwm. Tsuas yog xyuas kom nws tuaj yeem tswj hwm koj cov motors voltage thiab tam sim no.

2 DC Motors: Xyuas kom lawv muaj peev xwm tswj tau qhov hnyav ntawm koj lub drone.

Lub cev: Siv dhau los tuav tag nrho cov khoom siv hauv. Feem ntau nyuaj yas lossis txhuas yog cov khoom siv ruaj khov, lub teeb yuag siv. Rau qhov pom tau zoo, txawm tias siv 3D Tshuab Luam Ntawv.

Lub Hwj Chim Source: Nws yuav luag ib txwm yog qhov kev txiav txim siab nyuaj tshaj plaws thaum xaiv cov khoom. Lub roj teeb xav tau yog nyob ntawm kev kos tam sim no. Rau cov ntawv thov tsis muaj zog (zoo li 1 lossis 2 amps), lub roj teeb 9v yuav tsum txaus. Rau siab dua amperage, Kuv pom zoo 18650 Lithium Ion cell lossis Lithium Polymer roj teeb vim tias lawv yog lub teeb yuag, tuaj yeem tuav lub zog ntau rau lawv qhov loj me, thiab tuaj yeem them rov qab tau.

2 Log: Tsuas yog xyuas kom tseeb tias koj lub Log yog muaj qhov loj ib yam li lub taub hau ntawm koj lub cav. Kuj xyuas kom meej tias txoj kab uas hla ntawm Cov Log loj txaus rau koj lub drone. Txij li thaum lawv muaj ntau yam kev hloov pauv thiab tsim qauv rau txoj haujlwm no, lawv yog ntau yam sib txawv log thiab ntau qhov sib txawv los siv.

Cov tswj hluav taws xob: Tus tswj hwm 5 volt xav tau los ua kom muaj zog pi ntawm lub roj teeb. Kuv siv LM2596 DC-DC phaw hloov pauv.

Feem ntau ntawm cov khoom lag luam hauv qhov txuas tau siv hauv txoj haujlwm no thiab yog qhov zoo tshaj plaws uas kuv tuaj yeem pom thaum lub sijhawm.

Tam sim no koj muaj txhua yam koj xav tau, cia teeb lub pi.

Kauj Ruam 2: Teeb Kho Raspberry Pi

Teeb tsa Raspberry Pi
Teeb tsa Raspberry Pi
Teeb tsa Raspberry Pi
Teeb tsa Raspberry Pi
Teeb tsa Raspberry Pi
Teeb tsa Raspberry Pi

Cov kauj ruam no yuav qhia koj yuav teeb tsa Raspberry Pi yog li koj tuaj yeem pib coding. Yog tias koj twb muaj pi teeb tsa nrog Raspbian, dua li xav tias dawb mus rau kauj ruam tom ntej.

Ua ntej, koj yuav tsum rub tawm lub operating system rau raspberry. Tau NOOBS yog tias koj yog tus pib. Yog tias koj twb muaj qhov kev paub dhau los nrog raspberry pi, yog li koj yuav nyiam Raspbian. Kuv yuav xav tias koj siv NOOBS rau qhov kev qhia no.

Thaum qhov ntawd rub tawm, Format koj daim npav SD nrog SD Formatter.

Tam sim no Extract thiab luam cov ntsiab lus ntawm rub tawm rau hauv paus ntawm koj daim npav SD. Hauv paus yooj yim txhais tau tias nws tsis nyob hauv ib qho ntawv tais ceev tseg. Yog tias daim nplaub tshev tshiab tau tsim los tuav tag nrho cov ntaub ntawv rho tawm, theej hla cov ntawv ntawd.

Tom ntej txuas daim npav SD rau tus pi. Thaum nkag mus, nws yuav tsum yog "nyem" hauv lossis tsuas yog zaum sab hauv qab ntawm pi.

Txuas koj tus nas thiab keyboard rau hauv pi. Tom qab ntawd ntsaws rau hauv HDMI cable rau tus pi los ntawm tus saib. Thaum kawg ntsaws rau hauv 3 amp micro USB phab ntsa ntsaws adapter rau hauv pi. Txawm hais tias lub qhov (socket) tau pom zoo, Kuv siv kuv lub laptop ua lub zog siv (USB los ntawm kuv lub laptop mus rau Micro USB hauv pi).

Cia tus pi ua nws qhov. Yog hais kom sai, xaiv Raspbian thiab cia nws nruab. Ua raws li cov lus qhia hauv lub installer. Nws yuav siv sijhawm me ntsis los ua kom tiav. Yog tias txhua yam mus zoo, koj yuav tsum pom lub vijtsam duab zoo ib yam li ib qho saum toj no.

Txuas rau hauv Ethernet cable los ntawm koj lub router rau hauv pi. Tom qab ntawd qhib kab hais kom ua (Lub cim dub "lub thawv" nyob rau sab saum toj ntawm lub vijtsam). Koj yuav tsum tau hloov kho pi los ntawm kev sib txuas hauv lub network kom txuas nws mus rau lub wireless network.

Tom qab ntawd nyem rau ntawm lub cim Cable nyob rau sab saum toj ntawm lub vijtsam. Ntaus hauv koj lub network cov ntsiab lus qhov chaw hais kom sai.

Ntaus cov ntawv hauv kab tom ntej raws nraim li qhia thiab ntaus nkag. Qhov no yuav hloov kho pi. Nws yuav siv sijhawm me ntsis. Tsuas yog cia nws ua nws qhov.

sudo apt-tau hloov tshiab

Tom qab ntawd ntaus tus lej hauv kab tom ntej. Qhov no tseem yuav siv qee lub sijhawm. Tsis txhob ua dab tsi kom txog thaum nws ua tiav.

sudo apt-tau nruab dist-upgrade

Tam sim no koj yuav tsum tuaj yeem txuas lub Ethernet cable, nyem rau ntawm lub cim wireless nyob rau sab saum toj ntawm lub vijtsam, nkag mus rau koj cov ntaub ntawv network, thiab thaum kawg txuas rau koj lub network ntawm wireless.

Tam sim no cia cov cai ib feem ntawm drone uas ua haujlwm txav mus los.

Kauj Ruam 3: Kev Tawm Tsam (Bluetooth Server)

Kev Tawm Tsam (Bluetooth Server)
Kev Tawm Tsam (Bluetooth Server)

Txog kev txav txav, siv hom lus "Python 3". Cov lus uas qhia rau tus neeg hlau txav mus yuav raug xa los ntawm Bluetooth los ntawm app.

Ua ntej, koj yuav tsum teeb tsa lub tsev qiv ntawv Bluetooth. Ntaus cov lus txib hauv qab no kom ua tau.

sudo apt-tau hloov tshiab

sudo apt-tau nruab bluetooth

sudo apt-tau nruab bluez

sudo apt-tau nruab python-bluez

Tam sim no los ntawm lub desktop, nyem rau ntawm lub cim pib lub tshuab raj, tom qab ntawd Programming, tom qab ntawd Python 3. Tom qab ntawd los ntawm lub cuab yeej, nyem File, tshiab. Lub qhov rai tshiab yuav tsum tshwm sim.

Luam cov ntsiab lus ntawm qhov txuas "bluetoothpi.rtf" rau hauv lub qhov rais.

Ntawm qhov toolbar, nyem rau ntawm File, Save as. Txuag nws hauv/home/pi/Desktop/directory raws li movements.py.

Tam sim no los ntsuas tus lej, nyem rau ntawm lub cim Bluetooth ntawm lub kaum sab xis saum toj ntawm lub vijtsam. Pair raspberry pi nrog koj lub cuab yeej hauv. Rub tawm ib qho app hu ua BlueTerm ntawm koj lub Android ntaus ntawv. Tom qab ntawd hauv kab hais kom ua, ntaus tus lej hauv qab no hauv qhov loj. Qhov no yuav ua tus lej nab npawb.

sudo nab hab sej /home/pi/Desktop/movements.py

Cov ntawv "Tos rau kev sib txuas" yuav tsum tshwm ntawm tus pi.

Pib BlueTerm thiab nyem rau ntawm lub cim kev xaiv thiab tom qab ntawd "saib rau kev sib txuas" khawm.

Hauv app, koj lub npe raspberry pi yuav tsum tshwm. Nyem rau ntawm lub pob nrog tus pi lub npe. Cov ntawv "Txais kev sib txuas los ntawm" yuav tsum tshwm ntawm tus pi ua raws nws qhov chaw nyob. Tam sim no xijpeem koj ntaus hauv xov tooj, yuav tsum tau tshwm nyob rau hauv pi.

Koj tau ua tiav tus lej ntawm koj tus kheej lub server rau Bluetooth!

Kauj ruam 4: Android App (Bluetooth Client)

Lub Android App (Bluetooth Client)
Lub Android App (Bluetooth Client)
Lub Android App (Bluetooth Client)
Lub Android App (Bluetooth Client)
Lub Android App (Bluetooth Client)
Lub Android App (Bluetooth Client)
Lub Android App (Bluetooth Client)
Lub Android App (Bluetooth Client)

Rub tawm Android Studio ntawm no. Nruab nws thiab ua raws cov lus qhia muab rau hauv lub installer.

Pib ib txoj haujlwm tshiab. Tsim cov haujlwm tsis muaj npe hu ua MainActivity.

Luam cov ntsiab lus ntawm cov ntawv txuas "Logic.txt" hauv "MainActivity.java" cov ntaub ntawv (tab). Qhov no muaj tag nrho cov laj thawj tom qab lub app. Koj yuav xav hloov lub npe ntawm koj lub cuab yeej hauv qab ntawm cov ntawv.

Tom qab ntawd luam cov ntsiab lus ntawm cov ntawv "GUI" hauv "activity_main.xml" cov ntaub ntawv (tab). Qhov no suav nrog GUI yooj yim heev rau lub app.

Tam sim no koj yuav tsum tau ntsaws cov xub khawm (duab) rau hauv app. Unzip qhov txuas txuas Arrows.zip. Nyob rau sab laug ntawm android studio, qhib cov qauv ntaub ntawv kom pom app, res, minimap. Luam cov duab xub (cov ntawv PNG), nyem rau ntawm daim ntawv minimap thiab muab cov duab tso rau hauv cov ntawv, khaws cov npe ntawm cov xub zoo ib yam. Nws yuav tsum zoo li daim duab thaum ua tiav.

Thaum kawg theej cov ntsiab lus ntawm cov ntawv "Manifest" rau koj li "AndroidManifest.xml" file (tab).

Txhawm rau sim lub app, koj yuav tsum tau khiav nws ntawm koj lub cuab yeej. Txhawm rau ua qhov no, koj yuav tsum teeb tsa lub cuab yeej rau hom tsim tawm thiab pab kom USB debugging. Rau feem ntau cov cuab yeej, koj yuav tsum mus rau "Chaw", "Hais Txog Xov Tooj", nqes mus rau hauv qab thiab nyem rau "Tsim Tus lej" xya zaus kom txog thaum koj pom cov lus "Koj tam sim no yog tus tsim tawm!" Rov qab mus thiab tam sim no koj yuav tsum pom lub tab "Tus tsim tawm kev xaiv". Nyem rau nws thiab pab kom USB debugging.

Txuas koj lub cuab yeej Android rau koj lub khoos phis tawj ntawm USB, nyem rau ntawm lub cim khiav ntawm Android Studio, thiab xaiv koj lub cuab yeej.

Ntawm tus pi, pib tus nab npawb nab npawb tsim nyob rau theem 3 los ntawm kev ntaus hauv qhov hais kom ua bold:

sudo python /home/pi/Desktop/movements.py

Tom qab ntawv nyem rau khawm txuas hauv app. Thaum txuas nrog, qee cov xub yuav tsum tam sim no tshwm ntawm lub app. Thaum twg koj nyem rau ntawm ib qho, nws yuav hloov kho tus pi "txav" lub xeev.

Nws zoo yog tias keeb kwm yav dhau ntawm lub app muab qhov yuam kev. Qhov no yuav raug kho tom qab.

Koj nyuam qhuav tsim koj tus kheej app thiab Bluetooth Client.

Kauj Ruam 5: Txuas Cov Khoom Kho Vajtse

Txuas Kev Kho Vajtse
Txuas Kev Kho Vajtse
Txuas Kev Kho Vajtse
Txuas Kev Kho Vajtse
Txuas Kev Kho Vajtse
Txuas Kev Kho Vajtse

Luag cov kev sib txuas hauv daim duab saum toj no. Txuas lub koob yees duab module rau pi ib yam.

Khiav lub app thiab ua qhov txav mus los.py cov ntaub ntawv. Yog tias lub tshuab txav mus los kom raug thaum siv lub app, xav tias tso tag nrho cov khoom siv rau hauv lub plhaub kawg rau lub drone. Koj yuav xav hloov kho cov lej "HIGH" thiab "LOW" qhov tseem ceeb kom nws txav mus kom raug.

Hauv cov kauj ruam tom ntej, peb yuav ntxiv cov kev tshaj tawm ntawm lub drone.

Kauj ruam 6: Tshaj tawm

Tshaj tawm
Tshaj tawm
Tshaj tawm
Tshaj tawm
Tshaj tawm
Tshaj tawm

Lawv yog ntau txoj hauv kev los tso cov vis dis aus siv Pi, tab sis siv uv4l yog qhov yooj yim tshaj plaws uas tsis muaj kev lag luam.

Tsuas yog sab saud, yog tias koj twb tau tso koj lub drone ua ke thiab tsis tuaj yeem txuas nws mus rau koj lub monitor thiab keyboard, koj yuav xav tau SSH rau hauv koj lub drone. Txhawm rau ua qhov no, rub tawm Putty ntawm koj lub computer. Qhib nws thiab ntaus koj tus IP chaw nyob raspberry (nrhiav tus IP los ntawm kev ntaus cov lus txib ifconfig). Nws yuav hais kom koj nkag mus rau tus username thiab password. Lub npe siv tsis raug thiab tus password yog pi thiab raspberry feem. Tam sim no xijpeem koj ntaus hauv lub thawv hais kom ua yuav zoo li nkag mus rau cov lus txib ncaj qha rau hauv lub drone.

ua uv4l

Ntaus hauv cov lus txib no:

sudo nano /etc/apt/sources.list

Ntxiv kab ntawv hauv qab no hauv kab kawg ntawm cov ntawv.

deb https://www.linux-projects.org/listing/uv4l_repo/raspbian/ jessie main

Tawm thiab txuag cov ntaub ntawv los ntawm nias Ctrl-X thiab tom qab ntawv Yog yog.

Tom qab ntawv ntaus kab hauv qab no thiab nias nkag mus.

sudo apt-tau hloov tshiab

ces qhov no:

sudo apt-tau nruab uv4l uv4l-raspicam

Ntaus cov kab lus hauv qab no los ntawm kab. Tos kom nws ua tiav nws tau ua dab tsi ua ntej ntaus hauv kab tom ntej.

sudo apt-tau nruab uv4l-raspicam-ntxiv

sudo kev pabcuam uv4l_raspicam rov pib dua

sudo rpi-hloov tshiab

sudo apt-tau nruab uv4l-server uv4l-uvc uv4l-xscreen uv4l-mjpegstream uv4l-dummy uv4l-raspidisp

sudo apt-tau nruab uv4l-webrtc

sudo apt-tau nruab uv4l-xmpp-choj

sudo apt-tau nruab uv4l-raspidisp-extras

Tom qab ntawd, txhua yam koj yuav tsum ua yog ntaus hauv cov lus txib hauv qab no kom pib ntws (hloov "raspberrypi" nrog raspberry's IP chaw nyob/ Tus tswv lub npe hauv koj lub network)

cvlc https:// raspberrypi: 8080/stream/video.mjpeg

Qhov no yuav pib tshaj tawm cov vis dis aus hauv lub sijhawm tiag tiag ntawm chaw nres nkoj 8080. Cov kwj dej yuav tsum pom tom qab ntawm koj li app tam sim no. Txhawm rau saib cov kwj hauv txhua qhov browser, ntaus hauv qhov URL no (qhov twg "raspberrypi" yog koj tus drones IP chaw nyob).

https:// raspberrypi: 8080/stream/video.mjpeg

Nrog koj zoo siab, koj tau ua tiav koj cov neeg soj xyuas drone.

Kauj ruam 7: Tsav

Tig lub hwj chim hloov thiab pib tshawb nrhiav.

Yog tias koj xav paub yuav ua dab tsi ntxiv, nug kuv thiab kuv yuav pom tias kuv tuaj yeem ua dab tsi.

Yog tias koj muaj lus nug, thov tawm tswv yim hauv qab no thiab kuv yuav ua qhov zoo tshaj los teb lawv.

Ua tsaug rau kev nyeem ntawv!

Pom zoo: