The Electric Imp guys had very kindly passed Adrian a handful of Imps to evaluate. I missed the opportunity to get Shaun Myhill to walk me through using it at the IoT Howduino at DoES, but he and Antony McLoughlin worked together to create the Dirty Win-imp. I finally got my grubby hands on them yesterday to wire one up to an accelerometer.
While the experience was quite frustrating, and it felt like the product just wasn't "ready" yet, the hardware and concept are really cute, and if all the teething problems get sorted out, it's a genuinely useful idea, and rather different than developing on Arduino.
First of all, a disclaimer: this experience represents me charging into the world of Electric Imp half-cocked, without reading everything upfront. I may have missed obvious clues or explicit documentation due to my own inattention!
All the smarts of the Imp, as well as its wifi connectivity, are located in the SD card shaped microcontroller. But to get it to do anything, it has to be plugged into a board (an "Impee") which provides power, pins, and so on. The SD form factor is very cute and feels robust. The card doesn't actually work as an SD card, which is a bit odd, but using an existing form means they can take advantage of cheap components designed for it. The Impee I'm using exposes 6 GPIO pins, which isn't anywhere near as many as an Arduino, but this really isn't a problem, as we'll see.
The Impee can get power either by soldering a connection to a battery, or via USB. I connected via USB, but this only powers the device, and doesn't let you communicate to it, as it only speaks via wifi... this means you have to program it without any means to input your wifi settings ;-) The Imp team have solved this bootstrapping problem using a very clever idea called "Blinkup". They have smartphone apps for iPhone and Android which emit alternating white and black screens in a code which is then read by the Imp's light-sensor. While this is very nice (and it's so appropriate to be literally "flashing" your microcontroller), the implementation needs a little polish.
First problem: you need an iPhone or (recent-ish) Android. You're stuck if you are still using a dumb old Nokia, like both me and Adrian... Bafflingly there isn't a way of using a computer screen, such as the one on my laptop. I eventually borrowed an iPhone from John McKerrell and flashed the chip with the DoES wifi details.
After it rather unimpressively failed to do anything obvious, I looked up the diagnostics for the Imp's flashing LEDs, and here's the next problem: the documentation is fragmented and poor. The front- page of electricimp.com is nicely designed but even the "for developers" page doesn't link to the wiki. Navigating between the wiki and the "Planner" app is also confusing. Eventually I found a page on status codes and determined that it wasn't connecting to the wifi. Checking the iPhone app, it turns out though it worked out which network I was connected to, it didn't pass across the password, so you are supposed to type it in yourself. Once I'd done that, the flashing process worked very nicely.
With that done, the imp appears in my planner, and I am prompted to choose a firmware. I choose the blank firmware. You can edit the code in a rather pretty online code editor. However, the way I'd chosen the firmware, it was opened read-only... I really don't understand why this wasn't an editable copy. Eventually I figured out how to Add Node, and cargo culted some code from the examples. There aren't very many examples yet, but that will only get better as and when more people start contributing.
The Imp uses a language called Squirrel This is a
dynamic scripting language, but with a syntax derived from C. That's handy to
know, because it's sparsely documented and impossible to google, because
Squirrel is such an overloaded term. When I searched for "Squirrel Language",
my top hit was for the language of squirrels in the massively multiplayer
computer game Dofus. (In case you're wondering, the squirrel language "is
related to English, but with dominating use of letters 'i' and 'k'" --
Similarly, searching for terms like
Squirrel include module or
trigonometry will almost always give you completely useless results. The
documentation itself is correct but insufficient. The
atan2 function belongs
math library, but how do you use this library? It turns out that you
#include <math> like in C, but don't need to, because it's included
by default. However you have to preface the function with the library name, so
you call it like
math.atan2(). You can guess these things if you know C-like
languages, but really it would be nice not to have to.
Pushing the code is a joy. You simply save the code, and reboot the Imp (by
ejecting it and plugging it back into its impee). The Imp recognizes which
Impee it is in, and (if it can connect to the internet) downloads the new code
automatically. At this point, you get any error messages: this shows how
dynamic the Squirrel language is... even though the process is quite fast, I
would have liked some kind of pre-flight checks, but never mind. The error
messages are shown in the editor window, as are messages output by
server.show() -- I liked this a lot, as it made debugging so much easier than
on Arduino, where you have to use the serial console, and there is no automatic
output about runtime errors. Also, because the language is more dynamic, you
can easily coerce integers into strings, e.g.
server.show(x + "," + y + "," + z);
which also makes logging and debugging relatively pleasant.
The output of
server.show() is also sent to the planner screen, where it's
shown on the "node" box for the Impee. When you've only got the one Impee
running, this isn't especially impressive, but I can really imagine this
being useful once you develop an ecosystem of them.
Also bear in mind that the Impees don't have to be on the same network: this makes it a plausible implementation infrastructure for products such as the Good Night Lamp, or for monitoring systems over a number of locations. This is of course because the Imps don't mesh with each other, but rather with the central server. This is of course a possible counterindication for using them: do you trust them with your sourcecode? Do you trust them to continue existing? If they close, will it be possible to reconfigure the Imps to point at another provider who can host the code? If you get big, and want to configure the planning infrastructure more then the Electric Imp team want to facilitate for their general customers, will you be able to host and develop the infrastructure for yourself?
These days we are quite happy to host much of our social and business communication and storage infrastructure online with, so the idea of running the Imp code online isn't actually all that much of a stretch. The Electric Imp has great potential to find a niche that we weren't even aware existed, but at the moment it doesn't feel quite ready yet.