A GPS tracker for ultra-endurance cyclists

[Preserving this write-up I submitted as an entry in an electronic design competition].

Cycle Tourist

Ultra-endurance cycling events are becoming more and more popular. Events such as the Transcontinental Race (4,000km, unsupported, from Belgium to Turkey or Greece) require cyclists to ride for upwards of 16 hours a day, often catching just a few hours sleep, bivvying at the roadside to avoid wasting time on hotel checkins. Some events, such as the Audax UK “Lumpy End-to-End”, 1,800km in 8 days, require validation by GPS track. Opportunities for charging battery-powered devices are few and far between. While most participants use a dedicated consumer GPS device, or mobile phone, for navigation and capture of their track, there is a serious risk that batteries fail en route. It would be devastating to complete such an event, but not to capture the relevant GPS validation track. The purpose of my device is to provide a very low-power, simple GPS tracker, that can run unattended for days at a time on a single battery charge. It could be used as either the primary, or a backup, GPS tracker for ultra-endurance races.


Key requirements for such a device include:

  • Low-power. Rechargeable battery powered with ability to run for several days without a charge.
  • Weather-proof. There is a high probability of heavy rain at some point on such a long event. The device must exclude water.
  • High data storage capacity. Each GPS track point requires 32 bytes, in a suitable binary format. The device must record a point at least every 5 seconds for validation. Hence the device must be capable of storing more than 0.5MB per day in non-volatile storage.

Selection of components

  • ESP32. This microcontroller has many advantages which contribute to delivering the requirements outlined above. Low-power: The device can operate in deep sleep mode, consuming 10 µA, for much of the time e.g. for 4.5 seconds in every 5 second sample period. While collecting track points from the GPS device, the device is powered-up, but WiFi and Bluetooth are not required, so the radios can be disabled. Miniature. Even in a development board format (in this case the ESP32-PICO-KIT board), the device is small enough to be housed in a compact, lightweight enclosure that can be carried unobtrusively by the cyclist. WiFi. The device operates standalone while collecting GPS tracks, but at the end of event, we need to retrieve the saved track. This can easily be achieved by activating WiFi and a simple web server, allowing the GPS file to be downloaded. Touch-sensors. By using touch sensors as switches, e.g. to switch between tracking and track-retrieval mode, we avoid the need to open up physical ports on the enclosure, thus minimising opportunities for water ingress.
  • U-blox MAX-8C GPS. U-blox GPS devices are cheap and easy to obtain. They provide support for text-based NMEA protocol, as well as proprietary UBX binary format. However, many of the development boards are not designed with low-power in mind. MAX-8C is inherently low-power, and can be built into a low-power board such as this one from Uputronics. Typical current during GPS acquisition is 18mA, but low-power modes provide potential for this to drop to around 4mA post-acquisition and during tracking.
  • Winbond W25Q256FVFG External SPI Flash. The ESP32-PICO-KIT provides 4MB of flash memory, but much of this is consumed with firmware and program storage, leaving no more than 2MB available for storing GPS trackpoints. Given our aspiration to record a track for many days at a consumption rate of 0.5MB per day, I identified the need to interface to a further external SPI flash chip. The Winbond W25Q256FVFG provides 32MB of additional flash, which will support 60 days of GPS track recording.
  • LiFePO4 battery. All the above components run at a standard Vcc of 3.3V, therefore – with a suitable voltage regulator – many options of battery format are possible, including LiPo (3.7V – 4.2V), Alkaline, NiMH. LiFePO4 batteries are an attractive option, because the nominal voltage is 3.2V, and the discharge curve is very flat, dropping below 3.0V only after releasing around 95% of its total capacity. This means that 3.3V devices can be reliably powered without a voltage regulator, avoiding the associated inefficiencies. A drawback is that these batteries are heavier and more bulky than LiPo batteries of comparable capacity.
  • TP5000 LiFePO4 charging module. The LiFePO4 battery, which is sealed inside the enclosure, can be charged with 5V from a typical USB charger, via an internal TP5000 charging module. To prevent water ingress, a 5V DC jack with rubber seal is used in preference to a mini- or micro-USB connector.
  • Touch-pad hardware. Touch-pads are implemented with a metallic disc attached on the inside of the enclosure. A steel washer has been used successfully. Further work is required to evaluate alternatives e.g. a copper rivet, for sensitivity and precision.

