Fab Academy 2026  ·  Week 10

Output
Devices

This week I explored output devices — how microcontrollers send signals to the physical world. For the group assignment we measured the power consumption of a DC motor at different duty cycles. For the individual assignment I connected a 0.96" OLED display to my custom PCB to show real-time cycle and stock information for my final project.

OLED SSD1306 DRV8833 DC Motor PWM I2C XIAO nRF52840 Power Consumption Arduino IDE
OLED display on custom PCB OLED module close-up Motor measurement setup

Group Assignment

  1. Measure the power consumption of an output device

Individual Assignment

  1. Add an output device to a microcontroller board you've designed and program it to do something

Tools Used

  • Multimeter (×2) · Oscilloscope
  • Arduino IDE 2.3.8
  • Seeed XIAO nRF52840
  • OLED SSD1306 · DRV8833 · DC Motor TT
01
Fundamentals

What Is Power Consumption?

Power consumption refers to the amount of electrical energy used by a device or system during operation. It is an important factor when evaluating efficiency, performance, and energy costs.

⚡ The Core Formula

P = V × I

Where:

  • P = Power (Watts)
  • V = Voltage (Volts)
  • I = Current (Amperes)

Cover any variable in the triangle to find the formula for that value.

P Watts (W) V Volts I Amperes × POWER TRIANGLE

📐 Alternative Formulas

Current & Resistance Known
P = I² × R

Use when you know current flow and resistance of the load.

Voltage & Resistance Known
P = V² ÷ R

Use when you know voltage across the load and its resistance.

🔁 Unit Conversions

mA = A × 1000  |  A = mA ÷ 1000
Why it matters: Understanding power consumption helps in selecting the right components, optimizing energy usage, and ensuring safe and efficient operation of electrical systems.
02
Group Assignment

Measuring Motor Power Consumption

Collaborative work done with Andrés Mamani ↗ at Fab Lab Universidad de Lima ↗

🔧 1. System Description

We measured the output of a motor demonstration kit available in our Fab Lab. The system consisted of the following components:

DRV8833 H-Bridge Driver

Dual H-bridge motor driver capable of up to 1.2 A continuous current per channel. Controls motor direction and speed via PWM signals from the MCU.

→ Datasheet / Purchase

Lithium Battery 18650

Rechargeable lithium-ion cell used as the external power source for the motor circuit. Note: our unit showed signs of wear during testing.

DC TT Motor — 6V / 200 RPM

Standard dual-shaft TT gear motor. Rated at 6V with a no-load speed of 200 RPM, common in robotics and educational kits.

→ Datasheet / Purchase

Motor measurement system — DRV8833, 18650 battery and TT motor

📏 2. Measurement Methodology

To analyze the system we connected two multimeters simultaneously — one to measure voltage and one to measure current at the same time.

Important distinction: Current (amperage) is not the same as resistance. Current is the flow of electric charge, while resistance opposes that flow. They require different measurement setups.
Measuring Current (Amperage)

Connected in series with the circuit. The multimeter in ammeter mode behaves almost like a wire — very low internal resistance so current passes through it without significantly altering the circuit.

Measuring Voltage

Connected in parallel with the motor. The multimeter in voltmeter mode has very high internal impedance, so it draws virtually no current and does not interfere with the circuit.

Two multimeters measuring voltage and current simultaneously Complete measurement circuit

ℹ️ How the System Works

The microcontroller sends PWM control signals to the DRV8833 driver. The driver then determines how much power from the external battery is delivered to the motor. When measuring voltage, the multimeter does not interfere due to its high impedance. When measuring current, the multimeter becomes part of the series circuit path — its resistance is minimal, ensuring accurate readings with negligible impact on the circuit.

⚙️ 3. Motor Control Explanation

Stepper Motors

Commonly used in CNC machines. They provide high precision and maintain accurate positions during rotation — ideal when exact angular displacement matters.

Power Control Elements
  • Transistors
  • MOSFETs
  • Solid-state relays (for AC loads)
