Today we rolled out an upgrade – Release 25 – to the imp firmware, the mini operating system that lives on the imp and runs your Squirrel code. Release 25 is the first upgrade in a little while – and so, just like the late spring that’s suddenly blossomed all around Electric Imp’s UK office here in Cambridge, there’s a lot of new stuff happening all at once.

Perhaps the biggest change Release 25 gives you as a Squirrel-writer is control of turning on and off the imp’s WiFi controller. Previous versions kept the WiFi up whenever the imp was running – whenever it’s not in “deep sleep.” However, for battery-powered devices that’s often not what you want. For instance, a temperature monitor might want to wake up every minute and take a reading, but only bother bringing up WiFi and telling the server once an hour. Reducing the number of relatively power-hungry WiFi sessions will greatly improve the battery life.

By taking control in this way, you can also keep the imp responsive to sensor readings coming in every second, for instance, even while the imp is taking several seconds to reconnect to WiFi in the background.

In a similar vein, you can now write code that gets informed when joining or leaving WiFi – which was previously somewhat possible by polling the signal strength, but now it’s official and much easier to use. Armed with this, you can make an imp that logs data as you carry it around all day and, when you arrive home and are within WiFi range, uploads it all to the server.

As is always our aim with these upgrades, existing code that doesn’t need any of these new features will continue to work just as before.

Users of the imp’s sampler/audio-input facility might naturally have wondered whether the converse operation was possible: using the imp as a wave-generator or fixed-frequency DAC. Release 25 adds a new hardware.fixedfrequencydac object, which can be used for audio output or for any other situation where one of the imp’s DAC pins (that’s pin1 or pin5) needs to act as a signal-generator. The way it works is similar to the sampler: as a “bucket brigade” of Squirrel blob objects containing the PCM data. More details, and plenty of examples, are already on our developer wiki.

Another feature that will be pleasing to the low-power brigade is hardware.wakereason(), which tells Squirrel the answer to “what woke me up?” In particular, this makes it easier to distinguish a timer wake-up from a wake-up due to a rising edge on pin1 – as long as the pulse on pin1 is longer than about 20 milliseconds.

That’s not even it for the new features, and you can read about all the other ones on the release-notes page on the developer wiki.

Finally, when adding all these features we took care to ensure they didn’t eat into the available free memory for running Squirrel. In fact, we slightly overdid it, and Release 25 should actually run with a bit more free memory than previous releases: up to 2.5Kbytes more.

Peter Hartley
Co-founder and Senior Embedded Engineer