Design approach

Software is developed in C/C++ using ESP-IDF development framework. Tasks within the framework include:

  • GPS. Initialise the GPS device with the sample rate and protocol messages required. GPS location acquisition can be accelerated by using AssistNow Offline (u-blox), meaning that GPS information (ephemeris and almanac) can be downloaded from an Internet site over WiFi for 35 days into the future. Then, when the device is powered-on, the relevant day’s offline data is downloaded to the GPS device. This speeds up acquisition from 30 seconds to around 5 seconds. Once GPS location has been acquired, the GPS device sends a trackpoint via UART to the ESP32 host once every 5 seconds. A binary message, UBX-NAV-PVT, is used, because it encodes the location data in a relatively compact binary format. The received UART data wakes the ESP32, which, with minimal processing, writes the location data in the same binary format, via SPI, to external flash. The ESP32 can then return to deep sleep. This 5 second cycle will repeat indefinitely for as long as the device is in track-recording mode. A simple file system is implemented on the flash (esp32_fatflash by Illucius) to allow tracks to be associated as files, and so that they can be deleted by the user, and the storage occupied by that track can be made available for reuse.
  • Touch-pad. A second ESP-IDF task monitors for touch pad events. A long-press on a touch pad triggers a software event, which switches the device to “track-retrieval mode”. This activates WiFi and a simple web server. This will normally only occur when the ride is over; the device may be powered with external 5V supply at this time, and the additional power consumption will not be a problem.
  • WiFi / Web server. A third ESP-IDF task, triggered to be created in “track-retrieval mode”, WiFi will activate (could be either as a station on a pre-configured SSID, or as an AP providing a new, temporary SSID). A web server will be started, offering, via a browser page, a list of GPS tracks available for download. Each will be identified according to its start time, which is readily discoverable by decoding the first trackpoints of the binary trackpoint data stored in external flash. When the web client selects a track to download, the web server will decode trackpoints read from external flash, on-the-fly, converting them into the industry-standard GPX file format. The web server will also provide the ability to delete selected files, which will result in an entry being deleted from the list of tracks held in flash, and the flash pages used by that track being returned to a free page pool.

Development status

The hardware elements have been acquired and integrated on breadboard. Each of the main capabilities has been prototyped in software and demonstrated individually, i.e. ESP32-GPS integration, ESP32-external flash (both direct page read/write and via FAT), WiFi and web server, LiFePO4 battery operation and charging, touch sensor detection. The capabilities have not yet been integrated into a single working firmware build; this is work in progress. The current software implementation can be consulted here. Further work is also needed to design the enclosure to accommodate the hardware in a compact, weatherproof format. The build needs to be optimised for power consumption. Initial measurements suggest a current-draw of around 35mA in track-recording mode, but I believe this can be reduced below 20mA with optimised use of deep sleep, and with careful power management of the GPS module. This suggests the device could operate for 3 days on a single 1600mAh LiFePO4 battery, or 6 days on two. I look forward to completing this unfinished work, but wanted to submit an entry for the competition in time for the deadline.

Potential further enhancements

Because the ESP32 is also blessed with Bluetooth, the possibility exists to also track Bluetooth sensors such as heart-rate monitors and pedal-power meters. This would clearly increase power consumption compared to simple GPS tracking, but in certain circumstances it might be an attractive trade-off.

Transcontinental Race, Belgium-Turkey, 2,400 miles 59,000m ascent (that’s six and a half Everests)

