Coder Social home page Coder Social logo

mcauser / raspberry-pi-itead-studio-gps-neo-6m Goto Github PK

View Code? Open in Web Editor NEW
22.0 10.0 9.0 116 KB

Experiments with my ITead Studio RPI GPS Add On

Home Page: http://imall.iteadstudio.com/development-platform/raspi/raspberry-pi-gps-add-on.html

raspberry-pi itead gpsd raspbian uart gps neo-6m

raspberry-pi-itead-studio-gps-neo-6m's Introduction

Raspberry Pi + ITead Studio GPS

(u-blok NEO-6M)

ITead Studio product page

Raspberry Pi + ITead Studio GPS

Materials

Raspberry Pi - Mobel B

ITead Studio Raspberry PI GPS Add-on

0.5m USB cable

USB Power Supply (5V 2.1 Amp)

SanDisk Ultra 16GB MicroSDHC Class 10 UHS-1 + Adapter 30MB/s (SDSDQUA-016G-U46A)

Or any compatible SDHC/SDXC card or MicroSDHC + adapter, with Class >= 10 for greater performance.

Setup

  1. Install Raspbian OS
  2. Prepare serial port
  3. Install apps
  4. Test

Install Raspbian OS

Download the latest Raspbian Wheezy image from raspberrypi.org (around 2.9GB)

Prepare your SD card.

Boot and run raspi-config, expand root fs, enable ssh, change root pass, set hostname, set timezone, set keyboard layout etc.

Prepare serial port

The Broadcom UART (or serial port) appears as /dev/ttyAMA0 under Linux.

By default the UART is enabled to allow you to connect a terminal window and login.

You need to disable this to free it up for the GPS Module for a serial connection.

Disable kernel logging

โš ๏ธ Be careful doing this, as a faulty command line can prevent the system booting.

Edit the boot options so the UART does not provide a terminal connection by default.

By default, upon boot sequence the entire boot procedure is output on the UART serial port, which might confuse your micro controller which doesn't expect all that gibberish.

eg. If you see a ton of messages like this appear, you are logging your kernel messages to the console.

Jun 06 23:53:30 mmmpie kernel: [  289.077967] SysRq : HELP : loglevel(0-9) reboot(b) crash(c) terminate-all-tasks(e) memory-full-oom-kill(f) debug(g) kill-all-tasks(i) thaw-filesystems(j) sak(k) show-memory-usage(m) nice-all-RT-tasks(n) poweroff(o) show-registers(p) show-all-timers(q) unraw(r) sync(s) show-task-states(t) unmount(u) show-blocked-tasks(w)

Take a backup:

$ sudo cp /boot/cmdline.txt ~/cmdline.txt.bak

Disable the kernel log output on /dev/ttyAMA0:

$ sudo nano /boot/cmdline.txt

Change:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

To:

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Make sure you do not add any line breaks - it must all stay on a single line.

(you are removing these two commands:)

console=ttyAMA0,115200
kgdboc=ttyAMA0,115200

The console keyword outputs messages during boot, and the kgdboc keyword enables kernel debugging.

ttyAMA0 is the device (/dev/ttyAMA0) and 115200 is the baud rate.

Disable spawn login on serial port

take a backup:

$ sudo cp /etc/inittab ~/inittab.bak

Edit inittab and comment out the line that spawns a login (getty):

$ sudo nano /etc/inittab

Near the end of the file...

Change:

#Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

To:

#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Reboot

$ sudo shutdown -r now

After rebooting for the new settings to take effect, you can use /dev/ttyAMA0 like any normal linux serial port, and you wont get any unwanted traffic confusing the attached devices.

To double check, your changes run:

$ cat /proc/cmdline

You should see the contents of your /boot/cmdline.txt at the end of the line.

Install Apps

Install gpsd

gpsd (acronym for Global Positioning System Daemon) is an open source project which provides a daemon which streams GPS data via a TCP socket, allowing you to communicate with a whole host of different GPS devices.

Install with dependencies:

$ sudo apt-get install gpsd gpsd-clients python-gps

Package gpsd gives you binaries:

  • gpsd - interface daemon for GPS receivers
  • gpsdctl - tool for sending commands to gpsd over its control socket

Package gpsd-clients gives you binaries:

  • cgps - client resembling xgps, but without the pictorial satellite display and able to run on a serial terminal or terminal emulator
  • gegps - This program collects fixes from gpsd and feeds them to a running instance of Google Earth for live location tracking
  • gpsctl - control the modes of a GPS
  • gpsdecode - decode RTCM or AIVDM streams into a readable format
  • gpsmon - real-time GPS packet monitor and control utility
  • gpspipe - tool to connect to gpsd and retrieve sentences
  • gpxlogger - This program collects fixes from gpsd and logs them to standard output in GPX, an XML profile for track logging
  • lcdgps - A client that passes gpsd data to lcdproc, turning your car computer into a very expensive and nearly feature-free GPS receiver
  • xgps - simple test client for gpsd with an X interface
  • xgpsspeed - speedometer that uses position information from the GPS

