Introduction: RGB LED Current Measurement With Nordic Power Profiler Kit II

The Nordic Power Profiler Kit II (PPK2) is an affordable, easy-to-use, USB-powered device which can measure tiny currents over time. This is useful to analyse the power used by a microcontroller and its peripherals if it's intended to be powered by batteries or solar power. The device can optionally act as a power supply for 0-5V up to 1A. It can also be used as a basic, low sample rate 8 channel logic analyser.

This article explores the finer points of the power consumption of two types of RGB LEDs to demonstrate the use of the PPK2 and to show how multi-colour LEDs operate.

The first example is a battery powered BlinkypartsRainbow Unicorn soldering kit featuring four colour-cycling, multi-colour LEDs.

The second example is the NeoPixels on an Adafruit Circuit Playground Bluefruit (CPB). These pixels are bright, individually addressable, RGBlight-emitting diodes (LED) where the brightness level of the red, green and blue constituent LEDs can be varied from 0 to 255.

A simple CircuitPython program controls the NeoPixels with two modes selected using the CPB's switch.

  • A sequence of red, green, blue, yellow, cyan, magenta, and white at different brightness levels. This sequence runs on one NeoPixel and then on three NeoPixels.
  • One NeoPixel at full brightness for red, green and blue to produce bright white.

The CPB is not intended for low power use but its Nordic nRF52840 processor has features for this. This makes the board viable for experimentation, prototyping and learning about efficient power techniques. This program will also work on the similar ATSAMD51-based Circuit Playground Express (CPX).

Supplies

Step 1: Installing CircuitPython and CPB Pixel Current Program

If you are not familiar with CircuitPython then it's worth reading the Welcome to CircuitPython guide first.

  1. Install the latest version of CircuitPython (7.3.3 in September 2022) from https://circuitpython.org/ - this process is described in Adafruit Circuit Playground Bluefruit: Install or Update CircuitPython.
  2. Verify the installation by connecting to the serial console over USB. The REPL prompt shows the version. The version can also be checked by inspecting boot_out.txt on the CIRCUITPY drive.
  3. Install these libraries from a bundle from https://circuitpython.org/libraries into the lib directory on CIRCUITPY:
  4. adafruit_circuitplayground
  5. adafruit_lis3dh.mpy
  6. adafruit_thermistor.mpy
  7. neopixel.mpy
  8. Download the NeoPixel sequencing program to CIRCUITPY by clicking Save link as... on cpx-pixel-current.py
  9. Rename or delete any existing code.py file on CIRCUITPY, then rename the cpx-pixel-current.py to code.py. This file is run when the CircuitPython interpreter starts or reloads.

The versions used for this guide were:

  • CircuitPython 7.3.2
  • CircuitPython library bundle adafruit-circuitpython-bundle-7.x-mpy-20220827.zip

Step 2: Powering the CPB With Power Profiler

The Power Profiler Kit II must be connected to the host computer using the micro USB connector on the top at the right side. The lower left set of connections on the PPK2 from left to right are:

  1. GND (black);
  2. VIN (red) - only used for ammeter (AMP) mode, do not connect in source measure unit (SMU) mode;
  3. VOUT (brown) - connects to red cable on JST PH cable using test hook;
  4. GND (black) - connected to black cable on JST PH cable using test hook.

Unfortunately the connector can be inserted in two orientations necessitating some care to get the red and brown cables the correct way around. The current will measure around 0uA if the red/brown connections are swapped.

The Rainbow Unicorn was powered by removing its CR2032 battery and attaching the test hooks to the battery holder's terminals.

For current use above 500mA both USB connectors on the Power Profiler must be powered.

Step 3: LED Variable Brightness

The image above is a NeoPixel on the Circuit Playground Bluefruit at its lowest brightness setting. The driver chip (small dark square) is visible at the bottom and the bondwires connecting to the three LEDs can just be seen.

There are two common technique for varying the brightness of an LED: changing the current or turning the LED on and off rapidly and relying on persistence of vision.

Current Control

The brightness of an LED could be controlled by varying the voltage but the characteristics of an LED make this more challenging and less accurate than varying the current. A variable current supply provides good control over the brightness and allows for variations in the forward voltage. The colour (central wavelength) of the LED may vary a little with changes in current.

Pulse-Width Modulation

A simple and effective approach for varying the apparent brightness is to flicker the LED at a frequency high enough for humans not to be able to see the flicker. This may be more power efficient than a variable current supply. The typical flickering technique is pulse-width modulation (PWM). This is a common feature on microcontrollers allowing trivial brightness control for LEDs driven by GPIO pins. A current limiting resistor per LED is the only additional component required.

