# Example 49: 433MHz RF Module

Use common 433MHz OOK/EV1527/PT2262 transmitter modules to send remote control codes. You can also configure a receiver module as a level-monitoring input. FastBee has a built-in `RF_MODULE` peripheral type with type ID `48`, no additional RF library required.

## Wiring

| Module Pin | ESP32/ESP32-S3 | Description |
|-----------|-----------------|-------------|
| VCC | 3.3V or module-required power | Power supply per module rating |
| GND | GND | Common ground required |
| DATA / DIN / ATAD | GPIO4 example | Transmit mode cannot use input-only GPIOs |
| ANT | Antenna | Recommend ~17cm wire or matching antenna |

The receiver module uses `mode=1`, connect DATA/OUT to an input-capable GPIO.

## Peripheral Execution for Transmit

Add a new peripheral execution rule, select **Call Other Peripheral** for the action, target `rf_tx_01`, and fill in the action value:

```json
{"periphId":"rf_tx_01","action":"send","code":"0xA1B2C3","bits":24,"pulseWidth":350,"repeat":8}
```

`code` supports decimal, `0x` hex, and `0b` binary. Most 433MHz remotes use 24-bit codes. Keep default parameters for initial testing; adjust `pulseWidth` if triggering fails.

## Receiver Level Monitoring

If using a receiver module, add an RF peripheral with `mode=1`:

```json
{
  "id": "rf_rx_01",
  "name": "433M Receiver Level",
  "type": 48,
  "enabled": true,
  "pins": [16],
  "params": {
    "mode": 1,
    "activeHigh": true
  }
}
```

Use **Sensor Read** in peripheral execution:

```json
{
  "periphId": "rf_rx_01",
  "sensorCategory": "rf",
  "dataField": "value",
  "sensorLabel": "RF Level",
  "unit": "",
  "decimalPlaces": 0
}
```

After reading, `ds:rf_rx_01_value` is generated with value `1` or `0`. The current built-in receiver mode is for level monitoring only and does not perform full remote code learning/decoding. For code learning, use a matching learning remote or logic analyzer to obtain the code first.

## Debug Interface

```http
POST /api/peripherals/write
Content-Type: application/x-www-form-urlencoded

id=rf_tx_01&code=0xA1B2C3&bits=24&pulseWidth=350&repeat=8
```

## Notes

* Do not select GPIO34-39 or other input-only pins for transmit, nor Flash/PSRAM reserved pins.
* RF modules are sensitive to power supply and antenna. Test at close range first, then adjust antenna and installation position.
* Do not transmit continuously at high frequency. Use peripheral execution rules with event-triggered or low-frequency timer-triggered mode.
