Amazon Banner

Monday, March 18, 2013

Cacheberry Pi

As an avid Geocacher, when I was thinking of what to do with my Raspberry Pi, I couldn't help but wonder what geocaching related devices I could make.  I considered building a geocache that had some kind of electronics, controlled by the Pi, but decided that powering the Pi long term would be an issue.  I searched for other ideas online, and came across a video of the Cacheberry Pi project, by Jeff Clement.  The perfect mix of geocaching, electronics, and programming, I had found my first project!

The Cacheberry Pi is designed to be used in the car.  Place the small box on the dashboard, connect it to power, and while you're driving, the Raspberry Pi will search a pre-loaded database of geocaches for the nearest cache in the direction you're travelling.  This is different from most GPS receivers or applications because it searches only a narrow area ahead, and will not return caches that you've already passed by.

I've spent the last few weeks getting it working.  I used some slightly different hardware from the original, so it wasn't quite as simple as dropping his image onto my Pi and running it.  Here's what I used:
The Cacheberry-Pi displays a dashboard screen when no
nearby caches are found.
Getting the Raspberry Pi up and running was easy.  Getting the other hardware working right took a little bit of time.  The LCD that I used didn't work with the lcdproc driver included in the original version of the Cacheberry Pi.  I struggled for a while to get the lcd working right.  For more info on that, and to download the modified driver if you need it, see my previous post on the subject here.

The GPS module I used doesn't connect via USB, but instead connects directly to the GPIO pins on the Raspberry Pi and communicates via serial.  By default, the serial port on the Raspberry Pi is set up as a serial console, which must be disabled before it can be used by the GPS.  This can be done by making small changes in 2 files.

In /etc/inittab scroll to the end of the document, where you should add a # sign before this line:
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Next, edit /boot/cmdline.txt - This file is just one long line of text.  Find and remove the following from that line:
console=ttyAMA0,115200 kgdboc=ttyAMA0,115200

GPSD must also be reconfigured for the serial port instead of the USB. To do this, run:
sudo dpkg-reconfigure gpsd
This will start a wizard to configure settings for gpsd.  Set gpsd to run automatically at startup, then accept the default settings on each screen until prompted for the port that the gps unit is connected to.  Enter the following in the port field:
/dev/ttyAMA0
I've added an extra LED to my cacheberry pi, which is connected directly to the LED pin on the +Adafruit GPS unit.  This makes it easy to tell whether the GPS has a signal lock yet.  The other LED is controlled by the python code and activates based on the cache search pattern and distance.

I've also forked the Cacheberry Pi project on github and made a few changes to the code.  I added some missing steps to the instructions in the readme, to make it easier for others to reproduce the project. I've added configuration settings to display measurements in Metric or Imperial units, localize the time displayed on screen, adjust the scroll speed of geocache data on screen, changed what information about a geocache is displayed on the screen and how it's formatted, and made a few other small changes.  I hope these changes can be of help to someone else who is inspired by Mr Clement's project and wants to give it a try.

The updated code with these changes can be found here github.

Still on my to-do list for this project:

  • Adjust the behavior and triggers for the software controlled LED
  • Add a push button or keypad to allow simple interaction with the Cacheberry-Pi
  • Add a method for initiating a safe shutdown of the OS
  • Add some kind of backup power system which will kick in when the vehicle power is turned off, triggering a safe shutdown of the Pi's OS and powering the Pi long enough for that shutdown to complete. 
  • ???

1 comment:

  1. I've been trying to get this to work and am probably missing the obvious but how do I start the program up as it doesn't work for me? Many thanks in advance

    ReplyDelete