Reliability and magnetic sensors

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!

comments powered by Disqus