IMG_20160726_202350917-50On Friday 29th July I will join around 250 other cyclists on the start line of the Transcontinental Race in Geraardsbergen, Belgium. The race is quite unusual in several ways:

  • The clock never stops, racers choose where, when and if at all to rest.
  • No outside support is permitted, we can use only what we take with us, or find en route at commercially available services.
  • There is no defined route, just four mandatory controls; naturally they are located at high altitude in the Massif Central, Alps, Dolomites and Balkans.

The finish is at Çanakkale near the Gallipoli peninsula in Turkey. Part of my motivation is to remember my grandfather who survived an extraordinary bloodbath when he landed at Gallipoli 101 years ago.

I hope to complete the course in 18 days or less, but it’s a very tough race and last year almost 50% did not finish. I’m not seeking sponsorship but I’d be thrilled to receive any words of encouragement en route. My race number is 61 and you can read brief updates from me on Twitter (@robjordan and #TCRNo4s061), view my daily rides by following me on Strava (Rob Jordan, Winchester) or email me: rob@jordan-maynard.org. We will each carry a satellite tracker and you can view position updates every 5 minutes here: http://trackleaders.com/transconrace16 (beware, it can be addictive!)

You can read lots more about the race at www.transcontinental.cc.

Gorinchem – Rotterdam

De Goesting B&B, GorinchemOur B&B at Gorinchem was very special. Christina and her husband had bought a plot of dock-side land 20-odd years ago, and, while living on a houseboat, built, brick-by-brick, a house for themselves and an apartment to let out. They clearly love to sit beside the water, reading and drinking coffee. The B&B apartment was charming; so close to the water it felt like a houseboat, though apparently without risk of flooding as the water level is carefully managed. We slept in a box-bed; a cupboard containing a full-length bed.

Christina had helpfully provided some tourist information, including timetables for the local ferries, which forced a change of plan. The ferries we had planned to take to Woudrichem, and later across the Steur, would not start running until noon on a Sunday, so we were forced to re-route via bridges. It was not a big inconvenience, the main thing was to reach the Biesbosch, a glorious wetland well-populated with bird life. It was a rare warm sunny day and we enjoyed the luxury of an easy-paced comfortable ride, stopping at the wildlife museum on Biesbosch Museum Island for coffee and cake.

Being Sunday, racing cyclists were on the road in large groups with team jerseys. It made us realise that we had seen very few fast cyclists in Germany, but the Netherlands certainly made up for that.

In Dordrecht, we stopped for sandwiches on the docks where a couple of young lads were larking and apparently practising their English. “The monkey is in the the car” said one repeatedly, while the other replied “fuck off!”

We reached Kinderdijk, and the spectacular sequence of windmills standing alongside a canal. This is a popular tourist attraction, with many people of all nations tottering on rented bicycles. Here we needed to take a ferry to Slikkerveer via the Ridderkirk ferry terminal. This turned out to be quite tricky because the ferry stop at Kinderdijk had been moved and there was no advertised timetable. But, as so often, we were lucky that the right ferry (number 6) arrived by chance just as we had started to contemplate a 15 mile diversion to reach Rotterdam.

Happy cyclistsWe excitedly took on the final leg into Rotterdam, past the Feyenoord stadium, and celebrated success as we crossed the Erasmus bridge, our last crossing of the mighty Rhine.

Arnhem – Gorinchem

Woodland near ArnhemArnhem has a brand new railway station with fantastic bike-parking facilities. When leaving the parking area, the cyclist must flash an ID card at the attendant to show they are owner of the bike. They do this nonchalantly, en passant, without breaking pedal stroke. The station is on several levels, but these slope and merge without noticeable staircases or escalators. The building won architectural awards. Sadly, the roof leaks.

We had a nice vegetarian rijstafel in Arnhem. The proprietor told us how the many special leaves used in this cuisine give Indonesian workers the ability to work in the fields for 14 or 15 hours a day. Sounds like they need a trade union.

The morning ride out of Arnhem led us on paved but narrow paths through woodland. It also featured a few hills! We’d forgotten about those after many flat days. In the afternoon hard rain and wind reappeared and we had to fight our way to Gorinchem. The final yards were puzzling as we passed through council flats looking for our B&B in a most unlikely area. But Caroline, master of the accommodation bookings, knew what to expect, and it was something quite special.

Orsoy – Arnhem

XantenOrsoy’s an odd little historic crossroads village in the shadow of power station cooling towers. Terrible news from England cast a pall over our stay, but we enjoyed our accommodation in the Schlafkammer, a grand 19th century house divided into commodious apartments. More often used by long-term tenants, we shared the breakfast with a team from Dummen Orange, a cut flower company based in the Netherlands. Though we were still in Germany there were strong Dutch flavours emerging.

Among the odd spectacles seen in the last of Germany: A nuclear power station converted into a family fun park (apparently never commissioned because it was completed just as Chernobyl melted down). An old people’s home in Grieth from which a succession of seniors emerged on mobility scooters for their daily constitutional.

We proceeded towards Arnhem via numerous small ferries, including one that was anchored in the middle of the river and propelled by the natural water current and presumably a rudder. The Netherlands arrived unannounced. A small cattle gate, similar to many others, sat at the border but the only evidence was that signage changed language.

On the next ferry we met a British couple riding Bromptons from Basel to Rotterdam. Mrs Brompton had taken a tumble from her bike in Köln, while crossing a tram track. She needed a bit of medical attention, so dropped in at a surgery. Inside 30 minutes she was examined, stitched and sent on her way. No bill, no paperwork. Good old EU.

Köln – Orsoy

We had a two-night stay in Köln and a priority was to get some attention for Paul’s rattly front wheel. Because we were long-distance travellers, Herr Schneider at Schneider Rad Sport made time in a busy day to repack the bearings. Paul rolled sweetly afterwards. Herr S also stroked Paul’s Campag shifters lovingly and said “what a nice bike”.

Our 2-night stay in Köln was hosted by the absolutely delightful and attentive Jens, proprietor of the Hotel am Museum. In his devotion to ensuring visitors’ enjoyment of Köln he gave and demanded a detailed exchange of information, sometimes comically intrusive: “How much did your bike repair cost?”; “Why are you taking your back-pack on your walking tour of the city?”

To the latter question, we reacted sheepishly as we had borrowed towels and a bathrobe from the room for our visit to the Neptunbad Spa, a fantastic 1912 bath house. Great saunas, hot tub and pools, only very slightly spoiled when a heavyweight naked man slipped on a sauna bench and landed with his whole body weight on my toes. Luckily this happened during the ice aufguss, so resulted only in colourful bruising, not swelling.

We ate one evening in one of Köln’s brauerai, serving local beer in tiny 20ml glasses, allegedly so it always remains acceptably cold. We later found out the waiter keeps delivering these until you cover an empty glass with a beer mat; could have been an expensive evening.

The weather in Köln was bizarre. Sunny spells would suddenly end with a colossal thunderstorm and torrential rain, lasting only five or ten minutes.

Düsseldorf glimpsed through the trees.The route onwards from Köln took us through Dusseldorf, a much lovelier old town than we expected, and Duisburg, a crumbling giant of heavy industry where the Rhine and Ruhr come together to form one absolutely gigantic waterway.

Koblenz – Köln

Our evening in Koblenz included a nice meal but with the most frustratingly slow service! The restaurant was Cafe Miljoo, perhaps not the most promising name at least for English speakers. The waitress was a charming young woman but we sensed she couldn’t hold two ideas in her head at once, and needed a little sit down behind the scenes to recover after each one. It took ages to get menus, to have our order taken, and to get our table cleared. I probably didn’t help matters, trying to force the pace a bit, when asked: “alles war in ordnung?” (was everything all right?) I answered “zitronenkuchen” (lemon cake). After that she decided we were lunatics and brought neither lemon cake nor a bill. I tried so hard to catch her attention I thought my eyes would pop out of their sockets, but she seemed to be suffering from tunnel vision.

Kaiser WilhelmKoblenz is at the junction of Rhine and Moselle (a junction guarded by a colossal and unattractive equestrian statue of Kaiser Wilhelm), so it receives many cruise boats. As we strolled past one, an entertainer was playing the organ, while thrusting his hips rhythmically and suggestively. Meanwhile, the audience were raising and lowering their arms in time, Mexican wave style. Each to their own.

The ride to Köln was a bit of a faff. Flooding has increased with all the recent rain so we were dodging closures. A German man heading in the opposite direction asked Caroline for intelligence about the state of the path, while his wife sat on a bench, arms folded, as if to say “I’m not going another metre on this stupid bike track.” When C confirmed the next bit was open he dog-whistled his wife to come along. Maybe the flood wasn’t their only problem.

We pointlessly crossed the river by ferry twice, wasting time and money, because our guide book recommends an overnight stay on the other side for those moving at half our speed. We should have spotted that in planning, schoolboy error. The final approach to Köln is industrial and busy, and another German cyclist pedalled in the opposite direction yelling something to me and the only word I could make out was “Autofähre” (car ferry). Maybe it was: “Haha you are the crazy pair who pointlessly crossed the Rhine twice by car ferry!”

But the final arrival was splendid, the Rhine is straddled in Köln by numerous huge and spectacular bridges, and with kids on the waterfront skate-boarding to hip hop, one could be in New York. We have a day off tomorrow, bye for now.

Mainz – Koblenz (Hunsrück and the road to Schabbach)

The smithy in Geilwehler / SchabbachWhile Caroline continued along the Rhine banks, I took an excursion to the Hunsrück to visit some scenes from my all-time favourite TV/film series, Heimat. In case you don’t know it, Heimat is an epic (53 hours) history of a Hunsrück family through 4 generations. I’ve been preoccupied with it since the first series was shown in 1984. It begins in 1919 and ends in 2000. The family comes from the fictional village of Schabbach where the patriarch is blacksmith. While several Hunsrück towns stood in for different parts of Schabbach, it was the smithy I really wanted to see, and that is in the village of Gehlweiler.

I made an early 5am start and at first followed the south/west bank of the Rhine, then turned left for a stiff climb in steady rain to the Hunsrück, which is a kind of elevated plain at 500m. First sightseeing stop at Simmern was a disappointment. The watchmaker’s shop, which is a reference point in the rise of persecution of Jews and early Nazism, has had a complete makeover and now has a modern plate glass shop front.

Selfie fake: I'm standing inside a 360 degree photo showing Gehlweiler as it was for the filming of HeimatBut from Simmern onwards the beauty of the Hunsrück landscape started to take hold, and the long descent to Gemunden was magical. Just around the corner from Gemunden is Gehlweiler. Without any great fuss, the village preserves its older buildings and highlights with photos the role each played in the films. There is a 360 degree photo stand, where a smaller man (or a stooping six footer) could (and did) take a selfie surrounded by the village as it was for filming in the early 1980s, and representing the pre-war small town Hunsrück. The smithy was there, with all tools still laid out on the bench. As the rain intensified to an absolute torrent I was happy to see the real Schabbach at last.

The gunderoderhausThere are many more sights that could have been visited but not easily within a single day’s cycling. But I included one for Caroline. The star-crossed lovers of Die Zweite Heimat, Hermann and Clarissa, finally get it together in Heimat 3. They meet as the wall falls in Berlin 1989, and renovate (with cheap East German labour) a decrepit house high on hillside overlooking the Rhine at Oberwesel. That is now the Gunderoderhaus, a restaurant and film venue and tribute to the creator of Heimat, Edgar Reitz. The view from the GunderoderhausIt’s a magnificent spot and is a mere 1km, (and 200m of climbing!) from the Rhine cycleway. We reunited there and had a lovely lunch in Hermann and Clarissa’s dream house, overlooking the most famous section of the Rhine, near the Lorelei rock.