Supplier photo of an assembled infinity mirror light cube illuminated on a dark background.
Supplier photo
Temu affiliate offer · Project idea

Build an infinity light cube

Listing specifies 5-volt direct current. Soldering required; battery and glue not included.

View kit on Temu

Tricky Circuit may earn a commission through these links. Product ideas have not been bench-tested by Tricky Circuit and are not verified lesson parts lists.

Pico Fan Tachometer: Count Pulses Without Guessing the Interface

Counting a fan’s tachometer pulses is a useful introduction to measuring a rotating machine without attaching anything to its shaft. The important first step is identifying the electrical signal. A fan power wire, speed-control input and speed-reporting output do three different jobs, even when they share one connector.

Noctua NF-A4x10 5V PWM receives separate 5 V power. Green tach pin 3 reaches Pico GP16 with 10 kΩ pullup to Pico 3.3 V; grounds join, blue PWM pin 4 remains unconnected.
Original Tricky Circuit connection diagram. Labels identify physical pins and supply rails; this is a locally reviewed design, not a measured prototype. Open full-size schematic

Use a documented four-wire fan

This circuit specifies the Noctua NF-A4x10 5V PWM. The similar-looking 12 V and 24 V versions need different motor supplies; the name’s 5V suffix is part of the design. PWM means pulse-width modulation, a control method that varies how long a repetitive signal is high. We leave that input disconnected and measure the resulting rotation; the project is a tachometer, not a closed-loop speed controller.

Noctua documents two tachometer cycles per revolution and an open-collector output. Open collector means a transistor pulls the signal low or releases it; an external pullup establishes the high level. This lets the motor use 5 V while the signal pullup uses Pico’s 3.3 V. It does not make an unknown fan’s output automatically compatible with a Pico.

Parts and equipment

  • Noctua NF-A4x10 5V PWM, specifically the 5 V four-wire version; original Pico RP2040 with MicroPython 1.26.0.
  • Regulated 5 V fan supply rated at least 0.5 A, a 10 kΩ resistor, suitable connector breakout, short wires and secure fan mounting with guard. Pico powered separately by USB.

Every connection

Pin or partConnection and purpose
Fan motor supplyFan pin 1 black → external supply ground; pin 2 yellow → external +5 V. Do not power the motor from Pico 3V3. Verify keyed connector orientation from manufacturer drawing.
Common referenceExternal supply ground → Pico GND physical 23. Only grounds join; external +5 V does not connect to Pico VBUS or 3V3.
Tach signalFan pin 3 green → Pico GP16 physical 21; 10 kΩ from that signal to Pico 3V3 OUT physical 36.
Speed-control inputFan pin 4 blue PWM left unconnected. This lesson reads speed at the fan’s default full-speed command; it does not generate PWM.

Keep power and signal roles separate

The fan’s motor current comes from its external 5 V supply. Pico is powered from USB. Joining their grounds gives the signal a shared reference, but the two positive supply rails remain separate. Do not connect a fan motor to a programmable pin. Check the keyed connector and manufacturer’s pin numbering; wire colour alone is not sufficient evidence for an unidentified replacement fan.

The 10 kΩ signal resistor limits low-state pullup current to 3.3/10000 = 0.33 mA, below the documented 5 mA tach output limit for this 5 V fan family. A smaller resistor would increase current and can improve a long line’s rise time, but this short bench connection has no reason to approach the limit. Long cables and electrically noisy environments need a separate signal-integrity review.

Secure the small fan and use a guard. Keep loose wires and the breadboard clear of its blades. For a no-pulse experiment, remove motor power using the supply control; do not jam the rotating blades. Leave the blue control wire isolated so it cannot accidentally short to another pin.

Count one kind of edge

RPM means revolutions per minute. With two cycles per revolution, counting falling edges gives two events for each turn. Counting both rising and falling edges without changing the divisor would double the displayed RPM. The supplied program attaches a hard interrupt to GP16’s falling edge and increments a small bounded counter.

Every approximately two seconds, the main loop briefly disables interrupts, copies and clears the count, and records the actual elapsed milliseconds. It then restores the previous interrupt state. The callback performs no printing and keeps its integer bounded; these choices reduce inappropriate work in an interrupt. They do not guarantee perfect capture during every possible interpreter or electrical disturbance.

The equation is RPM = count × 60000/(elapsed_ms × pulses_per_revolution). For 320 pulses in 2000 ms with two pulses per turn, the result is 4800 RPM. One additional counted pulse changes a two-second result by 15 RPM. That is count quantization, the smallest count step for this window, before oscillator error, missed edges and real speed variation.

Complete program