H-Bridge (Puente H)

A circuit made of 4 transistors and 4 diodes that allows changing the direction of the motor by switching the current flow direction. The DRV8833 integrates two full H-bridges on a single chip.

〰️ Speed Control via PWM

Higher Duty Cycle → Higher Average Voltage → Higher Motor Speed

Motor speed is controlled using PWM (Pulse Width Modulation). The signal rapidly switches between ON and OFF at a fixed frequency — the ratio of ON time to total period is the duty cycle. The longer the signal stays "on" per cycle, the higher the average voltage delivered to the motor, and therefore the higher the speed and torque.

📊 4. Our Results

Note about our battery: At the beginning we observed that the 18650 battery was worn out. At a 25% duty cycle the average voltage it provided was not enough to drive the motor. We increased to 65% as the minimum effective threshold.
When the motor runs at higher speed, the current increases.
If mechanical load or pressure is applied to the motor, the current also increases.
The driver supplies power according to what the motor demands — not a fixed amount.
Observation Demo — Motor speed & current relationship
I (Current)0.042 A
V (Voltage)
P (Power)

The worn 18650 battery could not provide enough voltage at this duty cycle to spin the motor.

I (Current)0.084 A
V (Voltage)1.389 V
P = V × I0.1167 W
65% Duty Cycle — Minimum effective speed
I (Current)0.120 A
V (Voltage)1.38 V
P = V × I0.1656 W
I (Current)0.122 A
V (Voltage)4.2 V
P = V × I0.5124 W
~82.5% Duty Cycle — High speed measurement
I (Current)0.150 A
V (Voltage)7.15 V
P = V × I1.0725 W
100% Duty Cycle — Maximum speed & power
03
Individual Assignment

OLED Display on My Custom PCB

For the individual assignment I used my custom PCB from Week 8 and decided to connect the OLED display that will be part of my final project. The OLED display shows cycle status, product stock levels, reminders, and alerts — helping the user stay informed and supported.

My board uses the Seeed XIAO nRF52840, which natively supports I2C via its SDA (D4) and SCL (D5) pins. Since these pins were already exposed as accessible headers on my PCB design, I was able to connect the display directly — no additional wiring adaptations needed.

OLED on custom PCB

🖥️ OLED Display Overview

Display OLED 0.96" I2C 128×64 SSD1306

This is a compact monochrome OLED display driven by the SSD1306 controller. It communicates over I2C, meaning it only requires 2 data wires (plus power and ground) — making it very easy to integrate into any project.

Current OLED screen

Cycles automatically every 5 s · Click a thumbnail to preview

📡 I2C Protocol — SDA & SCL

I2C (Inter-Integrated Circuit) is a serial communication protocol that allows a microcontroller to talk to multiple peripheral devices using only two wires. This is what makes connecting the OLED so straightforward.

SDA — Serial Data Line

This line carries the actual data being transmitted. Both the master (XIAO) and any peripheral device (OLED) share this line. Data is sent bit by bit, and the direction alternates depending on whether the master is writing or reading.

On the XIAO nRF52840 → Pin D4

SCL — Serial Clock Line

This line carries the clock signal, generated exclusively by the master device. The clock pulses tell all devices on the bus exactly when to read or write each data bit — ensuring synchronized communication.

On the XIAO nRF52840 → Pin D5

How They Work Together

Each I2C device has a unique 7-bit address (the SSD1306 uses 0x3C by default). When the master wants to communicate, it sends the target address on the SDA line, synchronized with SCL clock pulses. Only the device with the matching address responds — which is why you can daisy-chain many devices on the same two wires.

🔌 Connection Table — OLED → My PCB

OLED PinMy PCB (Header)Notes
VCC3.3V (top-right header)Display runs on 3.3V — safe for XIAO logic
GNDGND (top or same header)Common ground
SDAD4I2C data line — native on XIAO nRF52840
SCLD5I2C clock line — native on XIAO nRF52840
OLED module front OLED module pinout

