Ada Fruit GPS Ultimate Breakout Board for PineA64
#1
I have been testing the Ada Fruit GPS Ultimate Breakout Board with my PineA64, and have found it to be a very handy device for local GPS, and truly the ultimate breakout board for GPS gurus.

   

The breakout board is in the mid-ground of the pic above. I have the board connected to uart4 (ttyS4) on the PineA64 board, where I am reading and parsing the NMEA sentences from the GPS receiver using Python (codes submitted and explained below). The pinouts for the euler bus may be found here. I use a four color ribbon from the gps module (red 3v3 Vcc, green Tx, white Rx, black Grnd). The red wire plugs into euler bus pin(17) 3v3, the green wire plugs into pin(21), the whire wire plugs into pin(19), and the black wire plugs into pin(25). It is important to note that the Tx line of the module (green) plugs into the Rx pin on  the euler bus; the Rx line of the module (white) plugs into the Tx pin of the euler bus.  Tx and Rx  cross.  ( in human terms, your mouth speaks to someone's ear, they listen with their ear to your mouth!). Use the pinouts sheet from the wiki to identify and utilize the uart3 if you like. The codes will need to modified slightly should you decide to use uart3.  In the pic below you'll notice that the white wire is missing; that's ok, if you're not going to be sending commands to the gps receiver, and the receiver works very well by default in most cases.

The PineA64 lith-ion batt is in the foreground with the LED lab in the background.  The pic below is the verso of the breakout board showing the backup batt and holder (which may be optionally soldered in place). I strongly recommend the backup batt (and bracket) because it significantly reduces startup and acquire times... the receiver gets smarter over time, and memorizes GPS sat information as it runs.

   

The pic below is a close-in of the ada fruit ultimate gps breakout board clearly connected to the uart4 (ttyS4) of the PineA64. I have posted the codes below. Again , you'll notice that the white wire (used to send commands to the gps receiver is missing.  The cable on the near end of this pic below is the uart0 serial console which runs over to my notebook gnu+linux system and is my interface into this board.  The transmit Tx wire green of the serial cable plugs into uart0 pin(8) of the EXP header, the white receiver line Rx plugs into pin(7) of the EXP header , and the black wire (grnd) plugs into pin(9).

   

The codes listed below are a simple Python script that parses the primary NMEA sentences for local display making some sense of the otherwise cryptic messages typically received by any GPS receiver. The code has been tested on gnu+linux (lennyraposo debian mate) and displays latitude, longitude, time, date, altitude, and satellite position for fixing sats.  The codes should be run as root;  while they are intended to get a person started, they may not be robust enough for direct application , and may or may not be suitable for a particular purpose.

ada_fruit_GPS4.sh

Code:
#!/usr/bin/python
##
##  ada_fruit_gps4.sh
##  v.01a
#
#*****************************************************************
#  author:     Mark H. Harris    
# license:     GPLv3
#
#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
#   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
#   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#   MECHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
#   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#   SPECIAL, EXEMPLARY, OR CONSEQUENCIAL DAMAGES (INCLUDING, BUT
#   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
#   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERUPTION)
#   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
#   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE
#   EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#*****************************************************************
##
import serial

## SERIAL PORT SETUP PINEA64 UART4
#
uart4 = serial.Serial(port="/dev/ttyS4",bytesize=8,stopbits=1)
uart4.baudrate = 9600

## INTERESTING GLOBALS
#
count=0
svns=0
svndct={}
gprmc=''
ggagsa=''
uart4.flush()
gsvflag=False
kb_interrupt=False
GGAFIX= {'0':'Fix not available', '1':'GPS fix', '2':'Differential GPS fix'}
GSAFIX= {'M':'Manual', 'A':'Auto', '1':'Fix not available', '2':'2D  <4 SVs used', '3':'3D  >3 SVs used'}

## MAIN TRY BLOCK WHERE WE ATTEMPT TO PARSE SOME NMEA SENTENCES
#
while(not kb_interrupt):
   try:
       cline=uart4.readline().split('*')
       dline=cline[0].split(',')
       if (dline[0]=='$GPGSV'):
           if (dline[2]=='1'):
               gsvflag=True
           for n in range(4,len(dline)-3,4):
               svndct[dline[n]]=(dline[n+1],dline[n+2],dline[n+3])
           continue
       if (dline[0]=='$GPRMC' and count==0):
           print("\n"+gprmc)
           gprmc="time: "+dline[1]+"   date: "+dline[9]+"   "+dline[4]+": "+dline[3]+"   "+dline[6]+": "+dline[5]
           count+=1
       else:
           if (dline[0]=='$GPRMC'):
               count+=1
       if (dline[0]=='$GPGGA' and count==0):
           gprmc+="   El: "+dline[9]+" "+dline[10]
           print(gprmc)
           ggagsa="    sats: "+dline[7]
           ggagsa+="   type: "+GGAFIX[dline[6]]
           svns=int(dline[7])
       if (dline[0]=='$GPGSA' and count==0):
           dsvns=[]
           for n in range(svns):
               dsvns.append(dline[3+n])
##          print("svns: "+str(dsvns))
           ggagsa+="   mode: "+GSAFIX[dline[1]]+" "+GSAFIX[dline[2]]
           print("\n"+ggagsa)
           print("\n                  SVn: ('El', 'Azi', 'dB')")
           print("               ----------------------------")
           if (gsvflag):
               for svn in dsvns:
                   print("                   "+svn+": "+str(svndct[svn]))
       if (count>=5):
           count=0
   except KeyboardInterrupt:
       kb_interrupt=True
       uart4.flush()

run with :

sudo  ./ada_fruit_gps4.sh

The breakout board will flash once every second until a fix is established;  thereafter it will flash once every fifteen seconds.

The codes listed above will work with other GPS receivers, but may need to be modified for display depending on the order of NMEA sentences the GPS receiver provides and how often the receiver updates the GSV sentences; which are updated by the ada fruit breakout every five cycles (or every five seconds).
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#2
I saw this thread, and thought I'd try the same.  For reference, in case anyone else wants to try this, I am running the Linux 3.10.102-2-pine64-longsleep #66 kernel here.

Indeed everything works right away with an unmodified Adafruit Ultimate GPS HAT plugged into the PI-2-BUS connector.

I get all the GPxxx strings coming in on /dev/ttyS2, the serial port on the PI-2-BUS pins 8 and 10.

Now, I've found that the gpsd daemon makes it easier to deal with the output from the gps receiver, since it collates all the bits and pieces of information in the various GPxxx messages into one common data area, from which we can read the time and where we are and where we are going, all in one go.

So I installed gpsd,  its clients and client development packages:
 
apt-get install gpsd gpsd-clients libgps21 libgps-dev

and had it almost going.

Since the gpsd daemon has to be told to read from /dev/ttyS2, there is a setting in a file /etc/default/gpsd for this,

DEVICES="/dev/ttyS2"

and now client programs like cgps and others work as expected.

The Adafruit Ultimate GPS HAT has a 1 pulse-per-second signal connected to PI-2-BUS pin 7, which is PL10 or GPIO362, which might be used by the kernel if it supports 1pps for timekeeping with NTP.
  Reply
#3
Did similar with a Dragino LoRa/GPS hat (http://wiki.dragino.com/index.php?title=....2FGPS_HAT), found gpsd and cgps to be an easy way to get the GPS side up and running.

And, of course, it works with Marcus' code as well with the same serial port tweak.

Now I just need to find some free time to get the LoRa side of the board working with the Pine.
  Reply
#4
Nice writeup Mark. Can you sticky this thread also, as it shows the serial bus being used. Can you also edit it to indicate which pins you've connected the GPS to... I've having to guess that you plugged the GPS TX into Pin 10, etc... Wink And you wouldn't want me to blow up a GPS module now, would you? Tongue
  Reply
#5
Making this thread sticky. I have edited the original post to make the pin number assignments more clear; also, I posted the link to the wiki pinouts diagram for the euler bus; I hope this is helpful.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#6
Addendum:  Coin Cell Clip:

I chose to mount the coin cell clip to the back of the gps breakout board , by soldering it to the pads provided and then I used the slightly thinner DL1216 battery.  

The specs call for the CR1220, but the CR1216 ( or DL1216 ) is 1.6mm rather than 2.0mm thick, and I thought it would put less pressure on the clip's springs.  This battery ran fine for a couple of weeks.

I made an error and put too much heat on the clip, thereby damaging the glue holding the solder pads to the breakout board, and eventually the clip gave way springing the battery and the clip across the room.   Blush

A little research found a way to salvage my $40 dollar mistake.  One of the breakout pins is an input called VBAT. The VBAT pin also connects to the breakout RTC backup battery , and can double for the coin cell clip. Frankly, I wish I had know that in the beginning and I would not have messed around with the coin cell clip to begin with. 

I have now chosen to use an AAAx2 battery box (with switch) to backup the RTC and gps settings; this of course saves those really long gps bootup and acquisition times.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#7
Addendum: On-board Data Logging:

I made a pleasant discovery tonight ; the v3 ultimate gps breakout board from ada fruit has 65K of on-board data logging available. To get the logging started you simply send a PMTK checksum(d) message to the breakout and the breakout board and module do the rest. You query the data logged with a PMTK message as well; the board has enough on-board storage to log for about 48 hours continuously.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#8
Mark, thanks for the write-up. Very nice.

On the adafruit website they are out of stock https://www.adafruit.com/products/746

What is a good alternative source?
  Reply
#9
(09-02-2016, 06:37 AM)Boring Wrote: Mark, thanks for the write-up. Very nice.

On the adafruit website they are out of stock https://www.adafruit.com/products/746

What is a good alternative source?

They will be back in stock soon I'm sure, but in the mean time Amazon has them:

https://www.amazon.com/Adafruit-Ultimate...B00GLW4016



by the by, if you order through Amazon, you can order the external antennae adapter and active antennae and cord all in the same package which reduces the shipping costs;  plus, the breakout board is cheaper than ada fruit carries it !
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#10
   

Here is a pic of the VBAT installed with the rest of my PineA64 guts. 

... the battery box is a AAAx2 with a slide switch. Positive 3v+  goes to VBAT and the negative lead of the battery box goes to ground.  I have soldered the gps ground lead (black) to the VBAT ground lead (brown) because the gps breakout only has one ground pin. 

The VBAT is absolutely necessary for real-life practical use of this gps unit... otherwise boot-up and acquisition of fix can take anywhere from 15 minutes to a couple of hours !...  The VBAT holds the Real Time Clock, as well as satellite info for the next bootup... subsequent bootups will take considerably shorter and shorter periods of time as the unit learns;  turn the battery off, and you have to start over !
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb Sample GPIO codes highlighting RPi.GPIO-PineA64 and the PI bus MarkHaysHarris777 6 8,027 06-07-2019, 12:37 AM
Last Post: tllim

Forum Jump:


Users browsing this thread: 1 Guest(s)