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 PIR Experiment: Warm-up, Hold Time and Retriggering

A motion module often appears to work perfectly until it powers up at the wrong moment or stays high through several movements. Before connecting it to a lamp or room controller, use it as a timing experiment. The goal is to learn what the module’s output actually represents, how startup differs from normal operation, and which conclusions the software cannot support.

This design uses the Adafruit product ID 189 adjustable passive infrared (PIR) motion module, an original Raspberry Pi Pico with RP2040, and MicroPython 1.26.0. The Pico uses Universal Serial Bus (USB) for power and console output. A separate regulated 5.0 V low-voltage supply powers the sensor, with a shared ground and separate positive rails. It is an unbuilt design: host checks exercise the supplied state machine, not a physical PIR module or Pico firmware.

Parts, identity and the useful question

Part Purpose Check before use
Adafruit PID189 adjustable PIR module Provides a digital motion-related output and H/L retrigger setting. Record actual board markings, connector labels and jumper position.
Original Pico RP2040 Samples one digital input and prints observed intervals. Use the original Pico physical pin map and MicroPython1.26.0 baseline.
Regulated 5.0 V bench supply Powers the PIR module within its documented 5–12 V input range. Measure voltage and polarity before connection; use only the low-voltage output.
1 kΩ series resistor Connects module OUT to the Pico input. It is not a voltage divider or a power-off isolation device.
Short jumper leads and a fixed support Keep electrical connections and viewing geometry repeatable. Do not let a loose module move while comparing trials.

The exact module matters. Adafruit documents this product’s output as 3.3 V digital logic and its supply as 5–12 V. Those statements do not certify a generic board labelled HC-SR501, a relay module, an open-collector variant or another controller hidden under a familiar lens. This lesson does not identify the module’s controller or detector silicon by appearance. If the supplied board differs from the documented product, stop and establish its actual pin functions and levels first.

The question is deliberately narrower than “is anyone in the room?” A PIR module responds to changes in its infrared view. A stationary person can become invisible to this kind of motion indication. The program records intervals during which the module output is high; it does not report distance, continuous occupancy or the number of people.

Keep the 5 V supply away from the input

External regulated 5.0 V powers only the Adafruit PID189 positive terminal; its return joins module GND and original Pico GND physical18. Documented 3.3 V OUT passes through 1 kΩ to GP16 physical21 with an internal pull-down. Pico power comes separately from USB.
Original functional schematic with explicit supply and return paths. Printed module functions define the connections, not a guessed connector order. The two positive supply rails remain separate.
Net Connection Reason
Sensor power Regulated +5.0 V to module positive-power pin. Supply the module separately; leave its onboard regulator unmodified.
Common ground Supply return, module GND and Pico GND physical18. The signal needs one shared voltage reference.
Signal Module OUT → 1 kΩ → Pico GP16, physical21. GP16 is configured as a general-purpose input/output (GPIO) input with an internal pull-down.
Separate positive rails No connection from external +5 V to Pico VBUS, VSYS or 3V3. Avoid joining power-source outputs or backfeeding USB.

Wire with both supplies off. Check polarity, then power the Pico before the sensor. Once the sensor is powered, start or restart the logger so its 60-second wait begins after sensor power-up. Before attaching the signal to GP16, verify the actual module OUT level against ground and the Pico’s input requirements. Its documented high is 3.3 V; never apply the module’s 5 V supply to the input. Remove sensor power before removing Pico power so a powered output is not left driving an unpowered controller. The series resistor does not make an arbitrary 5 V signal safe and does not replace this power sequence.

The internal pull-down gives the Pico a default low when its signal lead is disconnected. That is useful for a quiet bench input, but it also makes disconnection look like an inactive sensor. This circuit has no separate power-good or continuity feedback. A low result is not evidence of healthy wiring. Check the module’s power and use a deliberate movement test when validating the setup.

Three time mechanisms that must stay separate

Startup stabilization: Adafruit advises allowing roughly 30–60 seconds after power-up and waiting for the output to settle. This application deliberately ignores the first 60 seconds after the program starts, even if the module was powered earlier. That conservative software policy is not a guarantee that every module and environment stabilizes within exactly one minute.

Module hold and retriggering: The module’s TIME control and H/L jumper shape the output before the Pico sees it. In H retrigger mode, repeated motion can extend one continuous high. In L non-retrigger mode, continuing movement can produce separated pulses. Read the actual labels, record settings and change the jumper with power off. Do not use the product page’s approximate timing description or the guide’s example component calculations as a calibrated promise for your particular unit.