For multiple LEDs there is a design question when using PWM. The hypothetical examples shown above are for three LEDs (red, green and blue) illuminated at 30% of maximum brightness level with a current of 15mA per LED. If they illuminate at the same time the current is much more bursty with a short 45mA peak. If they are staggered by offsetting the phase then they present an almost constant 15mA load for this particular brightness level. The latter appears more attractive to minimise fluctuations in load on the power supply.

Step 4: Rainbow Unicorn Power Profiling

This video looks at the power consumption during the colour cycles of the Rainbow Unicorn intended for use with a CR2032 battery. The variable voltage feature of the PPK2's power supply is used to explore the behaviour at different voltages. The 3V represents a typical value for a new battery under load. The 2V is a voltage sometimes cited as the final voltage for a fully discharged CR2032.

  • 00:04 Start is pressed to start the data logging, graph shows noisy 0.25uA value.
  • 00:05 The power output is enabled at 3.005V. The unicorn starts with all four LEDs showing red (appears as orange in the video).
  • 00:08 Red at 26mA transitions to green at 20mA then blue at 12mA.
  • 00:20 (Greenish) yellow at 43mA, cyan at 29mA, magenta at 34mA, (almost) white at 50mA.
  • 01:07 Repeat of the colour cycle at an abnormally low voltage of 2.06V. The red LED is the only one that works at this low voltage with lower current consumption at 6mA. These LEDs are clearly not designed to work at this voltage.

The four LEDs on the Rainbow Unicorn start with synchronised colour cycles but quickly drift out of synchronisation.

Step 5: Calculation of Battery Lifetime

The Nordic Power Profiler software presents statistics for the current window of data and for any selection. One cycle of the colour changes for the Rainbow Unicorn is shown above with an average current of 29.44mA and a peak of 47.75mA. The CR2032 batteries use a lithium/manganese dioxide cell with a nominal voltage of 3V and a capacity around 225mAH. The battery lifetime would be expected to be around 225mAH / 29.44mA = 7.6 hours.

A battery data sheet from a reputable manufacturer would provide a more detailed account of how the lifetime varies with current. The voltage for a discharging battery is not constant and the lower voltage towards the end of the battery lifetime may be below the minimum voltage for the device further reducing the practical battery lifetime.

Step 6: NeoPixel Power Profiling

The ten pixels on the Circuit Playground Bluefruit are individually addressable meaning they can be independently changed. This is implemented by chaining the pixels in the style of a shift register where a pixel will pass the level settings to the next one if it receives another one. This allows a large number of pixels to be controlled using just one signal line.

NeoPixel is Adafruit's trademarked name for their pixels using the wire protocol for WS2812, WS2812B, WS2811 and SK6812 RGB LEDs.

The video above shows:

  • 00:05 Start is pressed to initiate the data logging. The graph shows a noisy 0.2uA value.
  • 00:09 The power output is enabled - this is set to 4908mV. The CircuitPython interpreter initialises and flashes all ten NeoPixels.
  • 00:13 The first NeoPixel ramps from off to full red brightness with four intermediate steps. This repeats with green and blue. And then with two colours together to produce yellow, cyan and magenta. Finally, with all three producing white.
  • 00:20 The graph auto-scales as the inrush current (?) from the start of the trace scrolls off the x axis.
  • 00:26 The sequence repeats with three NeoPixels.
  • 00:50 The CPB is powered up again with the switch set to the right which sets the first NeoPixel to full brightness white consuming a constant current of 48.23mA.

Step 7: Circuit Playground Bluefruit CircuitPython Startup

The screenshots from the Nordic Power Profiler show:

  1. An initial peak of almost 400mA for just over 1ms when the Circuit Playground Bluefruit is powered up. This spike is probably an inrush current due to the capacitors charging up across the power supply rails on the CPB.
  2. The CircuitPython interpreter briefly lights all the NeoPixels red and then flashes them yellow and then blue at startup.
  3. The CPB with an idle CircuitPython program uses around 6mA.

The idle current is likely to vary a little based on what the on-board peripherals are doing. The power intensive features of the Circuit Playground Bluefruit/Express will be:

  • all ten NeoPixels set to bright values;
  • loud, long audio played on the mini speaker;
  • heavy use and misuse of the infrared LED (only on CPX);
  • powering any high current peripherals like servos or motors.

Step 8: CPB One NeoPixel

The screenshots from the Nordic Power Profiler for 1 NeoPixel being illuminated show:

  1. A 12 second view across all of the colours, red, green, blue, yellow, cyan, magenta, white. When each is at full brightness the current level becomes constant as the PWM duty cycle is 100%, i.e. on all the time.
  2. The red at brightness level 128 which equates to a duty cycle of 50% where the LED spends half its time on and half off. The current is 17mA but 6mA of that is the CPB which means the red LED uses 11mA.
  3. This is white at brightness 10, approximately 4% duty cycle on red, green and blue. There is a single peak here indicating all three constituent LEDs are illuminated at the same time, i.e. there is no phase offset.

