In my last post, I explored alarm monitoring using the Raspberry Pi and Arduino. I thought I’d give the Electric Imp a try as well. The Electric Imp is a WiFi module and Cortex-M3 processor built into an SD card form factor and available on Sparkfun for $30. It needs a few extra bits like an ID chip to function but I picked up an Electric Imp Shield on Sparkfun to make it easy. To configure the Imp, I put the shield on top of an Arduino Uno and powered up the Uno off USB. This powered the Imp which begins flashing it’s LED red. I had downloaded the Electric Imp app for my Android tablet. To make it easy, I’d set up the WiFi access I wanted to share with the Imp first on my tablet. I chose to use my guest network — outside my firewall to better ensure that the Imp only called it’s home base on the net. When you launch the Imp app, you’ll first have to put in your account and password that you’ve already set up on the Electric Imp site. Then, it gives you a choice of using your current WiFi setting or one you key in and lets you beam it to the Imp by flashing the mobile devices’s screen. You should transmit to it just after power up when it’s flashing red. You hold the end of the card toward the screen and start transmitting from the mobile device. If all goes well, you should get green confirmation flashes. It may also update its firmware at this point if this is the first time you’ve connected to the net.
The photo below shows the Arduino, Electric Imp Shield, and my “Alarm Monitoring Shield” on top. In the photo, it’s being powered by the USB cable. Considering the red wire on the alarm bus is 12V, it would also be straight-forward to add a step down converter to the Alarm Shield to power the stack from the alarm bus itself.
The Arduino monitoring routine given in my original post needed only a minor tweak — to send a copy of the data via software serial on pin 9. Here’s a link to the new Alarm.ino version. I then translated the Python program I’d been running on the Raspberry Pi to Electric Imp’s Squirrel language. The translation was fairly straight-forward and only minor changes needed to be made. Here’s a copy of Alarm.nut (yes, squirrel programs are exported to nut files). Just as we used the Raspberry Pi to offload interpretation of the alarm state changes from the Arduino, the Electric Imp and it’s embedded processor do the same thing. To get the code onto your Imp, you can upload the nut file onto their site and configure your Imp to use that program (or edit it directly on the web). The most reliable way to get the Imp to update its software (especially if it’s busy running a previous version of your code), is either to power cycle the board or to pop out and pop in the Imp from the SD socket. The Imp will quickly update its code and start running. Imp’s web-based planner interface, shown below, includes a rectangular box for the Imp. The current program “Alarm State” is shown at the top and any messages transmitted to the server with the server.show command are displayed below (e.g. “ALL,INSTANT,ON”). When connected with my live system, I was impressed that the state change and display was nearly instantaneous (despite their warnings that their servers were on the West Coast and I’m on the East Coast). The result could also be sent to other destinations through HTTP by modifying the squirrel routines to output the state and connecting the output of the Imp box with the input of an appropriately configured HTTP Request box.