Building A Home Security Recipe With a Beagle Bone, the Cloud9 IDE and the Apigee Zetta API
Last week, I touched on a few of the companies who provide API services for gluing together the various parts of an Internet of Things (IoT) infrastructure, in my “The Different Flavors of IoT APIs” piece. One of the companies I covered was Apigee, maker of the Zetta API platform.
This week I took a little closer look at Zetta, reviewing their “Home Security” recipe kit. This collection of hardware and software introduces the Zetta API platform and leads developers through a tutorial on building a basic security node using a Beagle Bone Black, some sensors, and a dash of API magic.
The kit, which lists for about $84 is available from Sparkfun. It consists of a Beagle Bone Black micro-controller board, jumper wires, some resistors, an electret microphone, a buzzer, an LED, and a breadboard. An optional passive infrared sensor was also included in my box.
The “Home Security” recipe led me through quite a few important concepts, such as:
- How to use the Cloud9 IDE for coding on the Beagle Bone Black machine.
- How to connect and interact with data from sensors.
- How to link together functions to do something useful.
The tutorial is well organized and easy to follow. All work was carried out on my local LAN from my old Xubuntu 14.04 notebook to the Beagle Bone. I used a wired Ethernet connection to the Beagle Bone and WiFi to my Linux notebook.
The Cloud9 IDE gives you a cool, Web-based interface to edit files and run programs, on the Beagle Bone. You could also ssh into the Beagle Bone and edit the files in vi or nano.
The main script file I used was named server.js and was located in the /var/lib/cloud9/zetta-security-system directory. Here’s an outline of the process for setting up the first task in the tutorial, connecting a buzzer.
- Hook up the buzzer to the Beagle Bone Black board.
- Retrieve the buzzer driver from the Zetta library of current APIs.
- Insert code to control the buzzer, in the server.js script file.
- Start the server node.
- Test the buzzer on the Zetta Browser.
The tutorial progressed from making the buzzer beep through detecting sounds with the little microphone, to linking the buzzer and microphone together in a little application. Whenever the microphone picked up a sound above a certain level, it would start beeping the buzzer. The tutorial finished up with having me build my own driver for an LED. Pretty much everything worked on the first try and I’d say the documentation was excellent.
Using existing drivers for the various sensors is pretty straightforward, when putting together your application. For example, the buzzer script consists of initialization of the driver, through a variable, assigning the driver (buzzer) to a particular pin on the Beagle Bone board, and finally listening on a specific port for a query or outputting of data. The Zetta library of drivers includes a buzzer, an LED, the microphone, and several other sensor/output devices. No doubt it will grow over time as more people beginning using Zetta, in their projects.
I only had a couple of challenges.
First, the microphone needed a header or three wires soldered in, before it could be plugged into the breadboard. No big deal. Likewise the passive infrared sensor had a plastic mini-connector on the end of the wires, so I had to use a three-part header to plug it into the breadboard. Again, a minor thing although if you don’t have a parts bin, you might have to make a run to the parts store or improvise.
Another area that caused me a little trouble was forgetting to change into the zetta-security-system directory before downloading a driver and starting the server. I received an error saying it couldn’t find the appropriate modules.
Be sure to kill the server node with CTRL-C before starting up a new one. You can also do a ps -ax on the Cloud9 command line, find the appropriate server node process number and then kill it.
I wrapped up the tutorial by adding the optional passive infrared sensor to detect motion, following the normal download the driver, add the application code to the server.js file, start the server, and view on the Zetta browser process cycle.
The idea of using standardized “drivers” for devices makes sense as both the complexity of applications and the computing hardware increases. The Zetta platform aims to make it easy to use sensors in your application and not have to worry much about how the device interacts with the computing hardware interface.
Apigee is a sponsor of The New Stack.