ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
rcwl0516.h File Reference

RCWL-0516 microwave Doppler presence sensor, and the shared one-GPIO presence facade (PC_ENABLE_RCWL0516). More...

#include "protocore_config.h"

Go to the source code of this file.

Detailed Description

RCWL-0516 microwave Doppler presence sensor, and the shared one-GPIO presence facade (PC_ENABLE_RCWL0516).

The RCWL-0516 (RCWL-9196 controller + MMBR941M RF amp, ~3.18 GHz Doppler) has no data protocol at all: a single 3.3 V OUT pin that latches HIGH when a moving reflector is detected and returns LOW once its own retrigger window expires. Everything interesting is therefore in time, not in bytes - which is what this module provides.

Two problems a bare digitalRead() does not solve, and this does:

  1. Chatter. The OUT pin is driven by an analog comparator, so around the detection threshold it can flicker. A raw read turns one person walking past into a burst of presence events. A level must therefore hold for PresenceCore::debounce_ms before it is believed.
  2. Gaps. The module drops OUT between retriggers, so a person who is present but briefly still reads as absent for a moment. Presence is therefore held for PresenceCore::hold_ms past the last believed-HIGH sample, which turns a stream of retriggers into one continuous "occupied" span instead of a flapping boolean.

The core is pure and takes an explicit now, exactly like services/hotswap: it decides, the binding acts. That makes the whole machine host-testable by injecting pin levels against a synthetic clock, with no GPIO and no real time involved. All timing comparisons are unsigned differences, so they are wrap-safe across a millis() rollover.

PresenceCore is deliberately sensor-agnostic: it is a debounced, hold-extended view of one active-high presence pin. The RCWL-0516 is simply its first user, via the pc_rcwl0516_core_init defaults - the HMMD's OUT pin, a PIR, or an HB100 can reuse the same core by supplying their own two constants.

Fail-safe start: a freshly initialized core reports absent and treats the pin as idle, so presence is only ever reported after it has actually been observed and believed. Claiming presence you have not yet measured is the failure mode worth avoiding.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file rcwl0516.h.