Author Archive

PunchClock: Fun With iBeacons

Tuesday, July 8th, 2014

PunchClockSometimes at Panic we build internal stuff that never sees the light of the outside world. This is one of those projects: an automatic in/out tracker for the Panic Team.

OK, sure, there’s not that many people that work here so it’s not a huge issue for our team, but it still seemed like something interesting to try. I originally hacked together an in/out tracker that used a combination of SNMP, ARP table lookups, and plain old port scanning to figure out who was theoretically “in”. It wasn’t so reliable and was eventually removed from our Status Board. What I didn’t know was that Apple would soon deliver a solution to our (not-so) mission-critical problem.

With the arrival of iBeacons in iOS 7, Apple was clearly moving into retail and public spaces in a whole new way. It was no longer enough to have an app for the store you are shopping in — the app could now react to your location within the store. iBeacons themselves typically do little more than broadcast an ID to notify your device that you’re near them. The idea is to spread these relatively cheap, dumb beacons around a space and then let iOS and a cloud service figure out what content the visitor should see.

Going further, iOS 8 adds a button to the lock screen when you’re in an area registered with Apple to provide indoor location tracking. That button launches the relevant app if you have it installed or takes you to the App Store if you don’t. Cool stuff.

With this new technology in-hand, it wasn’t too long before I put together a brand new office In/Out tracker called PunchClock. It uses a combination of a geo-fence and iBeacon tracking, plus a simple Sinatra backend hosted at Heroku. The part that took the longest to fine-tune was figuring out the right combination of polling to provide good location information without draining the battery.

Once we had reliable In/Out data, I thought it would be interesting to allow you to be notified (in a hopefully non-creepy way) the moment someone entered or left the office. The final notable feature of PunchClock is the ability to send push messages to everyone marked as “In” — mainly in case you get locked out of the office, or locked in the bathroom. Neven did some nice UI, Cabel made a couple of tiny notification sounds, and the app was complete.

While Apple’s iBeacon technology continues to be rolled out in big box stores and sports stadiums, there’s no reason you can’t put it to use in your own home or office now.

We’re making PunchClock available on Github so you can create your own In/Out tracker. The backend provides JSON data to the app as well as a DIY panel for Status Board.

To be honest, you’re going to have to be pretty technically-capable to set up your own instance of PunchClock. This isn’t a shipping retail product, and it’s not for the faint of heart. But if you’re a coder and you’re ready for a fun night of hacking, we’d love to see what you do with it. We’ll try to do our best to explain the process in the README for the app and backend.

PunchClock was fun for us, and we hope it’s fun for you.