Example 21: IR Remote Control
Example 21: IR Remote Control
Experiment Overview
Receive infrared remote control signals via an IR receiver (e.g., VS1838B), decode and trigger device actions. FastBee has a built-in IR_REMOTE driver in Standard firmware and esp32-F8R4 Full firmware, supporting NEC, RC5, SONY and other protocol auto-decoding.
Note: IR remote requires compile switch
FASTBEE_ENABLE_IR_REMOTE=1. ESP32-S3 Full currently has this switch disabled by default, prefer Standard firmware.ESP32-S3 RMT Driver Configuration: ESP32-S3's RMT driver has legacy vs. new version conflicts. If enabling IR in custom S3 firmware, both configurations must be handled:
-DCONFIG_RMT_ENABLE=0 -DIR_USE_GPIO=1If using other environments and need IR, ensure the above compile flags are added.
Hardware Wiring
| Board Label | GPIO Pin | Connected Device |
|---|---|---|
| IR_RX | GPIO15 | VS1838B IR receiver (OUT pin) |
VS1838B wiring: VCC→3.3V, GND→GND, OUT→GPIO15.
JSON Configuration Example
{
"peripherals": [
{
"id": "ir_recv",
"name": "IR Receiver",
"type": 38,
"enabled": false,
"pins": [15],
"params": {
"category": "ir_remote"
}
}
]
}Peripheral Execution Linkage
Scenario 1: Remote Button Controls LED (Event Trigger)
Function: Toggle LED state on any button press
Web Interface Configuration Steps
Step 1: Ensure LED peripheral is configured
- Peripheral ID:
led_d1 - Type: GPIO Output
Step 2: Create Rule
- Click left menu Peripheral Configuration → Switch to Peripheral Execution Management tab
- Click New Rule button
- Fill in basic configuration:
- Rule Name:
IR Control LED - Report Data: ✅ Enable
- Enabled: ✅ Enable
- Rule Name:
Step 3: Configure Trigger (Event Trigger)
Click Add Trigger button
Fill in trigger configuration:
Field Value Description Trigger Type Select Event Trigger Respond to IR events Event Type 125IR key value receive event Event Source ir_recvIR receiver peripheral ID
Step 4: Configure Action
Click Add Action button
Fill in:
- Action Type: Select Toggle Level
- Target Peripheral: Select
led_d1
Click Save button
Scenario 2: Different Buttons Different Actions (Event Trigger + Script)
Function: Button 1 turns on light, Button 2 turns off light
Web Interface Configuration Steps
- Create rule, name:
IR Multi-Function Control - Trigger configuration:
- Trigger Type: Select Event Trigger
- Event Type:
125 - Event Source:
ir_recv
- Action configuration:
- Action Type: Select Command Script
- Action Params:
var code=event.data.code; if(code==0xFF30CF){gpioWrite('led_d1',0);} // Button 1: Light on if(code==0xFF18E7){gpioWrite('led_d1',1);} // Button 2: Light off - Click Save
Common Remote Control Key Values (NEC Protocol)
| Button | Key Value | Description |
|---|---|---|
| 1 | 0xFF30CF | Number key 1 |
| 2 | 0xFF18E7 | Number key 2 |
| 3 | 0xFF7A85 | Number key 3 |
| OK | 0xFF02FD | Confirm key |
| ▲ | 0xFF629D | Up |
| ▼ | 0xFFA857 | Down |
💡 Tip: Different brand remotes have different key values, check actual received key values via logs first
Notes
- Firmware Version: Use Standard or
esp32-F8R4Full; ESP32-S3 Full currently has IR driver disabled by default - RMT Driver Compatibility: ESP32-S3's RMT new driver (driver_ng) and legacy driver cannot coexist, must verify startup and decode stability before custom enabling
- Receiving Distance: VS1838B typical receiving distance 8-10m, needs to aim at receiver
- Ambient Light Interference: Strong sunlight or fluorescent lights may interfere with IR reception
- Protocol Support: Auto-detects NEC, RC5, RC6, SONY, Samsung and other protocols
- Repeat Code: Long press receives repeat codes (NEC: 0xFFFFFFFF), needs filtering in scripts
