Skip to content

Week 10 Group Assignments -

Group assignment:

Measure the power consumption of an output device.

Document your work on the group work page and reflect on your individual page what you learned.

Power Consumption Measurement

We chose to measure the power of the high power addressable LEDs that Jeremy is using for his camera prototype. They are being driven by a XIAO ESP32C3 and we felt it would be interesting to measure with the relatively high amp draw of the bright LEDs.

Setup

We used Jeremy’s dev board and LED prototype for the experiment. The setup is shown in the images below. The dev board is running a XIAO ESP32C3 microcontroller and a series of 3 addressable LEDs. One of the LEDs is on the board and is a WS2812 5mm package standard LED. The other 2 in the chain are connected to the board and are Adafruits 3W Neopixels. These are a high power RGB LED that is connected to a WS2811 control circuit as opposed to an integrated package.

Circuit setup showing the high power LED

Circuit setup showing the development board.

To measure the power, we connected a USB power meter to a wallwart and then connected the XIAO to the output of the power meter with a USB cable. We set the output of the power meter to 4.99V.

Circuit setup with the power meter inline with the USB cable. Note that the circuit is drawing a small amount of power at rest before any of the LEDs are on.

Code

The XIAO was loaded with the following code that uses the onboard button to cycle through different colors including full bright white and finally to off. When the XIAO first comes on, the LEDs are off until the button is pushed the first time.

color_cycle.ino
#include <Adafruit_NeoPixel.h>

int pushButton = 21;
int led= 20;
int LED_COUNT= 3;
int LED_PIN= 10;

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

volatile bool buttonPressed = false;
volatile unsigned long lastInterruptTime = 0;
const unsigned long debounceTime = 200; // milliseconds

int colorIndex = 0;

uint32_t colors[] = {
  strip.Color(255, 0, 0),      // Red
  strip.Color(255, 165, 0),    // Orange
  strip.Color(255, 255, 0),    // Yellow
  strip.Color(0, 255, 0),      // Green
  strip.Color(0, 255, 255),    // Cyan
  strip.Color(0, 0, 255),      // Blue
  strip.Color(255, 0, 255),    // Magenta
  strip.Color(128, 0, 128),    // Purple
  strip.Color(255, 255, 255),  // White
  strip.Color(0, 0, 0)         // Off
};

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);

  // make the pushbutton's pin an input:
  pinMode(pushButton, INPUT);
  pinMode(led, OUTPUT);

for (int i =1; i<=2; i++){
  digitalWrite (led, HIGH);
  delay (500);
  digitalWrite (led, LOW);
  delay (500);
}

digitalWrite (led, LOW);

//pinMode(BUTTON_PIN, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(pushButton), handleButtonPress, FALLING);

}

void loop() {

   if (buttonPressed) {
    buttonPressed = false;

    // Change LED color
    strip.setPixelColor(0, colors[colorIndex]);
    strip.show();

    // Move to next color in the list
    colorIndex = (colorIndex + 1) % (sizeof(colors) / sizeof(colors[0]));
  }
}

void handleButtonPress() {
  unsigned long currentTime = millis();

  // Debounce check
  if (currentTime - lastInterruptTime > debounceTime) {
    buttonPressed = true;
    lastInterruptTime = currentTime;
    digitalWrite (led, HIGH);
  }
}

Theoretical Output

There are 3 LEDs in the circuit that can draw power. The WS2812 on the board uses about 60mA at fullpower and the high power LEDs draw 600mA at full power. So we would expect to see the circuit draw about 420mA for single color (red, blue, or green only) or 2.1W. For full color we expect about 1260mA at full power white or 6.3W.

Testing

We turned the circuit on with the above code and cycled through and noted the power output at different colors. One quirk of the programming is that the onboard pixel is RGB and the high power LEDs are GRB. So when the onboard LED is red, the high power are green. However, at full power white, they are both white.

No LEDs

We saw from the image above that the circuit draws about .13W at steady state with no LEDs on.

Single Color

We first looked at single color power output of red, blue, and green on the high power LEDs. We cycled the button until the LEDs were red and observed the measurement and did the same for green. The output of both is strikingly similar at 1.94W (red) and 1.83W (green) specifically

Output of red LED.

Output of green LED.

Output of blue LED.

Subtracting the steady state power, the power draw of the LEDs is 1.81W and 1.7W so about .85W per high power LED which is lower than the nominal stated output.

2 Color

Then we tested cyan color or a mix of full power green and blue. In this case we had abouta little less than double the power consumption of .66A and 3.34W

Output of cyan LED.

Based on the single color tests, we would expect .85W x 4 plus the nominal power of.13W or 3.53W. So the measurement is quite close.

White, Full Brightness.

Finally we tested white, which is full power for all 3 LEDs. The result was 0.96A and 4.83W.

Output of white LED.

Based on the single color test, we would expect about .85 * 6 (3 LEDs in each of the 2 RGB packages) plus the .13W power draw at steady state which is 5.23. So we are about .5W lower measured draw than what we would expect.

Conclusions

It was interesting to see how the measured power draw varied with different color combinations and how easy it was to setup the USB power meter to measure this.

We found that the measured power draw of the LEDs was lower than we expected, but proportional to what we would expect based on the single color testing.

Jeremy found this helpful as it will inform his battery choices for his final project.