Introducing the Raspberry Pi So you’ve got yourself a Raspberry Pi mini computer. Now what? Perhaps you’re familiar with the Pi and its architecture, but you’re wondering what to do with it. Perhaps you have some experience with computers but aren’t familiar with Linux or Raspbian, the Pi’s default operating system. Perhaps you’re already a Linux geek, but you don’t know how to program in Python and thought it would be a good time to learn. Perhaps you have absolutely no experience with computers beyond clicking the Start button, checking your email, and surfing the web, but you heard about this “Raspberry Pie” thingamabob and decided to see what all the ruckus was about.34153
Connecting the GPS Receiver to the Pi
To get your Pi to talk to the GPS receiver, you first need to connect the two. To do this, we’ll use the Python library
called gpsd, and the Pi’s UART (Universal Asynchronous Receiver/Transmitter) interface (pins 7 and 8). The Python
gpsd module is part of a larger library of code designed to allow devices such as the Pi to monitor attached GPS
and AIS receivers, with ports to C, C++, Java, and Python. It allows you to “read” the National Marine Electronics
Association (NMEA)–formatted data transmitted by most GPS receivers.
The UART interface is an old one. It’s basically a serial (RS-232) connection, but for our purposes it’s all we need.
It consists of a positive (+) and negative (-) connection for power, and transmit and receive pins. Start by typing the
following line to install the software we’ll need to read the GPS, gpsd and its associated programs:
sudo apt-get install gpsd gpsd-clients python-gps
Next we need to configure the Pi’s UART interface. By default, it’s set up to connect to a terminal window, but we
need to communicate with the Tx and Rx (transmit and receive) pins. To do that, first make a copy of /boot/cmdline.txt
by typing
sudo cp /boot/cmdline.txt /boot/cmdlinecopy.txt
and then edit it by typing sudo nano /boot/cmdline.txt. Delete the following portion
console=ttyAMA0,115200 kgdboc=ttyAMA0,115200
so that the file reads
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
Save the file, and then edit the inittab file by typing
sudo nano /etc/inittab
Comment out the following line (the very last line), which tells the Pi to start a terminal connection, by adding a
hashtag to the beginning of the line:
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Now reboot by typing sudo shutdown –r now.
When you’re back up and running, connect the GPS receiver to the Pi like so:
1. Connect the receiver’s VIN to the Pi’s 5V (pin #2).
2. Connect the GND to Pi pin #6.
3. Connect the Tx to Pi Rx (pin #10).
4. Connect the Rx to Pi Tx (pin #8).
When the receiver’s LED starts to blink, you know you have power. Now you can test it by starting the gpsd
program by typing
sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock
Then start the generic GPS client by typing
cgps -s
The cgps client is a generic viewer; it simply takes the data the gpsd program is receiving and displays it to
the user.
It may take a moment for data to begin to stream, but when it does, you should see a screen like the one in
Figure 10-2.
If you see nothing but zeros, it means the GPS can’t find a satellite fix. You may have to wait a few minutes or
even give the GPS a clear view of the sky. My experience is that this particular GPS board, even without the optional
antenna, is very sensitive. When I added the antenna, I had no problem getting a GPS signal, even in my house.
Once you know that the GPS unit is working and communicating with the Pi, we need to put that information into
- 上一篇:AA2024-T3可成形性金属板英文文献和中文翻译
- 下一篇:同时定位和地图构建英文文献和中文翻译
-
-
-
-
-
-
-
高警觉工作人群的元情绪...
现代简约美式风格在室内家装中的运用
上市公司股权结构对经营绩效的影响研究
NFC协议物理层的软件实现+文献综述
g-C3N4光催化剂的制备和光催化性能研究
江苏省某高中学生体质现状的调查研究
中国传统元素在游戏角色...
浅析中国古代宗法制度
C++最短路径算法研究和程序设计
巴金《激流三部曲》高觉新的悲剧命运