Skip to main content

Transition Your Product From imp002 To imp004m

How To Migrate An imp002-based Design

Electric Imp has formally end-of-lifed the imp002 module. Customers who are currently manufacturing connected products based on this module should implement a strategy to migrate their product from the imp002 to the imp004m, which will shortly be produced in volume by our manufacturing partner Murata (as part number LBEE5ZZ1MD).

The imp004m offers a similar feature set to the imp002, but with two key differences. Firstly, it requires an external SPI flash to operate and, secondly, while the imp004m has GPIO analog input support it does not offer GPIO analog output support. The imp003 is a better replacement for imp002 in such applications.

Secondly, it does not provide a true fixedfrequencydac or a sampler. However, the imp004m module has the ability to both digitize an audio signal and to convert digital audio data back into an analog signal capable of driving a speaker or earphones. Together, these audio processing capabilities put the low-cost imp004m on a par with other imp modules: emulation of a fixed-frequency DAC using pulse-width modulation (PWM), and support for filtering the input from a digital microphone which together enable sampler-like functionality.

In most cases, the board design for imp004m will be similar to the imp002 (although not as a drop-in replacement). Like the imp002, the imp004m does not require an external antenna.

This document will help you choose the best approach to migrating your imp002-based design to the imp004m. For more information on the imp004m, please review the datasheet.

The imp004m And The imp002: Key Similarities And Differences

Feature imp004m imp002
GPIO 18 pins 12 pins
Analog GPIO input GPIO input and output
Sampler No Yes
Fixed-frequency DAC No Yes
CPU ARM Cortex M4F @ 96MHz ARM Cortex M3 @ 120MHz
Application RAM 184KB 85KB
Code Space 256KB 128KB
WiFi Integrated 802.11bgn radio, antenna Integrated 802.11bgn radio, antenna
Requires External SPI flash Yes No
Requires 32kHz crystal for low-power operation No (optional) No (integrated)
NVRAM table No Yes
Low-power ‘stop’ mode* Yes No

*The imp004m has a low power ‘stop’ mode which is automatically entered when the system state allows (no peripherals requiring clocking enabled, WiFi off, no pending tasks to run). Restarting from this mode does not restart Squirrel, so is often easier to manage than deep sleep.

imp002 To imp004m Design Changes In Depth

Unlike the imp002, the imp004m is manufactured by Murata rather than by Electric Imp itself. This means the imp004m is more widely available than the imp002 was. The newer module is physically smaller than the imp002 and its power requirements are lower than, so the host PCB’s power supply design can be maintained without change.

External SPI Flash — Which Must Be Pre-programmed

The imp002 contained internal SPI flash storage, which was used to store the WiFi firmware. External SPI flash connected to the imp004m performs the same function, but because of the size of the WiFi firmware, the imp004m cannot automatically initialize a blank SPI flash at first power up in the same way that an imp003 can. The flash is attached to a dedicated SPI bus which can only be used for this required component.

Consequently, the imp004m SPI flash must be pre-programmed before SMT with an image available from Electric Imp.

As with the imp003, space not used by the WiFi firmware is available to your squirrel application (any space above 776KB).

Persistent Storage

If your imp002 code makes use of nv storage, you will need to modify this for the imp004m. The imp004m does not include nv support because of its lack of non-volatile memory in which nv can be preserved during deep sleeps. If you need to store data across deep sleeps on the imp004m, you can either use your external SPI flash, or potentially even avoid deep sleep altogether. This is possible because shallow sleep on the imp004m consumes significantly less power than other imps do in shallow sleep.

Application Firmware

The imp004m runs the same Squirrel code as the imp002 but you may have to make some minor changes to your code to match the updated hardware design. You updated application firmware will also benefits from having double the available application code storage space.

For example, if your design currently uses hardware.i2c89, you will need to select hardware.i2cQP or hardware.i2cNM on the imp004m. Whichever of these I²C buses you choose, you will have to change you device code everywhere you reference hardware.i2c89. It is possible to maintain Squirrel application firmware which supports both types of hardware by detecting which type of imp module the Squirrel is running on and mapping the peripherals accordingly. For example:

i2cDevice <- null;

local impType = imp.info().type;
if (impType == "imp004m") {
    i2cDevice = hardware.i2cQP;
} else if (impType == "imp002") {
    i2cDevice = hardware.i2c89;
} else {
    throw "Unsupported device";
}

