Hardware Reference
In-Depth Information
Solution
The Bone has several serial ports (UARTs) that you can use to read data from an external
microcontroller included in smart sensors, such as a GPS. Just wire one up, and you'll soon
be gathering useful data, such as your own location.
Here's what you'll need:
▪ Breadboard and jumper wires (see “Prototyping Equipment” )
▪ GPS receiver (see “Miscellaneous” )
Wire your GPS, as shown in Figure 2-16 .
Figure 2-16. Wiring a GPS to UART 4
The GPS will produce raw National Marine Electronics Association (NMEA) data that's
easy for a computer to read, but not for a human. There are many utilities to help convert
such sensor data into a human-readable form. For this GPS, run the following command to
load a NMEA parser:
bone# npm install -g nmea
Running the code in Example 2-10 will print the current location every time the GPS out-
puts it.
Example 2-10. Talking to a GPS with UART 4 (GPS.js)
#!/usr/bin/env node
// Install with: npm install nmea
Search WWH ::




Custom Search