back to panic.com

Panic Blog

From the desk of
James
Engineering Dept.

PunchClock: Fun With iBeacons

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.


Posted at 2:24 pm 22 Comments

James, this is fantastic. Bravo!

Did you use physical ibeacons, or let ios devices act as beacons? If real beacons, which ones?
Thanks, perry

Perry, we purchased two dev kits from Estimote. Perhaps we should update the blog post to mention that.

The packaging and build quality of the Estimote beacons is excellent. For development I used a Raspberry Pi with a Bluetooth dongle.

Followup question… with the Estimote beacons are you required to use their software, or will generic iOS apis work? Seems that iBeacon manufacturers often have a custom api, and it seems ominous to bind one’s app to a particular beacon maker.

Perry, there was no software at the time we got ours. They’re generic iBeacons as far as I know. They all have the same UDID with random major/minor values.

Matthew Nielsen

7/8/2014 4:25 PM

Nice stuff — we have something similar in our office done passively. We have Rapberry Pis around the building running our own dashboard software, and they all have bluetooth dongles. The dongles aren’t paired with anything, they just know the bluetooth mac of a particular person’s phone/laptop/etc. You don’t need to be paired to do a “is this mac in range” query, so the RasPis poll their areas periodically looking for devices they know about and if they see that one is in range they record it.

With dashboard machines spread around all 8 stories of our building we can coarsely see where someone is. Since you can’t do signal-strength calculation unless you’re paired the best we can do is figure out that floor and what end of the floor (depending on the strength of the bluetooth dongle).

It’s really great when someone comes over looking for someone else and you can just look at the board and say “Ah, yes, James is in today but he’s up in the 5th floor right now.

Screenshot showing my team all hard at work on our own floor:

https://www.evernote.com/shard/s28/sh/435cc6bc-d4ea-4004-8c31-49028ddf5c42/c83bf75cb69bb201d33a4ee34548dc1a

Matthew, that’s a cool way to do it! PunchClock currently passes in the beacon that it’s closest too so this level of tracking is certainly possible. We’ve joked about creating a map view in the app to show where people are.

I recently did a very similar project at the Xero.com hackday, except it was based on a RPi WiFi hotspot.
The WiFi tracked MAC addresses for registered employees, updating timesheets and providing internet access.

Looks like we had the same idea :D
We got our Estimotes last week, and developed an automatic check in/out application :). We also built an android client (which we didn’t publish yet) using the open source Estimote APIs (in iOS we used the native iOS APIs instead).
I was surprised by the responosiveness of these beacon with iOS 7.1, with 7.0 exiting a region was really slow.

Here’s the blog post with our experience and our simple open source project:
http://andreamazz.github.io/blog/2014/07/01/fun-with-ibeacon/

Cheers

It says “Aaron”, but we all know that’s Steve Zizzou.

Brandon Medenwald

7/9/2014 11:19 AM

Over a year ago, we shipped iBeacon support in Simple In/Out, a digital in/out board. We’ve had GeoFence support since 2011, it’s our most popular feature (I also added Panic StatusBoard support some time ago as well, BTW).

I’d recommend anyone who’s interested check us out at simpleinout.com. We support the web, iOS, Android and Windows 8 desktop with more features coming all the time.

What hardware are you using for your actual ibeacons? Estimotes?

I suggest checking out http://geofancy.com. They’re a free service with a free app that lets you set up geofences and ibeacons to track your favorite locations.

This is pretty cool! Do you think it would be possible to include Siri / voice recognition on the app?

/* Taps the screen */

You: “Computer, locate Cabel Sasser”
Computer: “Cabel Sasser is not on board the Enterprise”
You: “Explain”
Computer: “All Enterprise personnel including the Captain have been evacuated”

:P

Quick question. iBeacons can tell when you enter or leave an area… but this can’t be used to know if someone is coming or going (you could approach one and head back into the office and get your status out of sync)… so I imagine this is the reason to use geoLocation. What exactly are the beacons used for?

John Smith

7/29/2014 10:34 AM

I just found this, really good. My son is working on a similar project tintapatron vásárlás will soon be finished.

This is nice, congrats, it looks good. We have the network in place now, but on different layers
Think about BigData and exchanges connected to beacons
We’ll post this as a case on our iBeacon test blog too, if you agree
Future is gonna be cool!

Does it work reliable with day to day use? Are there any lessons learned by using iBeacons for that use case or would you fully recommend this type of technology? It would be nice to hear some insights so that other developers could learn from your experience.

It would be awesome if you just roll in support for this to status board. We will likely run status board in our office on an iPad. It’d be a nice integration if you could just make that iPad running status board into the ibeacon that is ultimately tracking everyone.

I second adding this directly to Status Board!
I am not a App Dev, so most of this was over my head, but this is something that we’ve been dying to implement for years in some form at my office!
If you figured out how to commercialize it, I would buy it in a heartbeat! (or if you have any Devs that could configure it for my office, I’d pay for that too ;) )

By the way!
Are those custom avatars? or is there somewhere I can make one of those? :)
:)

Panic Inc.

Do: Be awesome, and use your real address.
Do not: Be negative, or post tech support q's. Email those!

pencil