// Configure and use the selected I2C bus
i2cDevice.configure(CLOCK_SPEED_400_KHZ);
local i2cReadValue = i2cDevice.read(_i2cAddress, SENSOR_REGISTER, 1);

IO And Peripherals

The imp004m, like the imp002, has two I²C and two SPI buses. The imp004m SPI buses have fixed chip-select pins. The imp004m has four UARTs; the imp002 has five. Both modules provide a large number of ADC- and PWM-capable pins, and single pulse-count and wake pins. Both provide three pulse-triggered pulse-generation pins.

The imp004m module has the ability to both digitize an audio signal and to convert digital audio data back into an analog signal capable of driving a speaker or earphones. Together, these audio processing capabilities put the low-cost imp004m on a par with other imp modules: emulation of a fixed-frequency DAC using pulse-width modulation (PWM), and support for filtering the input from a digital microphone which together enable sampler-like functionality.

The following table will help you map imp002 peripheral and GPIO pins to imp004m equivalents:

Function imp002 Pin(s) imp004m Pin(s)
Wake Pin 1 Pin W
Pulse Count Pin 1 Pin J
ADC Pin 1,
Pin 2,
Pin 5,
Pin 7,
Pin 8,
Pin 9,
Pin A,
Pin B
Pin A,
Pin B,
Pin C,
Pin D,
Pin K,
Pin L,
Pin W
PWM Pin 1,
Pin 2,
Pin 5,
Pin 7,
Pin 8,
Pin 9,
Pin C
Pin A,
Pin B,
Pin D,
Pin K,
Pin M,
Pin N,
Pin P
SPI spi257,
spi189
spiAHSR,
spiGJKL
I²C i2c12,
i2c89
i2cNM,
i2cQP
UART uart1289,
uart57,
uart6E,
uartB
uartBCAW,
uartFGJH,
uartHJ,
uartQ

Low-Power Operation Components

The imp002 includes all of the components required for low-power operation, but the imp004m makes these optional: it allows you to place those components only if they are needed. This allows applications which do not require low-power operation to save cost by omitting them.

The only component required for low-power operation is a 32KHz crystal. The 32KHz crystal allows the imp004m to enter the ultra-low power ‘deep sleep’ state while still waking at a predetermined time, or by asserting the wake pin (pinW). The internal WiFi chip features an ultra low-power standby mode — around 8µA — which does not require any external power gating to take advantage of.

impOS Licensing

With the imp002, the impOS license fee was included in the module price since it was being sold directly by Electric Imp. In order to avoid distributor markups and to reduce inventory costs, this fee has been separated out from the imp004m unit/volume price and is instead charged as part of the manufacturing process. Please contact Electric Imp sales for an updated service agreement with more information.

Migration Strategy

The recommended approach for imp002 customers is to redesign their product based on the imp004m. This allows you to take full advantage of improvements offered by the imp004m without the need to manage antenna design and RF certification.

Before commencing migration, you should first read our ‘Design Hardware With The imp004m’ guide.

Here are the more common considerations you will encounter when updating your design:

  1. You will need to determine a new pin mapping. We recommend you start by assigning the most scarce peripherals first.
    1. Wake from deep sleep, which is required for most low-power applications, has moved from imp002 pin1 to imp004m pinW.
    2. Inputs which trigger software callbacks, such as a button, require a little planning. All of the imp002’s 12 pins can be configured to trigger a callback on a state change, but only 11 of the imp004m’s pins can be configured with callbacks.
    3. Assign peripherals such as ADC, PWM, UART, I²C and SPI. You should note that the imp004m may not support the peripheral bus settings used in your imp002 design. For example, imp004m UARTs can match imp002 minimum baud rates but not all maxima: hardware.uart6E reaches 7.5Mbaud on the imp002, but the closest the imp004m can reach is 6Mbaud on hardware.uartFGJH and hardware.uartHJ. The imp004m’s SPI buses have fixed nSS pins, so chip selects cannot be mapped to any GPIO pin as on the imp002. Note The imp004m has no sampler.
    4. Assign digital outputs. Note The imp004m has no support for analog output.
  2. You will need to add a single pre-programmed SPI flash connected to the dedicated SPI flash interface. This must be at least 8Mbit in capacity.
  3. If your design requires low-power operation, be sure to include all of the low-power components listed in the imp004m design guide. If the design does not require low-power operation, remember to ground the OSC32_IN pin.