home / skills / wedsamuel1230 / arduino-skills / circuit-debugger

circuit-debugger skill

/skills/circuit-debugger

This skill guides you through systematic hardware debugging for Arduino projects, enabling power checks, signal tracing, and component isolation with

npx playbooks add skill wedsamuel1230/arduino-skills --skill circuit-debugger

Review the files below or copy the command above to add this skill to your agents.

Files (6)
SKILL.md
7.2 KB
---
name: circuit-debugger
description: |
  Systematic hardware debugging guide for Arduino/ESP32/RP2040 circuits. Use when user reports: circuit not working, components getting hot, no power, intermittent failures, unexpected behavior, sensor not responding, LED not lighting, motor not spinning. Guides through power checks, continuity testing, signal tracing, and component isolation using multimeter techniques.
---

# Circuit Debugger

Systematic approach to diagnosing hardware issues in maker projects.

## Resources

This skill includes bundled tools and references:

- **scripts/generate_debug_sketch.py** - Arduino sketch generator for I2C scanner, GPIO tester, ADC checker, PWM tester
- **references/measurement-procedures.md** - Comprehensive multimeter and oscilloscope guide

## Quick Start

**Generate I2C scanner:**
```bash
uv run --no-project scripts/generate_debug_sketch.py --i2c --output i2c_scanner.ino
```

**Generate GPIO tester:**
```bash
uv run --no-project scripts/generate_debug_sketch.py --gpio --pins 2,3,4,5 --output gpio_test.ino
```

**Generate all debug sketches:**
```bash
uv run --no-project scripts/generate_debug_sketch.py --all
```

**Interactive mode:**
```bash
uv run --no-project scripts/generate_debug_sketch.py --interactive
```

## Trigger Phrases
- "My circuit doesn't work"
- "Component is getting hot"
- "No power to the board"
- "Sensor not responding"
- "Intermittent/random failures"
- "Works sometimes, not others"

## Debugging Protocol

### Phase 1: Power System Check (Do First!)

**Visual Inspection (30 seconds)**
```
□ Check for smoke, burn marks, or melted plastic
□ Verify power LED on microcontroller is lit
□ Look for loose wires or cold solder joints
□ Confirm correct polarity on polarized components (LEDs, caps, diodes)
```

**Multimeter Tests (Set to DC Voltage)**
```
Test Point              | Expected Value  | If Wrong
------------------------|-----------------|------------------
VCC to GND on MCU       | 3.3V or 5V      | Check regulator, power source
Sensor VCC pin          | Match datasheet | Check wiring, broken trace
Motor driver VCC        | Logic + Motor V | Separate supplies needed?
Battery terminals       | Rated voltage   | Dead/discharged battery
```

**Common Power Issues:**
| Symptom | Likely Cause | Fix |
|---------|--------------|-----|
| No voltage anywhere | Disconnected power, blown fuse | Check continuity from source |
| Low voltage (< 4V when expecting 5V) | Overloaded supply, bad regulator | Reduce load, check current draw |
| Voltage drops under load | Undersized power supply | Calculate total current, upgrade PSU |
| Reverse polarity | Swapped wires | Check all connections, may have damaged components |

### Phase 2: Ground Continuity

**Critical Rule:** All grounds must be connected together.

```
Multimeter: Set to CONTINUITY (beep mode)

Test these pairs - ALL should beep:
□ Arduino GND ↔ Sensor GND
□ Arduino GND ↔ Motor driver GND  
□ Arduino GND ↔ Display GND
□ Arduino GND ↔ Power supply negative
□ All breadboard GND rails connected
```

**Ground Problems Cause:**
- Erratic sensor readings
- I2C/SPI communication failures
- Motors behaving randomly
- Displays showing garbage

### Phase 3: Signal Verification

**Digital Signals (Set multimeter to DC Voltage)**
```cpp
// Add this debug code to verify pin states
void debugPins() {
    Serial.println("=== Pin States ===");
    Serial.print("D2: "); Serial.println(digitalRead(2) ? "HIGH" : "LOW");
    Serial.print("D3: "); Serial.println(digitalRead(3) ? "HIGH" : "LOW");
    // Add more pins as needed
}
```

**Expected Readings:**
| Signal Type | HIGH | LOW | Floating (Bad!) |
|-------------|------|-----|-----------------|
| 5V Logic | 4.5-5.5V | 0-0.5V | 1-3V unstable |
| 3.3V Logic | 2.8-3.6V | 0-0.3V | 0.8-2V unstable |

**I2C Troubleshooting:**
```cpp
// Run this I2C scanner first
#include <Wire.h>

void setup() {
    Serial.begin(115200);
    Wire.begin();
    
    Serial.println("I2C Scanner");
    for (uint8_t addr = 1; addr < 127; addr++) {
        Wire.beginTransmission(addr);
        if (Wire.endTransmission() == 0) {
            Serial.print("Found device at 0x");
            Serial.println(addr, HEX);
        }
    }
}
void loop() {}
```

