# Example 50: Radar Sensor Module

Supports RCWL-0516 microwave radar, 5.8GHz human presence/motion radar, and other modules with `OUT` digital output. FastBee has a built-in `RADAR_SENSOR` peripheral type with type ID `49`, and the read result is `1/0`.

## Wiring

Using RCWL-0516 as an example:

| Module Pin | ESP32/ESP32-S3 | Description |
|-----------|-----------------|-------------|
| 3V3 | 3.3V | Module 3.3V output or power pin, wire per actual labeling |
| GND | GND | Common ground required |
| OUT | GPIO16 example | Default outputs HIGH when target detected |
| VIN | 4-28V | Note power range when using VIN supply |
| CDS | Optional | Can connect photoresistor control, per module documentation |

For 5.8GHz radar modules with only `VCC/GND/OUT`, connect `OUT` to an input GPIO.

## Peripheral Execution Read

Add a new peripheral execution rule, select **Sensor Read**:

```json
{
  "periphId": "radar_01",
  "sensorCategory": "radar",
  "dataField": "presence",
  "sensorLabel": "Radar Presence",
  "unit": "",
  "decimalPlaces": 0
}
```

After execution, data source `ds:radar_01_presence` is written:

| Value | Meaning |
|-------|---------|
| `1` | Motion or presence detected |
| `0` | Not detected |

## Linkage Example

Turn on relay when someone is present:

1. Create a timer-triggered rule to perform radar read every 1-2 seconds.
2. Create an event-triggered rule, event select `ds:radar_01_presence`, condition `= 1`.
3. Select relay peripheral for action, set HIGH or LOW depending on relay active level.

## Debug Interface

```http
GET /api/peripherals/status?id=radar_01
```

The `detected` and `value` fields in the response can be used to confirm module output.

## Installation Tips

* Do not cover the radar antenna area with metal enclosure. Point the sensing surface toward the detection area during installation.
* RCWL-0516 default detection range is several meters. Output stays HIGH for a period before pulling LOW — this is the module's own behavior.
* If the module outputs LOW to indicate detection, uncheck "OUT HIGH indicates detection".
* Radar penetrates thin plastic and cardboard more easily than PIR, and is more affected by installation environment. Perform final threshold and delay testing after fixed installation.
