Wednesday 25 September 2013

101 uses for an old smartphone, #1

I'm about to install a freezer in the barn, which is half a mile from my home. How am I going to know if the power fails or the internal temperature rises?

Various companies sell ultra-low power temperature sensors which communicate via Bluetooth, for example the TI SensorTag (which actually does far more, but it's temperature I'm interested in just now)

It is said to run for a year on one button cell.

I have an old Android phone - in fact, an original Google G1 - that is sitting doing nothing. An Android app can detect whether the device is connected to AC power by registering a receiver for the intent ACTION_BATTERY_CHANGED.

Texas Instruments offer sample source code for an app which can read data from the bluetooth sensor (although needless to say their Linux installer doesn't bloody well work!)

So, here is the specification for an app:

  • It runs as a service, from startup;
  • It checks for the presence of the bluetooth sensor, and if it doesn't detect it, sends a message;
  • It registers a receiver for power state events, and if the mains power goes off, it sends a message;
  • It periodically (e.g. every ten minutes, but configurable) reads temperature from the sensor. If it can't communicate with the sensor or the temperature is out of the configured range, it sends a message;
  • When it sends a message, it does so by SMS, email or Twitter (configurably), to a configured number/address

All you do then is drop the sensor in the freezer, plug the phone's charger into a wall socket on the same circuit as the freezer, ensure the phone has a valid SIM with enough credit to send texts, and leave the phone switched on.


NOTE: I haven't yet written this app. I may never write this app. But then again, I may...

No comments:

Post a Comment