"""Pico RP2040 + Noctua NF-A4x10 5V PWM. Tach only, no speed control."""
def rpm(count, elapsed_ms, pulses_per_rev=2):
    if count < 0 or elapsed_ms <= 0 or pulses_per_rev <= 0:
        raise ValueError('invalid sample')
    return count * 60000 / (elapsed_ms * pulses_per_rev)

def main():
    from machine import Pin, disable_irq, enable_irq
    from time import ticks_ms, ticks_diff, sleep_ms
    import micropython
    micropython.alloc_emergency_exception_buf(100)
    count = [0]
    def pulse(pin):
        # Bounded small integer; no printing/allocation in hard interrupt.
        count[0] = (count[0] + 1) & 0xffff
    tach = Pin(16, Pin.IN)
    tach.irq(handler=pulse, trigger=Pin.IRQ_FALLING, hard=True)
    last = ticks_ms(); empty_windows = 0
    while True:
        sleep_ms(2000)
        irq_state = disable_irq()
        now = ticks_ms(); n = count[0]; count[0] = 0
        enable_irq(irq_state)
        duration = ticks_diff(now, last); last = now
        empty_windows = empty_windows + 1 if n == 0 else 0
        print('pulses:', n, 'window_ms:', duration, 'RPM:', round(rpm(n,duration),1))
        if empty_windows >= 2:
            print('NO TACH PULSES: stopped, unpowered, disconnected or faulty; not a diagnosis')
if __name__ == '__main__':
    main()

Interpret a quiet wire carefully

The loop counts empty windows. After two consecutive zero-count windows it prints NO TACH PULSES and lists several possible causes. An unpowered fan, disconnected signal, wiring fault and stopped rotor all produce no useful pulse stream. A flat signal is therefore an observation, not a complete diagnosis of a mechanical stall.

The first window after starting or stopping the fan can contain a mixture of states. It represents an average pulse rate over that whole interval. This program does not claim an instantaneous speed. A longer window produces smaller count steps but slower response; a period measurement between edges is an alternative with different behavior at very low speed and at startup.

A reproducible first run

  1. With both supplies disconnected, check connector orientation, positive rails, common ground and pullup. Confirm the exact 5 V fan marking. Install MicroPython 1.26.0 on an original Pico and save the listing as main.py.
  2. Power Pico first. With fan power absent, observe zero pulse windows and the explicit no-pulse message. This is a communication observation; it is not a fault in a motor that has no supply.
  3. Apply the regulated 5 V motor supply. Record at least ten windows, including pulse counts and actual durations. Compare the settled readings with the manufacturer’s nominal speed range, allowing its tolerance and the measurement limits.
  4. Remove motor power through the supply control while leaving the Pico and common ground connected. Record the coast-down and the delay before two empty windows appear.
  5. Power everything down before disconnecting the tach wire. Restart the controller with the pullup still fitted and confirm the same no-pulse observation. Reconnect before further rotation tests.

What to record before using it for supervision

Save the fan’s full part number, supply voltage under load, count window, interpreter version, pulse polarity and pulses-per-revolution assumption. If you have a logic analyser or oscilloscope suitable for 3.3 V signals, compare waveform edge counts with software counts. A host calculation cannot establish that every physical edge reached the interrupt.

The counter wraps at 65536. At the intended roughly 167 pulses per second and two-second windows this is far away, but it is still a design bound: do not attach a high-frequency source and assume it is a general counter. The tests validate conversion and bad-argument handling, while callback capture remains a target bench check. This circuit has not been physically tested.

Challenge: the display reads twice the expected speed. What two assumptions should you check first?

Check whether you counted both edges and whether the fan really supplies two pulses per revolution. Correct wiring does not compensate for the wrong event divisor.

Sources and related lessons

Continue with why a voltage divider drops under load, measuring current through a resistor with a voltmeter, and the interactive circuit lessons.

📡Broadcast the signal — amplify the connection.

Leave a Reply

Temu affiliate offers

Find your next electronics project

Explore these do-it-yourself project kits. Check the selected option, included parts and instructions on each offer.

Tricky Circuit may earn a commission if you buy through these Temu affiliate links. These are product ideas; they have not been bench-tested by Tricky Circuit and are not verified lesson parts lists.

Supplier photo of a breadboard, jumper wires and assorted electronic components in a plastic storage case.

Supplier product photo

Try breadboard experiments

Breadboard, wires and assorted parts. Arduino controller board not included.

View kit on Temu

Supplier photo of an assembled blue surface-mount soldering practice board with a circular ring of small lights.

Supplier product photo

Solder a chasing-light board

Surface-mount soldering practice. Battery and battery holder not included.

View kit on Temu

Supplier photo of an assembled two-wheeled line-following car with a blue circuit board, two motors and an empty battery holder.

Supplier product photo

Build a line-following car

Soldering and assembly required. Check battery and track requirements before buying.

View kit on Temu