How Spark core helped us make a Wi-Fi keylock with e-paper keypad for our office.
Visionect, 2 Jun 2014
We wanted to see if current crop of Internet Of Things gadgets is ready for mainstream. We ordered a Spark Core module from spark.io to see how fast can one create a Wi-Fi enabled keylock that could open our front door.
Spark Core is a small WiFi enabled board communications module with a set of GPIO interfaces that can be used to hook up analog and digital inputs. It connects to a cloud service trough which you access and program the board.
We regularly hear about fridges reporting that they’re empty, plants tweeting about lack of water or even huge buttons just waiting to be pressed. This is the Internet of Things (IoT) revolution that is unfolding while you’re reading this post. More and more devices and physical objects get equipped with network connectivity out of the box.
Companies are struggling to get in the driving seat with a platform that will power it all. For Internet of Things devices to become really ubiquitous they need to be cheap, very small and use little power. They also need to be super simple to develop so that every developer can jump on the IoT train.
So what is the state of Internet of Things today? How good have the building blocks of IoT become? We tested this by building our own e-paper keylock for our office front door with an off the shelf IoT controller and our V Tablet device. The result was a nice Lockitron clone with a wall mounted keypad.
Based on our experience, we think that the wait for Internet of Things is over. It’s already here.
Internet of Things controller
First we need a small, cheap and low power embedded IoT controller – this is the board that will drive the complete setup. We’ve checked a couple of different solutions (good examples include Electric Imp, Pinoccio) that fit the requirements and in the end decided to go with the awesome Spark Core.
Spark Core is a small WiFi enabled board communications module (similar to other contenders) with a set of GPIO interfaces that can be used to hook up analog and digital inputs. It connects to a cloud service trough which you access and program the board.
We needed a small, cheap and low power embedded IoT controller and Spark Core proved perfect.
We chose Spark Core over others due to small size and affordable price. Wide programming language support (you can do even assembly if you want) is what finally won us over, but that doesn’t mean you have to develop anything – you can access device IO ports via the restful API that they provide. Best of all Spark Core uses the same awesome ARM Cortex M3 micro controller from STMicroelectronics that we used before, so we knew what we’re getting into.
Spark Core in practice
We always had a bit of an issue with our front door. It can only be opened with a press of a button which is located at the door. People regularly get up just to open the door. There is a bunch of off the shelf wireless door locks to solve the issue but we wanted to see just how hard would it be to develop our own from the scratch.
Smallish package from Spark.io contained the Spark Core board and a breadboard for prototyping (great idea!). First things first, we connected it up to our Wi-Fi (you configure the settings with a phone app). The demo app worked as we could turn on a LED that we connected to the breadboard.
Our door is opened by a push button that is connected to access control system deployed in our office. The push button is a switch in the simplest form possible, with two lines running to the control box. Our Spark Core will need to connect the two lines together.
We installed a push button controller connected to the access control system under our office reception desk.
We scoured our electronic component stash and found a relay switch. The relay was connected to the Spark Core using three IO pins to prevent any issues with current (maximum current load is limited) and with a diode in parallel to prevent spikes rushing back from the relay coil after it got turned off.
Two control cables that run to the door push button got split and Spark Core setup was connected in parallel. That was it for hardware part.
Firmware “development”
Firmware is uploaded to the Spark Core using their cloud service. You get a simple online editor with a couple of examples ready. We took the LED control example and just changed it to control three LEDs. That was literally it. For anything more complex check out their online docs.
A simple Spark Core online editor.
Click “Flash” in the upper left corner and code gets deployed on your Spark Cores. To execute we do a HTTP get request to the correct URL. In our case we could open the door by running (in terminal):
me@my_computer:~# curl https://api.spark.io/v1/devices/SPARK_UUID/open_door -d access_token=YOUR_ACCESS_TOKEN
That’s all nice and good, but not very user friendly for the non-haxor people in our office. With a help of a web app we wrapped that call into a bookmarklet that team members simply drop into their browsers.
‘Open the door’ bookmarklet in our web browsers.
Adding an e-paper keypad
We built a web connected door lock in less than a day for ~35 USD in parts. But since we do have a bunch of Wi-Fi enabled e-paper devices in our office we didn’t stop there – what if we add a proper entry keypad to our office doors?
With the help of our jQuery keypad plugin and two lines of Javascript (check password, open keylock) we had the keypad entry interface done. The V Tablet device got configured with the right URL and voila:
A full blown e-paper keypad, which can be mounted on the wall without any power infrastructure.
What does this mean?
Let’s recap. It took us less than a day to create a new keylock which can be controlled from the web and additional 15 minutes to add an e-paper keypad. And except for the lack of proper casing for our Spark Core, there is nothing that screams prototype about it – we’re using the setup daily.
Internet of Things is very real. The tools that are available right now make it super easy for anybody with basic programming and hardware skills to create their own smart gadget. This means that there will be a huge influx of new gadgets that will be connected, because frankly, there is no reason why they wouldn’t be connected. Today we’re laughing at the notion of connected refrigerators, while tomorrow we won’t know how we survived without them.
This also means that investing into connected and open solutions now will pay dividends later on. We were able to use our own V Tablet device and tap into IoT world just because it’s a connected Web device based on open standards. It’s time we all think about our physical infrastructure and the devices we plan to deploy so that we’re ready for the Internet of things future that’s just around the corner.