Software qualification: After its warm-up, the program requires 500 milliseconds (ms) of observed low before arming. This is an application choice intended to prevent a startup high from becoming an ordinary event. It is not a new sensor specification or an electrical debounce filter. Once armed, the program tracks each observed high interval until a low is sampled.

Constructed Tracker timing: a startup HIGH is ignored, LOW from 60.000 s qualifies ARMED at 60.500 s, and the next HIGH at 60.510 s ends at 61.520 s for one 1010 ms observed interval. A separate 251 ms observation gap discards an open interval and requires 500 ms LOW before rearming.
Original constructed software-policy traces, not measured sensor pulse widths. A continuous HIGH is one observed interval; missing observations do not produce a fabricated FALL or a people count.

Complete logger with explicit loss handling

Save the complete Python program (ZIP; file: batch-005/code/pico-pir-warmup-retrigger.py) on the selected Pico. Run it directly, or rename it to main.py after reviewing the wiring. The loop requests a 10 ms sleep between observations. USB output, interpreter work and other delays add overhead; this is polling, not a hardware timestamp recorder.

"""Adafruit PID189 on original Pico / MicroPython1.26.0.
Logs observed output intervals, not people or occupancy. No hardware test claimed.
"""


class TickAccumulator:
    def __init__(self, ticks_ms, ticks_diff):
        self.ticks_ms, self.ticks_diff = ticks_ms, ticks_diff
        self.previous, self.elapsed = None, 0

    def __call__(self):
        raw = self.ticks_ms()
        if self.previous is not None:
            delta = self.ticks_diff(raw, self.previous)
            if delta < 0:
                raise ValueError('clock reversed or sampling exceeded ticks half-period')
            self.elapsed += delta
        self.previous = raw
        return self.elapsed


class Tracker:
    WARMUP_MS, QUIET_MS, MAX_GAP_MS = 60000, 500, 250

    def __init__(self):
        self.started = self.last_at = self.quiet_since = self.rise_at = None
        self.armed, self.intervals = False, 0

    def feed(self, level, now):
        if level not in (0, 1):
            raise ValueError('input must be 0 or 1')
        if not isinstance(now, int) or now < 0:
            raise ValueError('time must be a nonnegative integer')
        if self.last_at is not None and now < self.last_at:
            raise ValueError('time reversed')
        if self.started is None:
            self.started = now
        gap = self.last_at is not None and now - self.last_at > self.MAX_GAP_MS
        lost = gap and self.rise_at is not None
        if gap:
            self.armed, self.quiet_since, self.rise_at = False, None, None
        self.last_at = now
        event, duration = None, None
        if now - self.started < self.WARMUP_MS:
            self.armed, self.quiet_since, self.rise_at = False, None, None
            phase = 'WARMUP'
        elif not self.armed:
            if level:
                self.quiet_since = None
            elif self.quiet_since is None:
                self.quiet_since = now
            elif now - self.quiet_since >= self.QUIET_MS:
                self.armed = True
            phase = 'ARMED' if self.armed else 'WAIT_LOW'
        elif level and self.rise_at is None:
            self.rise_at = now
            self.intervals += 1
            event, phase = 'RISE', 'HIGH'
        elif not level and self.rise_at is not None:
            duration = now - self.rise_at
            self.rise_at = None
            event, phase = 'FALL', 'ARMED'
        else:
            phase = 'HIGH' if self.rise_at is not None else 'ARMED'
        return {'elapsed_ms': now, 'phase': phase, 'raw_level': level,
                'event': event, 'interval_ms': duration,
                'observed_high_intervals': self.intervals,
                'sampling_gap': gap, 'lost_interval': lost}


def run(read_pin, clock, sleep_ms, emit=print, cycles=None):
    tracker = Tracker()
    count, last_report, previous_phase = 0, None, None
    while cycles is None or count < cycles:
        try:
            now = clock()
            result = tracker.feed(read_pin(), now)
        except (OSError, ValueError) as exc:
            # Do not query a failed clock again or call missing input LOW.
            emit({'phase': 'INPUT_OR_CLOCK_ERROR', 'raw_level': None,
                  'event': None, 'interval_ms': None, 'error': str(exc)})
            break
        if (result['event'] or result['sampling_gap'] or
                result['phase'] != previous_phase or last_report is None or
                now - last_report >= 1000):
            emit(result)
            last_report = now
        previous_phase = result['phase']
        count += 1
        sleep_ms(10)
    return tracker


