Tuesday, March 27, 2018

The Pi Logger

Since it's too cold to windsurf, and cheap OTG phones are not available in most of the world, I've been looking into using a Raspberry Pi for logging GPS data. For those who don't know Raspberry: they are tiny little Linux computers that cost between $5 and $30, depending which model you want. Here's an image showing two of them:
The clear case contains a Raspberry 3 (~ $30); the white case a Raspberry Zero W ($10). The black thing at the bottom is a USB battery; the blue & black thing at the left is a GT-31 GPS. Here's a view from the side:

There's a USB GPS dongle plugged into the Raspberry 3 - the same dongle I had used with Android phones before. I tested the Pi 3 - dongle setup on a bur ride into Boston today, and it worked! Here's are some speed tracks from the dongle and a GW-60 watch:
The blue lines are from the GW-60 (the "gold standard GPS), the red lines are from the dongle + pi. The watch had problems when the bus went under bridges, and dropped a bunch of points (the lines to the bottom). Zoomed in, the data from the dongle look less noisy than the watch data:
This is reflected in lower error estimates for the dongle data (the numbers on the right side):
No big surprises here, the dongle had done better than the watch in previous driving tests (when using an Android phone). The next thing will be to get some tests with the smaller Raspberry Pi Zero W in a few days (I'm waiting for a cable I need).

So far, the setup is just a logger: plug the battery cable into the Pi, wait a couple of minutes for it to boot, plug the dongle in, and record. When done, take the dongle out, and the Pi will shutdown a little later. Back home, grab the data over WiFi, and through them into your favorite GPS software, or upload to ka72.com. To get this to run, it needs a custom Java program, a couple of libraries for the USB/serial communication, a couple of scripts, and an entry in the /etc/rc.local to start things up automatically - not too bad.

The hardware cost for Pi Zero W + GPS dongle + battery + case cables is around $50 US. Adding a small display would add another $40 or so, almost doubling the cost, so that's not very high on my list of priorities.

Things I'll probably try first are:

  • Use a smaller battery pack
  • Pack things neatly for use when windsurfing
  • Configure the Pi Zero as a USB drive for easier downloading onto a computer
  • Use Bluetooth to announce speed
  • Use Bluetooth and an Android phone to display speeds 
  • Automatically transfer files after a session to a phone or PC (over Bluetooth or WiFi)
The entire setup should consist of a few things that are easy and cheap to buy, and a few cables, with no or very little assembly required. Geeks can swap the USB dongle against a ublox 8 chip with a larger antenna, and hook it up using either a serial-to-USB cable, or using the GPIO pins on the Pi (which would also require software changes). 

Monday, March 19, 2018

Texas Wrap

After three days of driving, we're back from Texas, and were once again greeted by snow on the ground. I'm not sure what the bigger shock was, though - the temperature differences or the "sticker shock" in the supermarket, where exactly the same food costs 1/3 to 1/2 more. Maybe I can understand that for fresh fruit from Mexico - but for frozen food? Well, at least the selection of vegetarian pizza is better here. Texas is not the best place for vegetarians!

The weather this year was weird, with a lot of cloudy and rainy days. I still got to sail 31 days, about the same as last year, but that included 4 light wind days, and 4 days on South Padre Island. My biggest sail (the 7.8) also was the most used sail, and only 6 of the 31 days were on sails smaller than 7.0 (2 x 5.6, 4 x 6.3).  It's not quite as bad as it might seem, though - since I only sailed slalom gear, I was on the 7.0 race sail in 23 mph wind averages, where I would use a 5.0 on freestyle gear. The two days on the 5.6 had wind averages of 27 and 32 mph.

We got only one "real" speed session this year, and not a single day with northwesterly wind that would have been perfect at the South Bird Island Slicks. On the upside, we sailed a couple of spots for the first time that are great for long distance speed: the North Flats at South Padre Island, and Grassy Point in Corpus Christi. At low water levels, both spots are great for nautical mile and one hour runs, so it's no surprise that 4 of my top 5 sessions for both of these disciplines are from this year. Good practice for the OBX long distance race next month! And maybe all that "big sail" practice will be useful at the US Nationals a week later, where I'll be sailing a 9.0 in the Kona One category. It's cool to see that more than 50 windsurfers are already registered for the US Nationals, including racers from the US, Canada, Denmark, Great Britain, Belgium, France, Brazil, Poland, Italy, and Germany. The list includes multiple national champions, so the racing should be hot! See you there or in Avon in a few weeks!

Monday, March 12, 2018

The Difference Between Good and Bad

No, this is not a philosophy post. It's about GPS reception. Surprised?

When I looked at GPS test results from yesterday and today, one thing puzzled me. Look at the data and take a guess:
Why was the phone GPS so inaccurate on 3/11, with large errors in every GPSTC discipline, but quite accurate on 3/12? I'll give you some clues, so you can see how early you can guess the answer.

Clue #1: A cold front pulled in yesterday afternoon. Temperatures dropped from the 80s into high 60s yesterday evening, and to 50s today.

Clue #2: That made me wear a 4 mm wetsuit today, while I was sailing in a lycra top yesterday.

The ardent reader of my blog may have a suspicion on what was going on by now (ha!).

Clue #3: The arm band I use for my phone tends to slip on the lycra, but much less so on the wetsuit. Yesterday, I stopped several times just to re-orient the phone so that it was pointing to the sky; it often was on the side of my arm.

Clue #4: Compare the track points from one run where the phone reported about 1 knot less speed than the GW-60 shown here:
to a run where both devices gave almost the same speed:
Clue #5: Check the "Sats" column for the phone data (the numbers on the right side) for the picture above.

So: yesterday, the armband with the phone slipped often, so that the phone was on the side of my arm, instead of pointing up. The runs that deviate most from the GW-60 data had reception from fewer GPS satellites, and changes in the number of satellites during the run. It seems that having the phone facing sideways on the arm during speed runs screws things up. That's not really very surprising - perhaps the more surprising thing is that the USB dongle gave accurate results yesterday (it was in the same bag, lying on the screen of the phone).

Can we verify that turning the phone sideways and blocking one side screws up GPS reception? Sure! I used GPSLogit, which has a graph that shows satellite reception. Here's a screen shot showing the reception with the phone facing up:
The phone used GPS 13 satellites, and had a decent horizontal accuracy of 4.6 meters. Just turning the phone onto its side did not change much, but then putting a hand close to the top of the phone on the back side did:
Now, the phone had good signal (green bars and dots) from only 7 satellites, and the estimated positional accuracy was 19.7 meters - four times worse!

If you want to reproduce this, but don't have GPSLogit, there are plenty of free GPS test apps on the Google Play Store available that could be used instead. The phone's GPS antenna is typically located near one of the top corners of the phone. You'll have to wait a few seconds to see changes in the satellite reception (probably because that information is not updated as often as position and speed info).

So, if you want to get accurate speeds from your phone with GPSLogit or Windsport Tracker, make sure the phone is facing to the sky! Of course, that's the same for the GW-60.

Sunday, March 11, 2018

Dongles Beats Phone

Here's a graph that compares the accuracy of the GPS from an Android phone to the USB GPS dongle that I have been testing:
The bars show the (absolute) difference between the results of the GPS units to the results from the "Gold Standard" GW-60 GPS in the six GPS Team Challenge disciplines over 10 different windsurfing sessions. The unit is knots. Shorter bars are better.

The results show that the phone GPS (red bars) can give quite accurate results, but sometimes does not. In 5 of the 10 sessions, at least one number (usually for 2 second average speed) was off by 0.3 knots or more. In three sessions, the observed difference was larger than 0.5 knots, which is definitely unacceptable for competition (but still good enough for just recording your sessions, and getting an idea how fast you were).

In contrast, the USB dongle had a maximum error below 0.4 knots in all 10 sessions, with a maximum deviation of 0.2 knots in 9 out of 10 sessions. The one session with a higher error was the one I reported about previously, where the arm band with the phone and dongle had slipped for large parts of the session. In all other session, the accuracy was very good. For comparison, the observed differences when wearing two GW-60 watches (one on each hand) are often in the 0.1-0.2 knot range.

Compared to the phone GPS, the USB dongle has another advantage (in addition to the higher accuracy): the u-blox GPS chip in it can provide accuracy estimates, which allows the automatic detection and elimination of artifacts, for example those that can happen during crashes or when swimming.

Anyone interested more detail can look at the data in this PDF file. You may notice that not all sessions have entries for all 6 GPS disciplines. There are various reasons for this: some sessions are shorter than 1 hour, so GPSResults did not give 1 h results; other sessions are different length in the different files (for various reasons, including a little bug that stopped the dongle logging in earlier versions), so distance differences where meaningless; and so on.

If you're really interested and want to look at the raw GPS data yourself, you can download them from here. It's a 32 MB ZIP archive with about 35 files. Note that you may need to define the time range in GPSResults for some of the sessions where the different units recorded different length sessions if you want to get meaningful results. Also, a few of the GW-60 session contain data from multiple sessions, so make sure to select just the session you want to compare.