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可成形性金属板英文文献和中文翻译
- 下一篇:同时定位和地图构建英文文献和中文翻译
-
-
-
-
-
-
-
中考体育项目与体育教学合理结合的研究
酸性水汽提装置总汽提塔设计+CAD图纸
大众媒体对公共政策制定的影响
乳业同业并购式全产业链...
电站锅炉暖风器设计任务书
当代大学生慈善意识研究+文献综述
杂拟谷盗体内共生菌沃尔...
十二层带中心支撑钢结构...
java+mysql车辆管理系统的设计+源代码
河岸冲刷和泥沙淤积的监测国内外研究现状