Location Clock with help from MyGeotab
- Posted: Nov 29, 2013 at 6:00AM
Today's Hardware Friday project Pieter Venter is one that I thought kind of neat. It uses a commercial GPS tracking device and their REST API to create a "location clock". Unfortunately there's no code, but I still dig the idea behind it.
What if we had an appliance in the house that could tell the kids when I’m on the way back from work? Or that Mom has taken someone to hockey practice? MyGeotab can do all these things and more, but how do you make a 2 year old understand this technology?
Sometimes a single purpose device integrates better into our lives. An idea was born that took a few late nights of tinkering and coding to turn that idea into reality.
MyGeotab 5.7 API
Our development team at Geotab has been hard at work creating an updated version of the MyGeotab API that allows programmatic access to the rich data available in MyGeotab. The API is easy to use, easy to understand and has great documentation and examples. It allows communication between programs on the Internet using HTTPS and exchanges information with straightforward HTTP GET or POSTS, with data formatted in JSON. At least, that was the theory about to be put to the test.
Over the years I have accumulated various LCD screens, LEDs, prototype boards, servos, breadboards and other things waiting patiently (mostly collecting dust) to be transformed into something useful. The idea of a simple clock came to mind, where instead of time, the hand of the clock will indicate driver activity. I figured even a 2 year old would understand pictures.
- NetDuino plus - a tiny prototype board, similar to the popular Arduino family but runs the .Net Micro Framework. It comes with only 100KB of memory (to give you an idea how small this is, a typical digital photos use 10 to 50 times more space).
- Hitec Hobby servo – this guy will rotate the clock hand 180 degrees.
- LCD screen - a serial enabled, backlit LCD screen. Only requires power and data lines so super easy to use, even for programmers.
- Acrylic glass – the clock face with decal printed by local photo company.
- Openbeam - a kickstarter project that allows easy construction of various frames with simple reusable aluminium beams, screws and bolts.
- Wifi access point – the NetDuino does not have WiFi built in, so an old Wifi router was re-flashed with dd-wrt and reconfigured to client mode.
The NetDuino board allows you to write the brains of the device in C#. It runs a tiny version of the Microsoft .Net framework called the .Net Micro Framework (NETMF). They implemented a subset of the .Net class libraries but it contains the usual things you’d expect, like the CLR, garbage collection, structured exception handling and so forth.
Since the NetDuino Plus v1 I’m using only has about 64KB of usable memory, it posed some unique challenges. The standard HttpWebRequest and socket implementations were way too big and complex for this micro to handle. Luckily there are some open source, lightweight alternatives and with a bit of research and customization I whipped up a MyGeotab API object that could do the following things directly from the NetDuino:
- Retrieve vehicle name
- Retrieve current location, speed and any exception violations for my vehicle
- Lookup name of exception rule
- Address lookup
It also means the MyGeotab server does the “heavy lifting” for us and we do not have to write complex logic on the small Netduino microprocessor. It simply follows orders based on the more capable processing that happens on the server. For example: MyGeotab will determine if the vehicle is moving inside a zone (geo-fence) of a particular type (for example home zone) and trigger the rule. This event is then picked up by the clock and the arm positioned accordingly.
This video clip shows how the clock boots up and then queries MyGeotab.com for my vehicle location, looks for the relevant exception rules and positions the clock arm. As an added bonus, I query the time over the Internet so it also shows the current time – just like a real clock would.
The MyGeotab clock now has a permanent home in the kitchen, and yes, our 2 year old knows how to use data from MyGeotab.com!
See what I mean? That's kind of cool, isn't it?