Package python-gps gives you binaries:

  • gpscat - dump the output from a GPS
  • gpsfake - test harness for gpsd, simulating a GPS
  • gpsprof - profile a GPS and gpsd, plotting latency information

Run gpsd

The gpsd service needs to be started, using the following command:

$ sudo service gpsd start

You can also run it directly:

$ sudo gpsd -F /var/run/gpsd.sock /dev/ttyAMA0

Once gpsd is running, you can telnet to port 2947. You should see a greeting line that's a JSON object describing GPSD's version.

Type ?WATCH={"enable":true,"json"}; to start raw and watcher modes.

You should see lines beginning with { that are JSON objects representing reports from your GPS; these are reports in GPSD protocol.

Test gpsd using cpgs

There is a simple GPS client which you can run to test everything is working:

$ cgps -s

It may take a few seconds for the data to come through.

This is what it looks like:

cgps

If all you get is timeouts, see below.

If you are cold-starting a brand new GPS, it may take 15-20 minutes after it gets a skyview for it to download an ephemeris and begin delivering fixes.

Troubleshooting

$ gpsd -h

usage: gpsd [-b] [-n] [-N] [-D n] [-F sockfile] [-G] [-P pidfile] [-S port] [-h] device...
  Options include: 
  -b		     	    = bluetooth-safe: open data sources read-only
  -n			    = don't wait for client connects to poll GPS
  -N			    = don't go into background
  -F sockfile		    = specify control socket location
  -G         		    = make gpsd listen on INADDR_ANY
  -P pidfile	      	    = set file to record process ID 
  -D integer (default 0)    = set debug level 
  -S integer (default 2947) = set port for daemon 
  -h		     	    = help message 
  -V			    = emit version and exit.
A device may be a local serial device for GPS input, or a URL of the form:
     {dgpsip|ntrip}://[user:passwd@]host[:port][/stream]
     gpsd://host[:port][/device][?protocol]
in which case it specifies an input source for GPSD, DGPS or ntrip data.

Check the baud rate

If cgps repeatedly times out, try running debug mode in the foreground:

$ sudo gpsd -b -N -D 3 -n -F /var/run/gpsd.sock /dev/ttyAMA0

This GPS's specifications lists the baud rate at 38400 and only starts working after gpsd attempts 4800, 9600, 19200 then finally 38400.

Set the baud rate of port /dev/ttyAMA0 to 38400:

$ sudo stty -F /dev/ttyAMA0 38400

(after reboot, baud rate returns to default 115200)

Don't wait for the GPS

Some GPS models require you to use the -n option, which instructs gpsd not to wait for client connection to poll the GPS. This GPS does not require it.

$ sudo gpsd -n -F /var/run/gpsd.sock /dev/ttyAMA0

Take ownership of the serial port

To access the serial power without having to become root, you will need to take ownership of the serial port. It is as easy as adding the group dialout to your login id. In this example user = pi. You may need to add the group to other users, such as www-data for your web server.

Check which groups the current user is in:

$ id | grep dialout

Add the pi user to the dialout group:

$ sudo usermod -a -G dialout pi

Check for other processes using the serial port

$ ps aux | grep ttyAMA0

Attempt to identify the device

$ gpsctl /dev/ttyAMA0

Dump raw output from device

gpscat is a simple program for logging and packetizing GPS data streams.

It takes input from a specified file or serial device (presumed to have a GPS attached) and reports to standard output. The program runs until end of input or it is interrupted by ^C or other means. It does not terminate on a bad backet; this is intentional.

$ gpscat -s 38400 /dev/ttyAMA0

Unexpected or out of date ephemeris

Part of the message broadcast by a GPS satellite is called the ephemeris. The broadcast ephemeris contains information about the approximate locations of the other GPS satellites in the constellation one might expect to see overhead at a particular place, date and time. Once received by your ground based GPS receiver, the ephemeris is used to hunt for the signals of other GPS satellites in the constellation expected overhead.

If your GPS receiver has not been switched on for a long time its ephemeris may be out of date. Likewise if your GPS receiver's current on-board ephemeris is related to a location in another part of the world, perhaps where it was constructed, tested or last used, then the expected constellation may be significantly different to what is overhead. This is why a brand new GPS can sometimes take up to 20 minutes before it starts giving a position, it's downloading the broadcast ephemeris. Usually the broadcast ephemeris will be automatically stored so the next time you switch on, unless you've gone half way round the world, the problem should not occur. If it does then there may be a problem with your GPS unit.

Documentation and specifics

ITead Studio GPS Expansion Board

Raspberry PI GPS Add-on is customised for Raspberry Pi interface based on u-blok NEO-6 GPS module. Through the serial port on Raspberry Pi, data returned from GPS module can be received, thus information such as the current location and time can be searched.

Model: IM131227001

GPS Add-on Data Sheet

GPS Add-on Schematic

u-blok NEO-6M GPS Module

The u-blok NEO-6 module series brings the high performance of the u-blox 6 position engine to the miniature NEO form factor. u-blox 6 has been designed with low power consumption and low costs in mind. Intelligent power management is a breakthrough for low-power applications.

Model: NEO-6M-0-001

NEO-6 Product Summary

NEO-6 Data Sheet

NEO-6 Hardware Integration Manual

u-blox 6 Receiver Description and Protocol Specification

Additional documentation and resources

raspberry-pi-itead-studio-gps-neo-6m's People

Contributors

mcauser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raspberry-pi-itead-studio-gps-neo-6m's Issues

Raspberrypi 3

I followed your instructions and got them to work with an older B+ model but it didnt work on the raspberrypi 3. There I had to use the following (the jq installation is optional; it's used to get json data from the GPS):

Wire up device
--------------

========== ================
**uBlox**  **Raspberry Pi**
GND	       GND         
TX	       RX (GPIO 15)
RX	       TX (GPIO 14)
VCC	       3V3
========== ================

Installation
------------

Install some packages::

   sudo apt-get install gpsd-clients ntpdate

Compile and install jq (if you want json gps data)::

  wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz
  tar xf jq-1.5.tar.gz
  cd jq-1.5
  ./configure
  make -j4
  sudo make install
  cd ..
  rm -rf jq*
  jq --version

Remove ``console=serial0,115200`` from ``/boot/cmdline.txt``.

Disable services::

  sudo systemctl stop [email protected]
  sudo systemctl disable [email protected]

Change ``/etc/default/gpsd`` and change the ``GPSD_OPTIONS`` setting to::

  GPSD_OPTIONS="/dev/serial0"

Make sure it's started during boot::

  sudo ln -s /lib/systemd/system/gpsd.service /etc/systemd/system/multi-user.target.wants/

Now reboot the device.

Test
----

Identify the device::

   gpsctl /dev/serial0

Output should be something like::

   /dev/serial0 identified as a u-blox 1.00 (59842) at 9600 baud.

Run gpsmon (Ctrl+c to exit)::

  gpsmon /dev/serial0

Show time packet. ``"mode": 1`` means the GPS sensor has not achieved satellite
lock yet::

  gpspipe -w -n 30 | grep -m 1 time | jq '.'

Show GPS packet::

  gpspipe -w -n 30 | grep -m 1 lat | jq '.'

Show device info::

  gpspipe -w -n 30 | grep -m 1 DEVICE | jq '.'

More in this thread: https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=51788

Working with Raspbian Jessie, Pi 3 v1.2

Working with Raspbian Jessie and a Pi 3, version 1.2 (printed on the mother board).

The core problem is that the GPS no longer attaches to ttyAMA0. With the introduction of Bluetooth, it got conflated with the serial port for performance reasons - this may be temporary on new versions. In any case, after installing Jessie, so apt-get update and the GPS should be available on ttyS0. The performance of ttyS0 is slighly less than AMA0, but since it actually works, it's probably a good thing. Still working out all the places, but wanted to record this for now.

Reference - http://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/

pps

To enable the GPS as a pps source. Do the following.

add "dtoverlay=pps-gpio,gpiopin=25" to a new line in /boot/config.txt

add "pps-gpio" to a new line in /etc/modules

install pps tools:

sudo apt-get install pps-tools

reboot

run ppstest /dev/pps0

your output should look like this:

$ sudo ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1427275430.004698032, sequence: 613 - clear 0.000000000, sequence: 0
source 0 - assert 1427275431.004698969, sequence: 614 - clear 0.000000000, sequence: 0
source 0 - assert 1427275432.004700114, sequence: 615 - clear 0.000000000, sequence: 0
source 0 - assert 1427275433.004703447, sequence: 616 - clear 0.000000000, sequence: 0
source 0 - assert 1427275434.004705218, sequence: 617 - clear 0.000000000, sequence: 0
source 0 - assert 1427275435.004708186, sequence: 618 - clear 0.000000000, sequence: 0
source 0 - assert 1427275436.004709644, sequence: 619 - clear 0.000000000, sequence: 0
^C

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.