Example 34: Flame Sensor
Example 34: Flame Sensor
Experiment Overview
A flame sensor detects specific infrared wavelengths (760nm~1100nm) emitted by flames via an IR receiver tube, outputting an analog signal indicating flame intensity. Suitable for fire alarms, firefighting robots, and other safety applications.
Hardware Wiring
| Board Label | GPIO Pin | Connected Device |
|---|---|---|
| AO | GPIO34 | Flame sensor analog output |
| DO | GPIO4 | Flame sensor digital output (optional) |
When flame is detected, the analog value decreases (the larger the flame, the lower the value); digital output goes LOW.
JSON Configuration Example
{
"peripherals": [
{
"id": "flame_01",
"name": "Flame Sensor",
"type": 15,
"enabled": false,
"pins": [34],
"params": {}
}
]
}Peripheral Execution Linkage
Scenario: Fire Alarm (Polling Trigger)
Feature: Trigger buzzer and LED alarm when flame is detected (ADC < 1000)
Web UI Configuration Steps
Step 1: Ensure Alarm Peripherals are Configured
- Buzzer:
buzzer_gpio(GPIO Output) - LED:
led_d1(GPIO Output)
Step 2: Create Rule
- Click Peripheral Config in the left menu → Switch to Peripheral Execution tab
- Click New Rule button
- Fill in basic configuration:
- Rule Name:
Fire Alarm - Report Data: ✅ Enabled
- Enable: ✅ Enabled
- Rule Name:
Step 3: Configure Trigger (Polling Trigger)
Click Add Trigger button
Fill in trigger configuration:
Field Value Description Trigger Type Select Polling Trigger Periodic condition check Target Peripheral Select flame_01Flame sensor Polling Interval 5000.5 seconds (fast response) Condition Expression value < 1000Flame threshold
Step 4: Configure Actions (3 actions required)
Action 1: Buzzer Alarm
- Click Add Action button
- Fill in:
- Action Type: Select HIGH
- Target Peripheral: Select
buzzer_gpio
Action 2: LED Alarm
- Click Add Action button again
- Fill in:
- Action Type: Select LOW (common-anode LED on)
- Target Peripheral: Select
led_d1
Action 3: Send Alarm Event
Click Add Action button a third time
Fill in:
- Action Type: Select Send Event
- Event Type:
alarm - Event Message:
Flame detected!
Click Save button
Flame Sensor Value Reference
| Status | ADC Value | Description |
|---|---|---|
| No Flame | >2000 | Normal environment |
| Distant Flame | 1000-2000 | Weak flame |
| Close Flame | <1000 | Strong flame |
Notes
- Detection Angle: Sensor detection angle is ~60°; must face the flame direction
- Detection Range: Effective detection range is ~20-100cm (depends on flame size)
- False Alarms: Strong sunlight or incandescent lamps may also trigger; set threshold appropriately
- Safety Distance: Be cautious of fire safety during testing; a small lighter flame is sufficient for testing
- Multiple Sensors: Deploy multiple sensors to cover different directions