Step 9: CPB Three NeoPixels

This is the same as the previous test run but with 3 rather than 1 NeoPixels being illuminated. A simple guess would be the values are the same but with 3x more current use by the LEDs. However, the screenshots from the Nordic Power Profiler show:

  1. A 12 second view across all of the colours, red, green, blue, yellow, cyan, magenta, white. This does look the same.
  2. This is white at brightness 10, approximately 4% duty cycle on red, green and blue. This particular section of the trace shows the 3 NeoPixels and 3 LED colours are initially peaking at the same time but the single peak slowly morphs into two smaller peaks then three smaller peaks.

The change in the peaks is not too surprising. NeoPixels do not have a common clock and there's no requirement for them in have an identical PWM frequency. The internal clock on each NeoPixel is running at a slightly different frequency and the LEDs are sometimes on at the same time and sometimes not.

This demonstrates that a reasonable number of these particular pixels are likely to have a fairly steady aggregate power consumption. It's possible that changes in brightness level might synchronise them to some degree - that could be explored experimentally. If the steady current behaviour was essential for a product then it would need to be documented by the (credible) manufacturer on the data sheet.

Step 10: Comparison With Multimeter and USB Tester Measurements

Multimeters can be used to measure current. Most only update once or twice a second making them unsuitable for a fluctuating DC current but they can work well for a steady current. The photographs above are measurements from two inexpensive multimeters used with the PPK2 as a power source for the CPB via JST connector and a USB meter.

  • AstroAI DM6000AR: Measures 0.046A on A range and 47.10mA on mA range. Care is needed to use the appropriate socket for the positive lead, stable measurements of -0.547A and 0.25mA occur for the wrong socket!
  • UNI-T UT30A: Measures 47.2mA, sometimes 47.0mA too. The next range is 40mA preventing a more precise measurement.
  • USB TESTER: Measures 0.02A. It also shows 0.143W on the display. Converting the power to a current gives 0.143/4.96 = 0.288mA which happens to be closer to the real value.

The PPK2 measures this as 48.15mA average with a range of +/- 1.8mA.

A multimeter measures current by performing a voltage measurement across a series resistor. The voltage drop across the meter is known as a burden voltage. This voltage drop can be significant and confusing at the voltages used for microcontrollers. There is an example of this in the Andreas Spiess video featured later in this article.

A wise precaution for multimeters is to always return the positive red lead to the voltage socket after measuring current. This prevents an accidental high current (and blown fuse) if the multimeter is used next to measure a voltage with the lead in the wrong socket.

Step 11: Light Bulb Power Profiling

The photograph above shows the data logging for a small incandescent bulb intended for use at 2.4V 0.5A. The supply voltage has been set to a more conservative 2.018V but there's still a huge inrush current peaking around 1.4A (over the 1A maximum the manufacturer states for the device), dropping to 500mA in around 80 milliseconds before settling at 404mA. This simple resistive load still has noise on the trace with most of the values between +/- 2mA.

Note: both USB connectors are in use here to provide current above 500mA. It may be worth using a lower current threshold for dual powering and being cautious on anything which may exceed the 1A maximum for more than a few milliseconds.

Step 12: Andreas Spiess Low Current Meter Comparison

Andreas Spiess has an excellent, in-depth comparison of several devices for measuring small currents over time in How to measure low Currents for ESP/Arduino? Power Profiler, Otii, µCurrent Gold, Joulescope (YouTube), shown above. The table from the video summarising the five devices is included below.

InstrumentAutomatic Range SwitchingNegative CurrentsDisplays AverageDisplay of CurvesMaximum Current Voltage
uCurrent GoldNoYesNoOscilloscope1.25A
Current RangerYesYesYes*Oscilloscope3.3A
Power Profiler Kit IIYesNoYesSoftware1A 5V
OtiiYesYesYesSoftware3A 5.0V**
JoulescopeYesYesYesSoftware3A 15V

* On optional display.

** 4.55V max in auto range mode.

Step 13: Going Further

Ideas for areas to explore:

  • Look at the power profile of the APA102 RGB LEDs AKA Adafruit DotStar.
  • Use the PPK2 digital inputs. Microcontroller GPIO can be used as outputs indicating specific activity in the application. These can be read and recorded by the PPK2 providing easier visual and programmatic correlation with activity vs power usage.
  • Check the power use for devices designed for low power applications like the Adafruit MagTag or Pimoroni Inky Frame.
  • Resolve the mystery of the Circuit Playground Bluefruit's first NeoPixel which on the first mode uses a total current of 40mA but on the second mode is 47-48mA despite being set to the same (255,255,255) value.
  • Your own low power project!

Some other LED soldering kits (available from various retailers and market places):

Further reading: