Cov txheej txheem:

Interfacing GPS Module Nrog Raspberry Pi: 10 Kauj Ruam
Interfacing GPS Module Nrog Raspberry Pi: 10 Kauj Ruam

Video: Interfacing GPS Module Nrog Raspberry Pi: 10 Kauj Ruam

Video: Interfacing GPS Module Nrog Raspberry Pi: 10 Kauj Ruam
Video: GPS Module with Arduino- Ublox NEO-6M 2024, Kaum ib hlis
Anonim
Interfacing GPS Module Nrog Raspberry Pi
Interfacing GPS Module Nrog Raspberry Pi

Hlo Guys !! Puas yog koj xav cuam tshuam nrog GPS module nrog Raspberry Pi? Tab sis ntsib qee qhov nyuaj los ua nws? Tsis txhob txhawj, Kuv nyob ntawm no los pab koj! Koj tuaj yeem pib los ntawm kev siv cov hauv qab no:

Khoom siv

  1. Raspberry Pi 4 Qauv-B nrog 4 GB RAM
  2. UBlox NEO-M8N GPS Module
  3. Ib lub Computer

Kauj Ruam 1: Txuas Raspberry Pi Nrog PC

Txuas Raspberry Pi Nrog PC
Txuas Raspberry Pi Nrog PC

Ua ntej tshaj plaws, txuas koj li Raspberry Pi Board nrog lub PC. Koj tuaj yeem mus ntsib https://www.raspberrypi.org/blog/getting-started-raspberry-pi/ rau cov ntaub ntawv hais txog kev teeb tsa Raspberry Pi Imager.

Kauj Ruam 2: Cov Lus Qhia Luv. Txog UBlox NEO-M8N GPS Module

Cov lus qhia luv luv. Txog UBlox NEO-M8N GPS Module
Cov lus qhia luv luv. Txog UBlox NEO-M8N GPS Module

Nov yog UBlox NEO-M8N GPS Module nrog Ceramic Active Antenna. Qhov GPS Module no muaj 72-channel Ublox M8 cav hauv tus txais. Tus qauv muaj 4 tus pin: VCC (Muab Voltage), GND (Hauv av), Tx (Transmitter), thiab Rx (Txais).

Cov qauv no muab cov NMEA tsis tu ncua (National Marine Electronics Association) cov ntaub ntawv cov hlua rau TX tus pin ua rau GPS cov ntaub ntawv. Txhawm rau paub ntau ntxiv txog tus qauv no, koj tuaj yeem rub nws cov ntaub ntawv ntawm no.

Kauj Ruam 3: Interface GPS Module Nrog Raspberry Pi

Interface GPS Module Nrog Raspberry Pi
Interface GPS Module Nrog Raspberry Pi

Rau kev cuam tshuam, ua cov kev sib txuas raws li hauv qab no:

  1. Txuas Vcc ntawm GPS module rau Lub Hwj Huam Muab Tus Pin 2 (5V) ntawm Raspberry Pi.
  2. Txuas Tx (Tus Pin Txuas) ntawm GPS module rau Pin No.10 ntawm Raspberry Pi.
  3. Txuas GND (Ground Pin) ntawm GPS module rau Pin No.6 Raspberry Pi.

Koj tseem tuaj yeem xaiv lwm tus Raspberry Pi cov laug cam, tab sis nco ntsoov txheeb xyuas tus lej tus lej tsim nyog thaum ua kev sib txuas.

Kauj Ruam 4: Teeb UART hauv Raspberry Pi

Teeb UART hauv Raspberry Pi
Teeb UART hauv Raspberry Pi

Thawj qhov peb yuav ua hauv qab no yog kho cov ntaub ntawv /boot/config.txt. Txhawm rau ua qhov no, khiav cov lus txib hauv qab no:

sudo nano /boot /config.txt

Hauv qab ntawm kab ntawv config.txt, ntxiv cov kab hauv qab no

dtparam = spi = rau

dtoverlay = pi3-disable-bt

core_freq = 250

enable_uart = 1

zog_turbo = 1

ctrl+x kom tawm thiab nias y thiab nkag mus rau txuag.

Kauj ruam thib ob hauv ntu UART teeb tsa ntu no yog kho cov khau raj/cmdline.txt

Kuv yuav qhia koj ua daim ntawv theej ntawm cmdline.txt thiab txuag ua ntej ua ntej kho kom koj tuaj yeem rov qab mus rau nws tom qab yog xav tau. Qhov no tuaj yeem ua tiav siv;

sudo cp khau raj/cmdline.txt khau raj/cmdline_backup.txtsudo nano /boot.cmdline.txt

Hloov cov ntsiab lus nrog;

dwc_otg.lpm_enable = 0 console = tty1 root =/dev/mmcblk0p2 rootfstype = ext4 of elevator = hnub kawg fsck.repair = yog rootwait ntsiag to txaws plymouth.ignore-serial-consoles

Nias ctrl+x kom tawm thiab nias y thiab nkag mus rau txuag.

Tam sim no reboot pi kom pom cov kev hloov pauv

Kauj Ruam 5: Lov tes taw Raspberry Pi Serial Getty Service

a Yog tias hauv koj cov ntawv tso tawm, Serial0 txuas nrog ttyAMA0, tom qab ntawd kom nws tsis siv nws siv cov lus txib hauv qab no,

sudo systemctl nres [email protected] systemctl kaw [email protected]

b. Yog tias hauv koj cov ntawv tso tawm Serial0 txuas nrog ttys0, tom qab ntawd kom nws tsis siv nws siv cov lus txib hauv qab no,

sudo systemctl nres [email protected] systemctl kaw [email protected]

Kauj Ruam 6: Qhib Ttys0

Txhawm rau kom ttyso siv cov lus txib hauv qab no,

sudo systemctl pab [email protected]

Kauj Ruam 7: Nruab Minicom thiab Pynmea2

Siv minicom python lub tsev qiv ntawv los txuas nrog GPS module thiab ua kom paub cov ntaub ntawv.

sudo apt-tau nruab minicom

Siv lub tsev qiv ntawv pynmea2 nab los txhawm rau txheeb xyuas cov ntaub ntawv NMEA tau txais.

sudo pip nruab pynmea2

Kauj Ruam 8: Kev Ntsuas Tawm

Kev Ntsuas Tawm
Kev Ntsuas Tawm

Txhawm rau sim GPS khiav cov lus txib sudo cat /dev /ttyAMA0, Koj yuav tau txais cov txiaj ntsig raws li qhia saum toj no.

Kauj Ruam 9: Sau Python Code

Tam sim no, sau tus nab npawb nab npawb rau kev cuam tshuam ntawm GPS module nrog Raspberry pi

ntshuam ntshuam

Ntshuam sij hawm

ntshuam hlua ntshuam ntshuam pynmea2

thaum muaj tseeb: chaw nres nkoj = "/dev/ttyAMAO"

ser = serial. Serial (chaw nres nkoj, baudrate = 9600, sijhawm tas = 0.5)

dataout = pynmea2. NMEAStreamReader ()

newdata = ser.readline ()

yog newdata [0: 6] == "$ GPRMC":

newmsg = pynmea2.parse (cov ntaub ntawv tshiab)

lat = newmsg.latitude

lng = newmsg.longitude

gps = "Latitude =" +str (lat) +"thiab Longitude =" +str (lng)

luam tawm (gps)

Kauj Ruam 10: Zaum Kawg

Zaum Kawg
Zaum Kawg

Lub qhov rais pom saum toj no yog qhov tso tawm zaum kawg. Nws muab cov ntaub ntawv ntawm koj txoj haujlwm tseeb raws li Latitude thiab Longitude.

Txoj haujlwm no yog ua raws kab lus GPS Module nrog Arduino thiab Raspberry Pi - Los ntawm Priyanka Dixit. Mus ntsib kab lus no kom paub ntau ntxiv txog GPS, nws ua haujlwm li cas, piav qhia cov ntsiab lus tseem ceeb ntev & latitude, qhov sib txawv ntawm GPS nti & GPS module, thiab ntau ntxiv!

Pom zoo: