I spent some time trying to customize MapMarkers in Google Maps Android SDK, I hope this guide is useful if you're trying to integrate FontAwesome's icons in your app's map layout. Android Iconfiy is a great library that provides FontAwesome icons in Android, so we'll use that as our source of icons.

I've been teaching an embedded systems course in PUC's CS department for a while, where we use the msp430f5529 experimenter board. It really serves the purpose of learning the bare bones of embedded systems, but unfortunately they tend to be unreliable and sometimes it gets to EE-oriented.

Part of the perks of teaching at a university is that you can apply to university programs and get to play with cool stuff. In advance. For free. So I applied to the Intel Galileo university program, and they kindly donated 20 boards we'll use this semester.

Which one should I buy?

It depends:

Do you want to operate this with a small battery? Then your only choice is the Arduino. Also consider taking a look at the very cheap msp430 launchpads.

Are you getting started with programming? Then the Rapberry Pi is a good choice. Its community is huge and using google as a problem solver will come in handy. The galileo is also a good choice, but expect to have less support from the community.

Already know arduino but want some more? The Galileo is an excellent choice, since you'll be using almost the same IDE and language. If you want to dive into Linux then the Galileo is also useful.

Are you used to fighting with linux setting ups? The BeagleBone Black will is a good option. Although you might feel a bit short on expansion board alternatives.

While I work on a Go backend for RunHedgie, I'm still hosting the database locally on a Raspberry Pi. That requires me to be at the office to play with the data, which is sub-optimal.

So I'd like to make a database backup each day and upload it to AWS's S3 storage service. That way I can download a copy of the data and use it in my computer whenever I want, not depending from an external CPU or server.

mktemp is a great utility to generate random temporary files. Fixed-value temporary files are usually a bad option.

If you're in Linux you should take a look at ionice. It tells the SQL dump program to go easy on OS I/O operations, lowering disk and CPU usage (but making your backups a bit longer). I prefer using the -c2 options, which makes the "best effort" to back it up as quickly and seemlessly as possible.

Unfortunately, your activity may have been dismissed between steps 1 and 2. So when you actually try to show the dialog, you'll get a nice exception:

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
FragmentManager.java:1343 in "android.support.v4.app.FragmentManagerImpl.checkStateLoss"
FragmentManager.java:1361 in "android.support.v4.app.FragmentManagerImpl.enqueueAction"
BackStackRecord.java:595 in "android.support.v4.app.BackStackRecord.commitInternal"
BackStackRecord.java:574 in "android.support.v4.app.BackStackRecord.commit"
DialogFragment.java:127 in "android.support.v4.app.DialogFragment.show"

Trying to crash the activity

Now we would like to test if this is working. An easy way to pause your activity can be done calling a new activity or app with adb. For example, to open the browser you can run the following command from the terminal:

RunHedgie suffered an outage of about 3 days without tweeting. There were two reasons for this which I'll explain in the following lines.

Don't forget to add a reboot strategy for your embedded system

In the first days of RunHedgie's rollout I'd come back from the office, connect via SSH to the Raspberry Pi that receives the packets from the wireless node which senses the wheel counts, change a few stuff and re-run the program that manages it all.

The thing is that one day we had a power outage, the system rebooted and I never noticed that the internal server was not running, so there were no counts and even no tweeting at all.

Solving it is quite simple, just add a command in your /etc/rc.local file and that will be executed on startup.

Reed Switches are unreliable

The counting system consists of a magnet, a Reed Switch and a microcontroller that is interrupted whenever an edge ocurrs (with a fraction of a second for debouncing). The effectiveness of this depends heavily on the distance between the magnet and the switch, the angle with which the switch is placed and how centered the magnet is with respect to the switch. That leaves us with very little margin.

Edit: @rbasoalto pointed out an excelent piece on Reed Switches, which confirms my empirical observations. A very nice illustrative explanation is included in the paper, which I'll show you here:

That's an image of a reed switch along with the magnetic field generated by a permanent magnet. As you can see, the switch's state will depend on the angle and how centered it is.

Hedgehogs are a bit filthy, they 'poop' in their wheels, so they have to be cleaned up frequently. That's why I made the whole system to be easily detachable so that it can be cleaned easily. One time after cleaning it I placed the switch a bit to far away from the magnet, resulting in no counts that night.

I've considered using a Hall Efect sensor. They seem to be much more reliable, but on the downside they need to be powered continously, since I need to detect edges, not only states. And at 3 mA of current that would drain the battery pretty quickly.

Anyways, I ordered a couple of them along with an Infrared Camera so that you can watch him run all night. They'll be arriving in a couple of weeks, so stay tuned!

But what if we need to combine multiple array values into a single calculation? I figured that a JSON-defined reading would be a good way to do this. So, let's say we have a 32-bit value divided in two different places:

array[2]: Higher part of counter (16-bit)

array[3]: Lower part of counter (16-bit)

We can define a formula that combines both:

formula = {'2': "x << 16", '3': "x"}

and then add both entries:

result_arr = []
for key, value in formula:
# Get the value in the array
x = arr[int(key)]
# Parse the formula contained in the JSON
code = parser.expr(value).compile()
# Add the result to the list of results
result_arr = result_arr + [eval(code)]
# Add all results
result = sum(result_arr)

there, we have a simple yet generic system to combine readings into meaningful values using any formula that we want.