def main():
    from machine import Pin
    from time import ticks_ms, ticks_diff, sleep_ms
    pir = Pin(16, Pin.IN, Pin.PULL_DOWN)
    print('PID189: 60 s warm-up, then 500 ms observed LOW before arming.')
    print('Intervals are output-high periods, never a people count.')
    run(pir.value, TickAccumulator(ticks_ms, ticks_diff), sleep_ms)


if __name__ == '__main__':
    main()

The output includes the current raw level, phase, elapsed milliseconds, RISE or FALL when present, an interval duration on a normal fall, and the number of observed high intervals begun since startup. For an illustrative trace with a sampled rise at 61,200 ms and fall at 64,700 ms, the reported duration is 64,700 − 61,200 = 3,500 ms. Those are hypothetical timestamps explaining the calculation, not bench data. Each transition is observed only when polled; a pulse entirely between reads can be missed.

A delay exceeding 250 ms is treated as a loss of continuity. The tracker discards any open interval, sets lost_interval when appropriate, and returns to WAIT_LOW. It never invents a falling edge or a complete duration across the missing observations. A new continuous observed-low qualification is then required. The 250 ms limit is an application validity policy; it is not a timing accuracy claim. A short low/high excursion between apparently consecutive samples can remain invisible even when no gap is flagged.

TickAccumulator uses MicroPython’s ticks_diff to handle the clock counter wrapping. The polling interval must remain within the clock’s documented half-period; a negative difference is rejected. The wrapper does not magically recover an arbitrary long suspension. An input or clock application programming interface (API) error prints INPUT_OR_CLOCK_ERROR with no current level and ends the loop without querying a failed clock again. Fix the cause, then restart the program to repeat warm-up. If the sensor itself loses power while the Pico stays on, this wiring cannot automatically recognize that event: restore power, restart this program, wait for qualification and repeat the movement test.

Compare the settings before choosing an application

  1. Write down the exact module markings, supply voltage, viewing direction, H/L setting and approximate TIME-control position. Do not call a knob position a calibrated number of seconds.
  2. Start with the shortest practical hold setting, leave the field quiet and power up in the stated order. Confirm WARMUP, then WAIT_LOW, then ARMED. If the output remains high, WAIT_LOW should persist without fabricating a normal interval.
  3. Move once across the field, then become still or leave the view. Record rise, fall and observed duration. Repeat with the same path and geometry; variation is part of the result.
  4. With power off, select the other H/L position. Repeat several movements before the output falls. Compare continuous high intervals with separated pulses. Keep the distinction between a motion episode and an output interval in your notes.
  5. Repeat after a controlled TIME adjustment while leaving position and path unchanged. Return to an earlier setting to check whether your comparison is reproducible.
  6. In a diagnostic session, pause the program for more than 250 ms during a high interval. On return, expect sampling_gap and lost_interval rather than a completed duration. Let the output become quiet before rearming.
  7. Power off the sensor before disconnecting its OUT lead. On restarting with that lead absent, the pull-down can produce low and eventually ARMED. This demonstrates why a quiet input alone is not a sensor-health test; restore and revalidate the wiring afterwards.

The blank bench sheet (ZIP; file: batch-005/code/pico-pir-warmup-retrigger-observations-blank.csv) has no results. The author’s 25 host checks exercise the actual supplied tracker and loop with synthetic startup, repeated pulses, lost intervals, quiet qualification, clock wrap, reverse time and API faults. They do not characterize a module, compile Pico firmware or execute this program on a microcontroller. Physical results belong in the sheet only after someone performs the corresponding trial.

Use the result carefully in later projects

This experiment prepares useful input behavior for room projects in the site’s electronics lessons. A later light controller can choose a separate hold timer based on observed motion. Keep that application timer distinct from the sensor’s own output hold, and retain a manual way to observe raw levels. Environmental changes, moving warm objects and placement can affect trials. Diagnose with recorded settings and repeatable paths before changing several software constants at once.

Challenge: H mode gives one 25-second high interval while L mode gives four short intervals for the same walking trial. Which mode counted the person correctly? Answer: Neither produced a people count. They shaped a motion-related output differently. Counting intervals is a faithful software observation; translating those intervals into people requires another measurement method and separate validation.

Primary sources and variant limits

Source review: 20 October 2026. No separate PID189 errata bulletin was identified in the checked product and guide links. That does not establish a fixed internal bill of materials or guarantee that no later errata exists.

📡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