Making machines talk
A NetDuino board, servo, LCD screen, construction kit, and the MyGeotab API for telematics data are assembled to make a handy location clock!
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 two year old understand this technology?
Sometimes a single purpose device integrates better into our lives. An idea was born. It took a few late nights of tinkering and coding, but eventually I was able 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 (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 two year old would understand pictures.
The basic idea is illustrated below:
- 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.
- Wi-Fi 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 build took about 5 or 6 hours spread over a few evenings, including a late night raid of the kids’ lego to find a suitable hour hand for the clock. A few pictures should save a lot of words here.
Coding 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
To make the system flexible, the NetDuino receives live updates from MyGeotab for my vehicle and decide where to position the arm based on exception rules. If an Exception Rule is triggered – the rule name is checked to see if it matches certain criteria:
- If the name starts with special sequence “IM@” it means “this is for me!”
- The second part will be displayed on the LCD screen (Home)
- The third part (105) indicates the angle for the clock arm in degrees
Any of the MyGeotab rule conditions can be used to determine when the clock arm should move. This means we have a lot of flexibility and can change the behavior of the clock by simply defining new rules in MyGeotab!
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!
Watch the YouTube Video
If you liked this post, let us know!
Geotab's blog posts are intended to provide information and encourage discussion on topics of interest to the telematics community at large. Geotab is not providing technical, professional or legal advice through these blog posts. While every effort has been made to ensure the information in this blog post is timely and accurate, errors and omissions may occur, and the information presented here may become out-of-date with the passage of time.
Geotab | Blog
Sign up for monthly news and tips from our award-winning fleet management blog. You can unsubscribe at any time.