GPS Receiver and
For the time base, I chose the Garmin GPS receiver
shown in Figure 6, mainly because I already had it left
over from a previous project. I could have used an RTC
(Real Time Clock) but then I would have had to add more
buttons to set the time. Besides, in my junk box I also had
a Parallax SX28 microcontroller programmed to parse the
sentences and output the time and date over a 9600 baud
five volt line. I bought a bunch of SX28 protoboards when
Parallax had an End-Of-Life sale several years ago; they are
handy for small projects like this one.
The time and date are parsed from the GPS RMC
sentence and the number of satellites in use is taken from
the GGA sentence. As you’ll notice in Figure 4, I display
the number of satellites on the 2x16 LCD, only because I
am awed by the whole GPS concept and love to see it
working. The Garmin unit works fine inside my single-story
house, but your reception may vary.
For some obscure reason, I decided to write my own
Arduino routine to convert UTC time to local time/date,
instead of adapting a Library routine. Big mistake! It
looked simple enough, but then I realized that I would
have to include time zones, leap years, and daylight
savings. Garf! After many hours of debugging, I got it
working and confirmed that it converts the UTC data to
the correct time and date for all 50 states. Just enter your
Time Zone (TZ) in the Setup Section of the code before
you load it. If you are not in the US, simply adapt the
code to fit your location.
The basic program flow is as follows:
1. In the background, the Arduino measures wind
speed at 2.250 intervals, and the SX28 reads the GPS
time/date and number of satellites.
2. At the end of each minute, the SX28 sends a pulse
to the Arduino.
3. The Arduino then:
a. Determines the peak velocity for the past minute
and adds the value to the daily array (1440 points).
b. If the daily maximum velocity has increased, it
moves the red fid mark and value to a new point, and
sounds an audio signal.
c. It serially transmits updated config and data array
files to Gnuplot in the RPi.
4. The RPi sends a new HDMI plot to the LCD
monitor, but in a small window.
5. The RPi expands the window to fill the LCD screen.
6. Steps 3, 4, and 5 are repeated at the end of each
minute, 1,440 times per day.
7. Everything resets at midnight.
8. The GPS GMT time/date from the SX28 is
converted to local time as it comes in.
The biggest problem I had with the programming was
juggling the code for the three different processors. The
SX28 used assembly language, the Arduino used C, and
the RPi required a combination of command-line
programming and Python. I had a heck of a time keeping
track of which language I was using at any one time. Plus,
it was my first experience with Python, so there was a
learning curve. Fortunately, the Internet has a cornucopia
of helpful hints and I was able to work my way through
the problems. I also bought several books and tapped my
This project was also my first experience with the
fantastic free Gnuplot plotting program. It was fun to
customize the display, but it was almost impossible to stop
tweaking it. (You know how it is.) I chose to locate the
main Gnuplot configuration file in the Arduino because I
needed to update many of the displayed numbers 1,440
times a day. Normally, the config file would be
permanently located in the RPi main directory. Instead, I
send an updated config file to the RPi at the end of each
minute, at 115200 baud.
The source code for the Parallax SX28, Arduino Mega,
and RPi is available at the article link. Also available is a
document explaining how to install the necessary support
applications/tools for the RPi.
Booting Up and Other
Getting all three processors to boot up concurrently
February 2016 31
■ FIGURE 6. Using a GPS receiver to extract the time
and date doesn’t require setting, but an RTC
could be substituted.