Electric Imp

Little devil: Electric Imp is an Internet of Things Wi-Fi PC-ON-AN-SD-CARD

The card micro that makes connecting projects to the cloud easy

Secure remote control for conventional and virtual desktops

Blink me

The phone’s favoured wireless network is already listed for the Imp to use, but you can enter others, along with their passwords. I had to do this: my main WLAN, presented by the app, sits in the 5GHz band, a region the Imp’s 2.4GHz radio can’t access. The Imp currently remembers only one wireless network, but Electric Imp developer relations chief, Matt Haines, tells me upcoming ImpOS upgrades may allow multiple networks to be recorded and add the ability to hop onto free hotspots out in the wild.

Whether you use the network the phone already knows about or key in the details of another one, you next hold the phone’s screen up against a tiny window on the end of the Imp, and the SSID and associated WPA key are literally flashed across. Audio tones tell you when to put screen to card and take it away again. If all’s well, the card will now connect to the internet and Electric Imp’s servers, download and apply any firmware updates.

Now it’s ready to use.

Electric Imp app

Electric Imp’s app: choose or enter your WLAN’s details (left) then prepare to flash the data to the Imp (right)

Programming the Imp is carried out in an online IDE. Imp uses an object-oriented scripting language called Squirrel to code two event-driven programs that run in parallel: one in the Imp, the other on Electric Imp’s servers. The latter program is called an “Agent” and it provides a web-based (HTTPS) mechanism for routing control commands and data over the internet to your Imp. Electric Imp manages the security and handles accessing Imps across routers’ NAT tables and firewalls, but of course you’ll need to sign up for a free account to make use of it.

Each Agent is assigned a unique web address which can then be embedded in a local HTML page presented by a browser or coded into a mobile app and accessed using Android and iOS stock URL handlers. You can pass named parameters tacked onto the end of the URL just as you would if you were scripting basic browser-server interaction, and code the Agent to parse those parameters when it’s passed an inbound request.

One response the Agent can make is to fire off a message to the device. The second program, running on the Imp, in turn reacts to this message by calling functions that can examine data sent by the Agent and perform actions accordingly, typically by sending signals out through the GPIO ports, the three-channel UART, two-channel I2C and two-channel SPI buses, either to control another device or to read data from it.

The Imp code can then send a message back to the Agent, to which it can respond, perhaps by informing the browser or app in front of the user, or to send further messages back to the device. You might, for instance, want to perform particularly weighty calculations on the back end to help keep the device’s power consumption as low as possible. But the Imp has processing resources to apply logic to the data coming in off through the GPIO.

Electric Imp IDE

You code a Model’s Agents and Imps in an online IDE
Click for larger image

It’s not hard to imagine a typical usage scenario. A mobile app asks for, receives and displays the temperature in your living room, from the Imp, then allows you to turn the central heating on if it’s getting a bit nippy. A more advanced version might detect that you’ve left work for home, that it’s the middle of winter and so interrogate an online weather service to see if it had better get the boiler fired up on your behalf.

The big question, of course, is whether the intelligence to handle this goes in the device - via the Imp, say - or resides in the app. By giving the Imp compute capability, it can also run code that doesn’t need user interaction.

Electric Imp’s IDE presents Agent code side by side with the Device code so it’s easy to look back and forth between them to ensure, say, you’ve got your message parameters applied consistently. You can have the IDE error-check the code without beaming it to the Imp, or upload and run Agent code and device code immediately.

Together Agent code and device code form what Electric Imp calls a “Model”. Only one Model can be applied to an Imp at once, and Electric Imp could improve how you work on multiple Models in parallel. As it stands, a Model that’s not currently associated with an Imp can’t be edited. Multiple Imps can be assigned the same Model.

Electric Imp

Breadboarded, powered and connected

The IDE doesn’t compile code: ImpOS incorporates a Squirrel interpreter. There’s clearly a small memory penalty involved in storing tokenised source code on the device rather than machine code, admits Haines, but the quid pro quo is that it makes it almost impossible to crash the hardware: the interpreter should be able to catch and stop any code before it takes out the system. On a lightweight embedded device in particular, compiled bare-metal code may find it has the freedom to cause more havoc.

The Squirrel language itself is not too hard to get to grips with if you’ve programmed C or Python before, and you’re doing relatively simple stuff. More complex code has a steeper learning curve. Being interpreted, it has one or two weak spots, bit-level maths operations in particular. The language has been used in a number of video games as a scripting language, but its use isn’t widespread. The available documentation is aimed more at the computer scientist than at the amateur programmer.

Squirrel is available under the open source MIT licence, but at this stage only its creator, Alberto Demichelis, is working on its future development and expansion.

Internet Security Threat Report 2014

More from The Register

next story
Nexus 7 fandroids tell of salty taste after sucking on Google's Lollipop
Web giant looking into why version 5.0 of Android is crippling older slabs
Be real, Apple: In-app goodie grab games AREN'T FREE – EU
Cupertino stands down after Euro legal threats
Download alert: Nearly ALL top 100 Android, iOS paid apps hacked
Attack of the Clones? Yeah, but much, much scarier – report
SLURP! Flick your TONGUE around our LOLLIPOP – Google
Android 5 is coming – IF you're lucky enough to have the right gadget
Microsoft: Your Linux Docker containers are now OURS to command
New tool lets admins wrangle Linux apps from Windows
Bada-Bing! Mozilla flips Firefox to YAHOO! for search
Microsoft system will be the default for browser in US until 2020
prev story


Choosing cloud Backup services
Demystify how you can address your data protection needs in your small- to medium-sized business and select the best online backup service to meet your needs.
Forging a new future with identity relationship management
Learn about ForgeRock's next generation IRM platform and how it is designed to empower CEOS's and enterprises to engage with consumers.
High Performance for All
While HPC is not new, it has traditionally been seen as a specialist area – is it now geared up to meet more mainstream requirements?
Website security in corporate America
Find out how you rank among other IT managers testing your website's vulnerabilities.
Intelligent flash storage arrays
Tegile Intelligent Storage Arrays with IntelliFlash helps IT boost storage utilization and effciency while delivering unmatched storage savings and performance.