| I2C Problem | Check |
|-------------|-------|
| No devices found | SDA/SCL swapped? Pull-ups present? Correct address? |
| Address conflict | Two devices same address? Check AD0/AD1 pins |
| Intermittent | Weak pull-ups (try 4.7kΩ), long wires, noise |

### Phase 4: Component Isolation

**The Divide-and-Conquer Method:**
```
1. Disconnect ALL external components
2. Verify MCU works alone (blink LED)
3. Add ONE component at a time
4. Test after EACH addition
5. When failure occurs, problem is last added component
```

**Component-Specific Tests:**

**LEDs:**
```
□ Correct polarity? (long leg = anode = positive)
□ Current limiting resistor present? (330Ω-1kΩ typical)
□ Test LED alone with battery + resistor
□ PWM pin? Try digitalWrite first
```

**Motors/Servos:**
```
□ Never connect directly to MCU pin (use driver!)
□ Separate power supply for motors
□ Flyback diode on DC motors
□ Check stall current vs driver rating
```

**Sensors:**
```
□ Correct operating voltage (3.3V vs 5V!)
□ Level shifter needed for mixed voltage?
□ Decoupling capacitor (100nF) near VCC pin
□ Pull-up resistors for I2C (4.7kΩ typical)
```

### Phase 5: Software vs Hardware

**Quick Software Test:**
```cpp
// Minimal test - does the MCU even run?
void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
    Serial.begin(115200);
    Serial.println("MCU is alive!");
}

void loop() {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
    Serial.println("heartbeat");
}
```

| If This Works | If This Fails |
|---------------|---------------|
| Hardware likely OK, check your code | Check USB cable, bootloader, board selection |

## Quick Reference: Common Failures

| Symptom | First Check | Second Check | Third Check |
|---------|-------------|--------------|-------------|
| Nothing works | Power supply | USB cable | Board selection in IDE |
| Gets hot | Short circuit | Reversed polarity | Overcurrent |
| Works then stops | Power brownout | Overheating | Memory leak |
| Erratic behavior | Floating inputs | Missing grounds | Noise/interference |
| I2C fails | Pull-ups | Address | Wire length |
| Motor jerky | Power supply | PWM frequency | Driver current |

## Multimeter Quick Guide

```
Measurement    | Setting      | Probes
---------------|--------------|------------------
DC Voltage     | V⎓ (20V)     | Red=signal, Black=GND
Continuity     | ))) or Ω     | Either direction
Resistance     | Ω            | Component out of circuit!
Current        | A or mA      | IN SERIES (break circuit)
```

## When to Ask for Help

If after this protocol you still can't find the issue:
1. Take clear photos of your wiring
2. Draw a schematic (even hand-drawn)
3. List exact components with part numbers
4. Share your complete code
5. Describe what you expected vs what happened

## References
- See [references/multimeter-guide.md](references/multimeter-guide.md) for detailed measurement techniques
- See [references/common-mistakes.md](references/common-mistakes.md) for beginner pitfall gallery

Overview

This skill is a systematic hardware debugging guide for Arduino, ESP32, and RP2040 circuits. It helps makers diagnose power, grounding, signal, and component faults using step-by-step multimeter and isolation techniques. The goal is to get you from symptom to root cause quickly and safely.

How this skill works

The guide walks through five focused phases: power checks, ground continuity, signal verification, component isolation, and differentiating hardware vs software issues. It explains what to measure, expected values, and concrete fixes for common failures like no power, hot components, intermittent behavior, and nonresponsive sensors. Included are practical multimeter procedures, simple test sketches to upload, and a divide-and-conquer workflow for isolating faults.

When to use it

  • When a board shows no power or wrong voltage levels
  • If components are heating or drawing excessive current
  • When sensors, displays, or motors do not respond
  • For intermittent or random failures that are hard to reproduce
  • When I2C or other buses show communication errors

Best practices

  • Start with a fast visual inspection for damage or reversed polarity
  • Always verify VCC and GND voltages before probing signals
  • Ensure all grounds are common and check continuity with beep mode
  • Isolate the MCU by disconnecting external modules and add parts one-by-one
  • Use proper current-rated supplies and separate motor power from logic

Example use cases

  • Diagnose a sensor that returns no data: check VCC, GND, pull-ups, and run an I2C scan
  • Fix a motor that stalls or jerks: confirm driver wiring, add flyback diode and separate supply
  • Resolve an LED that won’t light: verify polarity, resistor, and PWM vs digitalWrite behavior
  • Track intermittent resets: measure voltage under load to find brownouts
  • Validate pin states with a simple heartbeat sketch to distinguish software from hardware

FAQ

What voltage should I expect on logic pins?

Expect ~4.5–5.5V for 5V logic and ~2.8–3.6V for 3.3V logic as HIGH; LOW should be near 0V.

Why do I2C devices sometimes disappear?

Common causes are SDA/SCL swapped, missing pull-ups, address conflicts, long noisy cables, or weak pull-ups—try a scanner and 4.7kΩ pull-ups.

How do I safely measure current?

Measure current in series with the load using the proper meter input and range. Never place the meter across a power supply like a short.