GPS and ACCEL via ShieldRv1 on Raspberry Pi?

The SparqEE CELLv1.0 device.
wtbgagoa
Posts: 5
Joined: Thu Sep 17, 2015 1:50 am

Re: GPS and ACCEL via ShieldRv1 on Raspberry Pi?

Postby wtbgagoa » Mon Sep 21, 2015 10:42 pm

Thanks for the information.

User avatar
donjohnii
Site Admin
Posts: 686
Joined: Tue Jul 30, 2013 2:19 pm

Re: GPS and ACCEL via ShieldRv1 on Raspberry Pi?

Postby donjohnii » Sat Sep 26, 2015 6:13 pm

Pretty straightforward to setup the GPS on a GPIO rather than the HW UART. Here's what I came up with:

=======================================================================================

You can use the standard Raspberry Pi UART and functions to capture GPS data over the HW UART or, as demonstrated below, you can use the Raspberry Pi to “Bit Bang” or port “Software Serial” rather than the Hardware one.

The below software Serial port utilizes the great PIGPIO which you can download and install for free at the following URL:
http://abyz.co.uk/rpi/pigpio/download.html

Here’s the file I used from their site and the installation on the Raspberry Pi:

Code: Select all

wget abyz.co.uk/rpi/pigpio/pigpio.zip
unzip pigpio.zip
cd PIGPIO
make
sudo make install

Code: Select all

#!/usr/bin/python

import sys
import time
import difflib
import pigpio

RX=18

try:
        pi = pigpio.pi()
        pi.set_mode(RX, pigpio.INPUT)
        pi.bb_serial_read_open(RX, 9600, 8)

        print "DATA - SOFTWARE SERIAL:"
        while 1:
                (count, data) = pi.bb_serial_read(RX)
                if count:
                        print data
                time.sleep(1)

except:
        pi.bb_serial_read_close(RX)
        pi.stop()

gersbrett
Posts: 4
Joined: Sat Nov 05, 2016 3:19 am

Re: GPS and ACCEL via ShieldRv1 on Raspberry Pi?

Postby gersbrett » Sat Dec 03, 2016 11:30 pm

I finally got this thing to work. A couple of remarks:

-pigpio uses the BCM numbers. So if you use the shield your EN is at GPIO10 and TX is at GPIO9 (meaning you set RX=9 in the script)
-unlike in the script on this forum and on the sparqee web site you need to set EN to True.

Here is the complete script that worked for me:


Code: Select all

#!/usr/bin/python

import sys
import time
import difflib
import pigpio

RX=9

EN=10

try:
        pi = pigpio.pi()
        pi.set_mode(RX, pigpio.INPUT)
        pi.set_mode(EN, pigpio.OUTPUT)
        pi.write(EN,True)
       
        pi.bb_serial_read_open(RX, 9600, 8)

        while 1:
                (count, data) = pi.bb_serial_read(RX)
                if count:
                        print count, data
                time.sleep(1)

except:
        pi.bb_serial_read_close(RX)
        pi.stop()


Return to “CELLv1.0”

Who is online

Users browsing this forum: No registered users and 1 guest