Connect up a LinkIt One with a Grove Base shield. Add an LCD-RGB Backlight to any of the I2C connectors. Add also a Grove Touch Sensor to D8. Connect the GPS antenna to the LinkIt One.
Get the source code from Github. Either change the hardcoded home location in the .ino file, or copy the Dorothy_home.h.example to Dorothy_home.h and add the home location there (uncomment the relevant #include line in the .ino!)
Flash the code to the LinkIt One. Enjoy!
I while back I’ve exchanged some of my points earned from posting projects to a MediaTek LinkIt One on the Hackster.io Store. This is my first project with that, trying to do something different than what I can do with the hardware I (literally) amassed so far. Being an expat and traveller, GPS / location sensing is always a timely topic, so set out to build something around that.
It was a long typhoon day when I started experimenting with the LinkIt one, and and as rainy days go – I’ve felt it would be great to know how far am I from home? Of course there’s a GPS in every single smartphone these days, but a dedicated device can still evoke a different feeling. So the idea for Dorothy came about.
The basic idea is connect the GPS module and a Grove LCD RGB Backlight screen, and colour-code the distance from home. The LCD speaks I2C, so can directly connect it up to the I2C socket on the LinkIt One.
The colour coding follows the idea that further away people can feel “blue”, while “green” is in general a positive colour. Thus at large distances Dorothy should be more blue, while near home more green. Since the distance scales over very large values, logarithmic colouring comes handy:
The text is also changing by the scale: at large distances don’t have to be too precise, at short distances nicer tho show more, and at all scales use the 16×2 display as fully as possible.
The end result is something like this:
The distances are calculated using the Great Circle formulas and 6371km as the Earth’s radius. The board has of course enough computing power of course to use the more precise Vincenty formula, and the Math library has all relevant functions at hand.
It’s pretty cool that the LinkIt One comes with the LiPo battery by default, so all of this setup is super portable. Not sure how long the system works on battery, but so far my guess is “definitely more than 30 minutes”, probably at least a few times more than that.
Taking Dorothy on the is a perfect use case, here’s a video too, just for fun – so don’t mind the quality too much, no stabilizer for my camera, and this a moving train after all…
The home location here is hard-coded into the program flashed onto the board, so to change it, one needs a computer to modify and reflash. That’s not very handy, so let’s upgrade things.
One way to make this more useful is having the ability of dropping a marker. Imagine that you are travelling to a new town and want to know during the day how far you are from your lodging. Drop a marker at the lodging when heading out, then later can use the distance as “breadcrumbs” going back (realistically – to augment your map, but still).
For this I needed to add some way to interact with the board – a touch button! The LinkIt One does not have any Grove digital I/O connector (just an I2C and a Serial), so had to add Grove Base Shield into the mix too.
First I’ve tried with a Grove Button, but it seems like some pull-up resistor default setting makes it stuck at “permanently pressed” (as others reported this bug too). I guess there would be some deep software setting that would fix this, but in the meantime I went with a Grove Touch Sensor instead, as it was reported working (it does work!)
Now the logic becomes the following:
After bootup Dorothy looks for GPS satellites. When it finds some, shows the distance from the hard-coded location. Now touching the sensor will save the current location as the home.
Then of course you’ll appear instantly “at home”. The location info is stored on the internal flash, and so it will survive reboot.
If starting the board in “Mass Storage Mode” (by flipping the appropriate switch near the back of the board), then you can find the saved location data in a file called “homelocation.log“. You can also update that file to add a new home location without reflashing (the contents are just decimal longitude & latitude, both followed by a comma, and without any space or new line).
If a location is already saved, touching the sensor will clear the location data and goes back tracking the hard-coded home location (deletes the above mentioned file).
To make sure that it’s not that easy to mess up the location save, Dorothy checks for a touch sensor on start. If there’s no touch sensor then the internal pull-up shows a “HIGH” value, and in that case turn off the sensor monitoring code. That means no home location save until the board is restarted with a touch sensor attached.
The source code for all this is available on Github! It is based on the GPS demo included in the LinkIt One SDK, just heavily modified.