Thursday, 5 January 2017

GPS Speedo

One of my main hobbies is old motorcycles, and one of the things all of my bikes have in common is crappy speedometers.

For some time I have been considering a GPS driven digital speedo which could be swapped between the bikes.  I have looked at using an Arduino and a GPS module in the past but was never satisfied with the display options.  Until now, I was doing some surfing round on AliExpress and came across an I2C OLED display HERE 

I decided on using the following:

  • Arduino nano clone from AliExpress HERE
  • AdaFruit Ultimate GPS breakout HERE
  • LiPo charger module from AliExpress HERE
  • LiPo battery salvaged from a broken Android tablet
Having checked that the Chinese Arduino nano clone was working fine (I have had a couple which didn't over the years) I started by exploring the AdaFruit learning pages for the GPS breakout HERE 

Having downloaded and installed the library and checked out a number of the samples I was happy with the GPS module itself although in the workshop at home it did take some time to establish a fix.

Onto the OLED display.  As this was a cheap Chinese clone, there was no nice library available.  After some playing with the AdaFruit OLED library I dismissed that as the display I had is somewhat different to the AdaFruit one.  After trying several different approaches I settled on the U8GLIB HERE which I had already got installed on my development PC at home for use with Marlin (3D printer firmware).  This library allows for several different fonts and font sizes but can be a little heavy on memory with either multiple fonts or large fonts.

Jury rigged prototype:

And got some code up and running which displayed the time and speed in suitable sized fonts and promptly ran out of memory!  After some font changes I got it to compile, albeit with 99% memory usage.

I spent some time exploring the TinyGPS+ library, which worked very well with the AdaFruit GPS mdule but found some issues when using both TinyGPS+ and the U8GLIB library.  The code worked fine when outputting the speed and time to the serial port but as soon as I started to output to the OLED it became very flaky with lock ups and just plain not updating the display.  The AdaFruit sample code I used as a base uses interrupts to read the GPS data and I suspect this is why it works OK with the display.  Further research is needed.

At this point I jury rigged the LiPo charger module and battery and set it to charge (In a baking tray just in case of flames!) and all worked OK.  The LiPo module does not do any boosting of voltage so suppplies power at the battery voltage so I connected the output from the LiPo module to the GPS and OLED prototype and left it to run to see how long it would last.  After about 20 hours I got bored and decided that would probably do!

I stuck the jury rigged prototype in the car and drove about for a few days to evaluate accuracy.  It agreed with a GPS speedo based app on my phone and was within 5% of the speed shown on the car speedo.

Being reasonably confident now with the electronics side of the project I broke out Autodesk Fusion360 and started designing the case.  I has decided on a three part case with a base holding the battery, LiPo module and Arduino nano.  A middle tier with the display and GPS module in and a top part acting as a cover.  Using the laser cutter at work I had cut a rectangular piece of perspex to act as a window.  I fired up the 3D printer and started printing parts.  There were several iterations of the case parts as I tried and developed ideas.  

Some of the 3D printed parts:

I started the build by soldering together the modules and the battery.

Assembly has started

And fitted them into the case parts with some hot glue.

Assembled and hot glued.


I added a slide switch and left ports for the mini USB connection for the Arduino and the micro USB connector for the LiPo charger module.

At this time the case is printed in PLA.  Once I have had chance to use the speedo in anger I will re print the case in ABS.  I am also going to purchase one of the silicon baking mats and see whether I can laser cut some "gaskets" for between each layer of the case. I will also design a couple of bungs for the port openings and 3D print those on the SLA printer at work using some flexible resin.

I am planning to 3D print a Go-Pro compatible mount to go on the base so I can attach it to the bikes using a go-Pro style handlebar clamp,  So that's it done for now.  I will try the speedo out once things warm up a bit and report back.

In the mean time I will do some more research into alternative ways to drive the OLED and GPS modules.

No comments:

Post a Comment