Dorothy – a project for those away from home

I while back I’ve exchanged some of my points earned from posting projects to a MediaTek LinkIt One on the 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.

Basic version: where are are you?

Dorothy - Long way from home
Dorothy – Long way from home

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.

Dorothy - version 1
Dorothy – version 1

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:

  • Below a minimum distance 100m be totally green, that is (0, 255, 0) in RGB
  • Above a maximum distance 10,000km be all blue
  • Scale between such that the blue value us floor[log10(distance in meters) – log10(100)]*51.5, and the green value is just 255 – blue.
    • For example, at 1800m the blue = 64 = floor((3.2552 – 2)*51.5),
    • then green = 191 = 255 – 64

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:

LCD color change by distance
LCD color change by distance

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.

Dorothy - On the train
Dorothy – On the train

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.

Level up: leave a marker

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.

Dorothy - version 2
Dorothy – version 2

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.

Setting a new home location
Setting a new home location

Then of course you’ll appear instantly “at home”. The location info is stored on the internal flash, and so it will survive reboot.

Dorothy - near home
Dorothy – near home

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).

Back to flashed home location
Back to flashed home location

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.


It was an interesting first project with this board. Probably Dorothy will stop here, most other changes I can think of are more “complications” than “improvements”, so probably not worth doing at this stage. I’d love to hear suggestions, though!

For the board so far my impression is quite positive, even though there are some difficult issues remaining:

  • there’s no Linux support for the SDK (only Windows and Mac), though I guess it’s more of a choice than a fundamental problem. The only parts of the SDK that is probably not available for Linux is the firmware flasher – which does not work for me on Windows anyways. The IDE is based on Arduino so that should be fine, the compiler is gcc (I think) so that’s fine too….
  • the SDK documentation is quite patchy. Can’t use the API docs by themselves as not everything is explained. For many things I have to look at the examples directly, and even then it’s more trial & error
  • the hardware bugs like the over-eager pull-up are annoying (and harder to debug than software bugs)

But there are other stuff that makes me want to try more things out:

  • onboard SD card is cool (even if cannot be used in the same time as the internal flash)
  • onboard audio, WiFi, Bluetooth are also very cool
  • the battery is very useful, will try to measure how long it can last and build some projects around that.

From LinkIt One’s messaging I see they want it to be the ultimate prototyping platform for Wearables and IoT. I don’t think it’s the ultimate one, but definitely a very handy tool.

And this was a fun project. My homesickness has abated a bit too, which is nice. :)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.