Example 28: Reed Switch Sensor
About 1 min
Example 28: Reed Switch Sensor
Experiment Overview
A reed switch (magnetic control switch) closes its contacts when near a magnet, suitable for door/window open-close detection, water meter pulse counting, and similar applications. Contacts open when no magnetic field is present and close when a magnetic field is detected.
Hardware Wiring
| Board Label | GPIO Pin | Connected Device |
|---|---|---|
| REED | GPIO4 | Reed switch module (DO digital output) |
JSON Configuration Example
{
"peripherals": [
{
"id": "reed_01",
"name": "Reed Switch Sensor",
"type": 13,
"enabled": false,
"pins": [4],
"params": {}
}
]
}Peripheral Execution Linkage
Scenario: Door/Window Open Alarm (Polling Trigger)
Feature: Check door/window status every 200ms; trigger buzzer alarm when door/window is opened
Web UI Configuration Steps
Step 1: Ensure Buzzer Peripheral is Configured
- Peripheral ID:
buzzer_gpio - Type: 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:
Door/Window Open 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 reed_01Reed switch sensor Polling Interval 200200ms Condition Expression value == 1HIGH = door/window open
Step 4: Configure Actions (2 actions required)
Action 1: Buzzer Alarm
- Click Add Action button
- Fill in:
- Action Type: Select HIGH
- Target Peripheral: Select
buzzer_gpio
Action 2: Send Alarm Event
Click Add Action button again
Fill in:
- Action Type: Select Send Event
- Event Type:
alarm - Event Message:
Door/window has been opened
Click Save button
Installation Guide
| Component | Installation Location | Description |
|---|---|---|
| Magnet | On door/window sash | Moves with door/window |
| Reed Switch | On door/window frame | Fixed in place |
| Trigger Distance | 10-20mm | Typical distance |
Notes
- Installation Position: Place the magnet on the door/window sash; fix the reed switch on the door/window frame
- Trigger Distance: Typical trigger distance is 10-20mm
- Counting Applications: Water/gas meter pulse counting can use interrupt mode (type: 18)
- Sealing: Waterproof enclosure is required for outdoor use
