Odd Software for Odd Jobs

Average Speed Calculator

There are now a few point-to-point speed cameras on the highways in Australia. These apparently calculate your average speed over a fixed distance by snapping your number plate at the start point and then again at the end point. Now I know that my car's speedometer under-reports by about 10% - if it says I'm doing 100km/hr then I'm actually doing about 92km/hr. I've confirmed this from both my TomTom SatNav and by the road-signs they have roadworks that flash your speed up at you.

So I was wondering if I could hack something together to get a rough estimate of what my average speed is in real-time. I got a GPS unit off eBay some time ago but never got around to trying it out - it's a uBlox NEO-6M (marked GY-GPS6MV2).

Anyway, I finally gave it a go using the TinyGPS++ library by Mikal Hart.

And it worked pretty much straight away! Too easy. Thanks Mikal!

I wanted to use an e-ink/e-paper display so it would be nice and clear. I'd also gotten a 2.7" screen with developer board from Adafruit some time ago, but again had put it aside whilst I worked on other things.

So this was my starting point:

2016-01-26 07.15.08-1

The e-paper display was a harder to get going - a lot harder. The instructions on how to put it together were clear enough, but I found a lot of difficulty getting the examples to work. I finally got one of the examples to work using an Arduino Mega. Unfortunately, it seems the available libraries are slanted towards graphics rather than just text. As I'd gotten the largest 2.7" version, it turns out there's not enough memory to really run it properly. I'd have been better off using the 2" model perhaps.

So that was a disappointment. I might re-visit this later. In the meantime, I had a few 16x2 LCD displays lying around, so put one to use pretty quickly & simply. Unfortunately the contrast was all wrong (I'd used a 1kΩ to ground and a 10kΩ to 5V), but you can just make out the latitude and longitude from the GPS unit being output on the LCD:

2016-01-27 18.46.20-1

I sorted the LCD contrast issue pretty quickly by replacing the two resistors with a 10kΩ pot (blue). I've also added a momentary action switch to the small prototyping area on the Freetronics Eleven board to use as a start/stop button. Added some quick de-bouncing code and it was working as desired.

2016-01-27 20.09.36

So the next step will be to figure out how I want to calculate the average speed - so I just average the speed that the GPS unit reports, or do I actually calculate the distance travelled and divide by the time between start & stop button pushes … ? Something to figure out later.

As I'm limited to just a 16x2 display at the moment, figuring out how to display the info I want might be the biggest challenge! But let's see.