💻 The Code — 6 Rotating Screens

The program displays 6 different screens on the OLED, automatically cycling through them every 5 seconds using millis() for non-blocking timing. Each screen corresponds to a feature of my final HigiBox project:

  • Welcome message with smiley face
  • Stock alert with progress bar
  • Low-stock notice message
  • Current cycle day tracker
  • Motivational reminder with heart
  • Full stock status overview
Arduino / C++
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH,
  SCREEN_HEIGHT, &Wire, OLED_RESET);

int screenIndex = 0;
unsigned long lastSwitch = 0;
const unsigned long INTERVAL = 5000;

int stockDayPads    = 87;
int stockNightPads  = 42;
int stockPantyLiner = 12;
int cycleDay        = 3;

void setup() {
  Wire.begin();
  if (!display.begin(
    SSD1306_SWITCHCAPVCC, 0x3C))
    while (true);
  display.clearDisplay();
  display.display();
}

void loop() {
  if (millis() - lastSwitch
      >= INTERVAL) {
    lastSwitch = millis();
    screenIndex = (screenIndex+1) % 6;
  }
  switch (screenIndex) {
    case 0: screenWelcome();    break;
    case 1: screenStockAlert(); break;
    case 2: screenMessages();   break;
    case 3: screenCycleDay();   break;
    case 4: screenHydration();  break;
    case 5: screenStockAll();   break;
  }
  display.display();
  delay(100);
}

// Each screen function draws its
// own layout via Adafruit GFX calls
04
Technical Reference

XIAO nRF52840 — Electrical & Power Notes

🔌 Voltage & GPIO Limits

XIAO nRF52840 Pinout Diagram
I/O Pin Voltage — 3.3V Maximum

All I/O pins operate at 3.3V. Inputting more than 3.3V can permanently damage the CPU. This applies to all digital and analog pins.

GPIO Current — 15 mA Max per Pin

Each GPIO pin is limited to 15 mA maximum. Even a small vibration motor requiring 19 mA cannot be driven directly from a pin.

⚠️ You cannot connect a motor — even a tiny one — directly to a GPIO pin. You need a dedicated motor driver (DRV8833, L9110S, or MOSFET) between the XIAO and the motor.

😴 Deep Sleep

Ideal Deep Sleep — 5 µA

The board consumes only 5 µA in deep sleep mode — excellent for battery-powered wearables and IoT projects where standby efficiency matters.

Real-World with Peripherals

In practice, with peripherals attached (voltage dividers, sensors), real sleep consumption can rise to 300–600 µA depending on the circuit configuration.

🔋 Battery Management

The board includes a BQ25101 chip that supports battery charge management, compatible with a 3.7V Lithium-Ion battery — ideal for portable and wearable projects.

Quick Specs
  • CPU: ARM Cortex-M4 @ 64 MHz
  • GPIO: 11 digital (all PWM), 6 ADC
  • Wireless: Bluetooth 5.0, NFC, ZigBee
  • Logic: 3.3V strictly

🏎️ Motor Driver Recommendations

Since GPIO pins are limited to 15 mA, to drive motors you must use a dedicated driver. Common options compatible with the XIAO's 3.3V logic:

DriverMax Motor VoltageMax CurrentNotes
DRV883310V1.5A per channelGreat for small DC motors — used this week
L9110S12V800 mACheap and easy to use
TB6612FNG15V1.2A per channelVery popular, 3.3V logic friendly
MOSFET (e.g. 2N7000)Depends on FETDepends on FETFor simple on/off motor control

✅ Final Project To-Do

Action items for my final project based on what I learned this week:
  • Use an external power source for the motor — the XIAO cannot supply enough current (risk of damage).
  • Calculate the required voltage for the system. If sources are connected in series, voltages add up.
  • For each duty cycle, record: Voltage (V), Current (I), and calculate Power (P = V × I).
05
Downloads

Design Files

Get in Touch