Required components, layout recommendations and best practices
The imp004m module is the low-cost successor to the imp002, which has now been discontinued (please see ‘Transitioning your product from the imp002’ for further information).
See imp004m Pin Mux.
The imp004m supports 802.11b/g/n WiFi connectivity in the 2.4GHz band only.
From impOS™ 38, Bluetooth LE is available on the imp004m. It is not enabled by default, but the imp API provides facilities for its activation. While the Bluetooth sub-system is not connected directly to the imp004m’s MCU, the pins are made available via the module’s pinout, allowing the host PCB to route them to suitable imp004m GPIO.
For more details, please see ‘Bluetooth LE’, below.
With the release of impOS 38, the imp004m module gains 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.
For more information, please see ‘Working with Audio on the imp004m’.
The imp004m provides analog input on a number of its GPIO pins — see the imp004m Pin Mux for a list of which pins provide this functionality. However, the imp004m does not provide a sampler for continuous analog sampling. Before impOS 38, the imp004m does not support analog output via fixedfrequencydac. The imp004m does not support analog output via GPIO.
The imp004m does not include nv support because of its lack of non-volatile memory in which nv can be preserved during deep sleeps. Attempting to establish and access the nv table on an imp004m will throw the following Squirrel runtime error: “nv table not available on this imp”. This also means that TLS session credentials cannot be stored across sleeps, meaning that the first connection after a deep sleep bears the full crypto load and hence is significantly slower than subsequent ones.
Users who need to store data across deep sleeps on imp004m can either use hardware.spiflash (see below), 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.
Shallow sleep requires no special operations to enter; as long as the system is not busy (no Squirrel running), WiFi is disconnected, and peripherals are all disabled/quiesced (apart from edge triggered GPIOs), impOS will enter shallow sleep.
Your design will require the following in addition to the imp004m module:
The required circuit is very simple: you just need a phototransistor and a resistor.
Your phototransistor must be able to sense visible light. Do not use a phototransistor with a visible-light filter. Refer to the imp004m datasheet for a list of recommended parts.
The value of the bias resistor used in the BlinkUp detection circuit will depend greatly on your mechanical design and on the opto-electrical components you have selected. This value will need to be tuned to suit your design, by following the BlinkUp Tuning Guide. A larger value for RBIAS will result in a larger signal during BlinkUp, but also makes your design more susceptible to saturation from ambient light. A smaller value reduces sensitivity to ambient light, but will produce a smaller signal during BlinkUp. A 22-68kΩ resistor is a good place to start tuning.
This LED uses different color patterns to show different status conditions (see the BlinkUp codes guide for more information).
Your LED configuration needs to be able to produce three colors: red, green and amber. Most designs use a single bi-color LED to achieve this; some use two discrete LEDs and a lightpipe.
You may use either a common-cathode or a common-anode LED in your design; the imp004m will detect the LED polarity automatically. Two-pin (“either-or”) bi-color LEDs are not supported: it must be possible to turn red and green on at the same time. A list of recommended bi-color LEDs is available in the imp004m datasheet.
A 10kΩ resistor is required in parallel with the red side of the bi-color LED to allow the imp to detect LED polarity.
BlinkUp detection and bicolor LED circuit
An external SPI flash part is mandatory. The minimum size of the SPI Flash is 8Mbit (1024KB) and the maximum size is 128Mbit (64MB). The area below address 0xC2000 (776KB) is reserved for use by impOS. The remainder of the available space is made available to user code programmatically through the hardware.spiflash object. Areas below address 0xC2000 will be erased and reprogrammed by the OS; applications using pre-programmed SPI flash components must not use space below this address.
Note 1 The imp004m’s SPI flash chip must support both 4KB and 64KB erases (command 0x20 and 0xD8) and Page Program (command 0x02). You must also ensure that the SPI flash you use is able to run down to the minimum operational voltage of the imp004m to ensure that the SPI flash is operational at all times that the imp is operational. This is critical during upgrades in low battery states. If you are running from a single LiMnO2 cell (eg. CR123), you should use a wide voltage range SPI flash that is operational from 1.7-3.6V such as the Macronix MX25R8035FM2IH0.
Note 2 impOS 38 will cause certain recommended SPI flash parts to enter deep sleep whenever the imp004m itself enters deep sleep, and to wake the SPI flash when the imp004m wakes. Recommended SPI flash parts are listed in the imp004m datasheet. If you choose SPI flash parts which support sleep/wake but are not recommended by Electric Imp, you must ensure that the chosen parts enter and exit sleep mode in the same way that the recommended parts do, otherwise your product may malfunction. We do not anticipate any such risk if you use SPI flash parts which do not support sleep/wake.
Note 3 The SPI flash must be pre-programmed with an image from Electric Imp, unlike the imp003 which self-programs the external flash part. Please contact Electric Imp for an OS image to load into the SPI flash.
The flash can be programmed before SMT, or in-circuit by using a connector that exposes the four SPI flash pins and the imp004m nRESET line, as on the imp004m breakout board. With the imp004m held in reset, the SPI bus is tristated and can be driven externally by a programming tool, or another imp.
If your design requires that the imp be able to enter low-power sleep, the following components are also required:
The imp004m does not include an internal timing crystal to run the internal Real-Time-Clock (RTC) while the imp is in deep sleep. If your design requires that the imp be capable of low-power deep sleep, it must include the crystal so that the imp can set timers and use them as a wake source.
Note Make sure the crystal has a load capacitance of 6pF. Higher values may prevent the oscillator from starting up.
If you are not connecting a 32kHz crystal, the imp004m’s OSC32_IN pin must be tied to ground, either directly or through a 0Ω resistor.
If your hardware is at any time going to run at below 2.7V, you must ensure you use a wide voltage range flash.
Applying more load than this to the imp004m’s pins will damage the module. If your design requires you to move more current around, use an imp pin to switch a FET or transistor.
Your design must not expose any of the imp004m’s pins to a voltage greater than VDD (the supply voltage provided to the module). Consult the imp004m datasheet for more information on electrical characteristics and absolute maximum ratings.
The VDDA pin on the imp004m is used to provide the power supply used for the module’s analog-to-digital converters, which are used during BlinkUp and whenever squirrel application code requires them. Most designs can simply connect VDDA to VDD. Some designs might wish to use a separate supply rail for better isolation and reduced noise, like the Lala reference design. If a separate supply is used, it must be able to source 500µA, and must not exceed VDD at any time. Note that this means that during power-on, the VDDA rail must not come up faster than VDD. Note that VSSA, the analog ground, must also be properly connected.
The imp004m’s internal pull-up or pull-down resistors will be cleared when the imp reboots, and these nets will be tri-stated.
If you are not connecting a 32kHz crystal, the imp004m’s OSC32_IN pin must be tied to ground, either directly or through a 0Ω resistor.
See the SPI flash details, above.
It’s very important that your design follow a few simple rules when it comes time to place and route your printed circuit board in order to take advantage of the imp004m’s simplicity and maximize performance.
The imp004m’s ground pins should have a clear path back to ground, without running through many narrow traces or bottlenecking at a single via. While a via may be rated for much more DC current than your design calls for, the impedance of the ground path needs to be as low as possible to prevent noise from becoming a problem in your design. This applies to other parts of your design as well, so minimize ground impedance everywhere.
Use Ground Pours Flood ground on the top and bottom of your PCB to provide a good ground path to all components. The imp004m’s antenna tuning ‘expects’ a ground pour under the non-antenna portion of the imp. If the ground pour is omitted, the antenna will be de-tuned, which will negatively impact range and performance, and may prevent your product from passing wireless certifications.
Stitch ground planes around the edge of your board and throughout the interior of the board. Use more vias than you need for the DC current your circuit requires; this will lower the impedance of the ground paths and reduce noise.
Bypass capacitors will dump noise to ground, but if the trace on the filtered side is long, it presents an opportunity for that trace to pick up noise again.
The parasitic capacitance of a nearby ground plane may exceed the required load capacitance for your 32kHz crystal (if used). To avoid de-tuning the crystal (which can severely affect performance or prevent the imp004m from operating entirely), pull ground pours back around the 32kHz crystal and crystal load capacitors.
Ground Pour pulled back around 32kHz crystal
A poorly-routed switching power supply will send noise all over the board and severely impact performance and range. This is easily avoided by following the recommended layout in the datasheet for nearly any switching power supply IC.
Recommended Layout for the TPS62172 Buck Regulator, as shown in TI’s datasheet
Noise on your board directly diminishes your WiFi performance, and can prevent you from passing FCC certifications. Keep all noisy parts (switching power supplies, high-speed signaling) as far from the imp’s antenna as possible.
Routing signals in the correct order can significantly simplify a design:
Place your power supply and route VDD It’s generally a good idea to avoid vias on your power supply rail; these increase the impedance of the trace and create an opportunity for noise to impact your design.
Route high-speed signals directly and avoid vias By keeping the path between devices that communicate over a high-speed interface such as SPI direct and short, you minimize the possibility that noise will couple into the line, or that the signals on the line will couple into other parts of your design as noise.
Keep analog signals clear of noisy digital signals, and route them as directly as you can Routing an analog signal right next to a digital signal creates an opportunity for digital noise to couple into the analog signal. Keep them apart and pour ground in between to provide some shielding.
Route GPIOs last A signal which is simply used to poll a button or toggle an LED does not need special considerations. If a GPIO signal crosses a higher-priority signal such as a SPI bus or an analog line, the lower-priority signal should via around the higher-priority one.
The imp004m’s LPO_IN pin (the sleep clock pin) should be grounded if otherwise unused.
As the imp004m is mostly self-contained, it does not require any special PCB technology to operate well.
The imp004m is designed to “hang off” the edge of the application board, placing the antenna area in free space. You should keep copper away from PCB that comes near to the antenna area in order to preserve optimum RF performance.
Because the imp004m loads WiFi configuration and operating system data from external flash storage, it must check that the flash is connected and can be read. This takes place at start-up, and any errors encountered are signalled on the bi-color LED attached to the imp004m. The following table lists these error signals; click on an error’s Play link to view an animation of the LED pattern.
Note that if the flash is blank, or is corrupt, the cryptographic check on the image will fail and the device will be unable to show any failure LED code because no impOS is able to be loaded. In this case, you will see the green LED lit solidly at a low brightness level if you have a common cathode LED, or no LED indication at all if you have a common anode LED.
|SPI Flash Not Found|
|SPI Flash Error|
The imp004m’s WiFi chip is the Cypress Semiconductor CYW43438 communication chip. This chip also supports Bluetooth 4.1. Though the CYW43438’s Bluetooth unit is not connected directly to the imp004m’s MCU, its CYW43438’s Bluetooth-specific pins are brought out to the imp004m pin-out to make them accessible to hardware designers who wish to make use of the module’s Bluetooth features in their products. To do so, you will need to:
After making use of Bluetooth, you should set CYW43438 pins BT_REG_ON and LPO_IN low and if you wish to power down and fully disable the imp004m’s Bluetooth sub-system.
This is all that is required from hardware — the Bluetooth LE system will still need to be enabled in software, however, using imp API methods made available in impOS 38. Please see ‘Using Bluetooth LE with the imp004m’ and the imp API bluetooth class for full information.
|August 5, 2016||Initial release|
|August 12, 2016||Added SPI flash requirements|
|September 2, 2016||Note changes to pin nomenclature|
|September 7, 2016||Added 32kHz crystal information|
|October 14, 2016||LED, phototransistor, PCB guidance, etc added|
|November 24, 2016||Added wide voltage range flash recommendation|
|December 2, 2016||Make requirement to pre-program flash more explicit|
|August 24, 2017||Add note on LPO_IN grounding|
|September 29, 2017||Clarify analog functionality|
|December 15, 2017||Add Bluetooth LE information|
|April 13, 2018||Add audio information, add SPI flash sleep/wake guidance|