# Peripheral Configuration

> This guide consolidates all peripheral configuration content, including peripheral types, pin assignments, parameter configuration, Web configuration steps, and linkage examples.
>
> Before choosing a module, check: [Sensors and Modules List](https://www.fastbee.cn/doc/en/device/v2/getting-started/supported-sensors-and-modules.html).

## Table of Contents

* [Peripheral Overview](#peripheral-overview)
* [GPIO and PWM Peripherals](#_1-gpio-and-pwm-peripherals)
* [Motor Control Peripherals](#_2-motor-control-peripherals)
* [Display Devices](#_3-display-devices)
* [Temperature and Humidity Sensors](#_4-temperature-and-humidity-sensors)
* [Environmental Sensors](#_5-environmental-sensors)
* [Electrical Sensors](#_6-electrical-sensors)
* [Communication Devices](#_7-communication-devices)
* [Other Peripherals](#_8-other-peripherals)
* [Pin Assignment Principles](#pin-assignment-principles)
* [Web Configuration Process](#web-configuration-process)
* [FAQ](#faq)

***

## Peripheral Overview

FastBee supports 25+ peripheral types, configured visually through the Web interface without writing code.

The peripheral page abstracts real hardware into objects that can be referenced by rules. When adding a new peripheral, first select the type, then fill in pins and parameters. It is recommended to keep new peripherals disabled on first save and enable them after confirming wiring.

| ID | Name | Type | Pins | Status | Actions |
| --- | --- | --- | --- | --- | --- |
| `adc` | ADC Analog Converter | ADC | 36 | Disabled | Edit / Enable / Delete |
| `can` | CAN Bus | CAN | 4, 5 | Disabled | Edit / Enable / Delete |
| `i2c` | I2C Bus | I2C | 17, 18 | Disabled | Edit / Enable / Delete |
| `jtag` | JTAG Debug Interface | JTAG | 12, 13, 14, 15 | Disabled | Edit / Enable / Delete |
| `modbus_rtu` | Modbus RTU-Industrial Device | UART | 16, 17 | Disabled | Edit / Enable / Delete |
| `oled_ssd1306_c3` | OLED Display-SSD1306 | LCD | 5, 6 | Disabled | Edit / Enable / Delete |
| `gpio_pwm` | PWM Output | PWM Output | 21 | Disabled | Edit / Enable / Delete |
| `sdio` | SD Card SDIO Interface | SDIO | 14, 15, 2, 4, 12, 13 | Disabled | Edit / Enable / Delete |
| `swd` | SWD Debug Interface | SWD | 13, 14 | Disabled | Edit / Enable / Delete |
| `uart` | UART Serial Port | UART | 16, 17 | Disabled | Edit / Enable / Delete |

![Add Peripheral Dialog](https://www.fastbee.cn/doc/assets/peripheral-add-dialog.DM0WXSnl.png)

```mermaid
%%{init: {"flowchart": {"htmlLabels": false}}}%%
flowchart TD
  A["What hardware do I want to connect?"] --> B["Digital\nGPIO Input / Output\nButtons, door sensors, relays"]
  A --> C["Analog\nADC / Voltage / Current\nVoltage, current, light"]
  A --> D["Bus Devices\nI2C / SPI / UART\nOLED, RFID, serial modules"]
  A --> E["RS485 Slave\nModbus Device\nRelays, acquisition modules"]
  A --> F["Display Output\nOLED / TM1637\nStart with static text"]
  B --> G["Save as Disabled -> Single Item Verify -> Connect to Rules -> Report and Archive"]
  C --> G
  D --> G
  E --> G
  F --> G
```

When selecting, first determine the peripheral type by hardware signal form: digital signals go to GPIO, analog signals go to ADC, bus devices go to I2C/SPI/UART, RS485 slaves go to Modbus sub-devices, and display peripherals should first pass static text tests.

### Peripheral Type Quick Reference

| type value | Type Name | Description | Detailed Documentation |
|--------|--------|------|---------|
| 11 | GPIO\_DIGITAL\_INPUT | Digital input | [gpio-input.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/gpio-input.html) |
| 12 | GPIO\_DIGITAL\_OUTPUT | Digital output | [gpio-output.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/gpio-output.html) |
| 13 | GPIO\_DIGITAL\_INPUT\_PULLUP | Pull-up input (buttons) | [gpio-input.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/gpio-input.html) |
| 15 | GPIO\_ANALOG\_INPUT | ADC analog input | [adc-input.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/adc-input.html) |
| 17 | GPIO\_PWM\_OUTPUT | PWM output | [pwm-output.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/pwm-output.html) |
| 36 | LCD | Display (SSD1306/SH1106) | [oled-usage-guide.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/oled-usage-guide.html) |
| 38 | SENSOR | Sensor (DHT/DS18B20 etc.) | See individual sensor docs |
| 41 | PWM\_SERVO | Servo | [servo.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/servo.html) |
| 42 | STEPPER\_MOTOR | Stepper motor | [stepper-motor.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/stepper-motor.html) |
| 43 | ENCODER | Rotary encoder | [encoder.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/encoder.html) |
| 44 | ONE\_WIRE | One-Wire (DS18B20) | [sensor-ds18b20.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-ds18b20.html) |
| 45 | NEO\_PIXEL | WS2812B RGB LED strip | [neopixel.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/neopixel.html) |
| 47 | SEVEN\_SEGMENT\_TM1637 | TM1637 seven-segment display | [display-tm1637.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/display-tm1637.html) |
| 51 | MODBUS\_DEVICE | Modbus slave device | [modbus-device.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/modbus-device.html) |
| 55 | IO\_EXPANDER | I2C IO expander (logical GPIO via shared I2C) | [PCF8574 IO Expander](https://www.fastbee.cn/doc/en/device/v2/peripherals/io-expander-pcf8574.html) |

`SENSOR_GENERIC` (type `38`) selects a registered I2C driver via `params.driver`, or a local sensor via the numeric `params.sensorType`; `sensorCategory` belongs to the read action parameters. For INA226 voltage/current/power acquisition, see [INA226](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-ina226.html); for NTC thermistor temperature measurement, see [NTC Thermistor](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-ntc.html).

***

## 1. GPIO and PWM Peripherals

### 1.1 GPIO Output (type:12)

**Applications**: LEDs, relays, buzzers, laser sensors

**Detailed Documentation**: [gpio-output.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/gpio-output.html)

**JSON Configuration**:

```json
{
  "id": "led_01",
  "name": "LED Indicator",
  "type": 12,
  "enabled": true,
  "pinCount": 1,
  "pins": [26, 255, 255, 255, 255, 255, 255, 255],
  "params": {
    "initialState": 0
  }
}
```

### 1.2 GPIO Input (type:11/13/14)

**Applications**: Buttons, PIR motion sensors, vibration sensors, reed switches

**Detailed Documentation**: [gpio-input.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/gpio-input.html)

### 1.3 ADC Input (type:15/26)

**Applications**: Light sensors, soil moisture, smoke, raindrop, voltage, current sensors

**Detailed Documentation**: [adc-input.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/adc-input.html)

### 1.4 PWM Output (type:17)

**Applications**: LED dimming, motor speed control, servo control

**Detailed Documentation**: [pwm-output.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/pwm-output.html)

***

## 2. Motor Control Peripherals

### 2.1 Servo (type:41)

**Applications**: SG90, MG996R servo angle control

**Detailed Documentation**: [servo.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/servo.html)

### 2.2 Stepper Motor (type:42)

**Applications**: 28BYJ-48 stepper motor precision positioning

**Detailed Documentation**: [stepper-motor.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/stepper-motor.html)

***

## 3. Display Devices

### 3.1 OLED Display (type:36)

**Applications**: SSD1306, SH1106 OLED screens

**Detailed Documentation**: [oled-usage-guide.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/oled-usage-guide.html)

**Features**:

* I2C interface, address 0x3C or 0x3D
* Supports text, numbers, graphics display
* Can display sensor data and system status

### 3.2 TM1637 Seven-Segment Display (type:47)

**Applications**: 4-digit 7-segment display

**Detailed Documentation**: [display-tm1637.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/display-tm1637.html)

**Features**:

* CLK/DIO two-wire control
* Supports number, temperature, humidity display
* Can rotate display of multiple parameters

### 3.3 LCD1602 (type:36, placeholder)

**Status**: Driver to be extended

**Detailed Documentation**: [display-lcd1602.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/display-lcd1602.html)

***

## 4. Temperature and Humidity Sensors

### 4.1 DHT11/DHT22 (type:38)

**Detailed Documentation**: [sensor-dht.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-dht.html)

**Features**:

* One-Wire communication
* DHT11: Temperature 0-50°C, Humidity 20-90%
* DHT22: Temperature -40-80°C, Humidity 0-100%
* Sampling interval ≥2 seconds

### 4.2 DS18B20 (type:38/44)

**Detailed Documentation**: [sensor-ds18b20.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-ds18b20.html)

**Features**:

* OneWire bus
* Temperature -55-125°C
* Multiple sensors can be connected in parallel (distinguished by address)

### 4.3 AHT20 (type:38)

**Detailed Documentation**: [sensor-aht20.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-aht20.html)

**Features**:

* I2C interface, address 0x38
* Temperature -40-85°C, Humidity 0-100%
* Lightweight I2C; requires the corresponding runtime feature

### 4.4 SHT31 (type:38)

**Detailed Documentation**: [sensor-sht31.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-sht31.html)

**Features**:

* I2C interface, address 0x44 or 0x45
* High-precision temperature and humidity
* Lightweight I2C; requires the corresponding runtime feature

***

## 5. Environmental Sensors

### 5.1 Ultrasonic HC-SR04 (type:38)

**Detailed Documentation**: [sensor-ultrasonic.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-ultrasonic.html)

**Features**:

* Distance measurement 2-400cm
* Requires two pins for trigger and echo
* Sampling interval ≥100ms

### 5.2 BMP280 Barometric Pressure (type:38)

**Detailed Documentation**: [sensor-bmp280.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-bmp280.html)

**Features**:

* I2C interface
* Temperature, barometric pressure, altitude
* Requires active `i2cSensors`

### 5.3 MPU6050 Gyroscope (type:38)

**Detailed Documentation**: [sensor-mpu6050.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-mpu6050.html)

**Features**:

* I2C interface, address 0x68
* Six-axis posture (accelerometer + gyroscope)
* Requires active `i2cSensors`

### 5.4 BH1750 Light Sensor (type:38)

**Detailed Documentation**: [sensor-bh1750.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-bh1750.html)

**Features**:

* I2C interface, address 0x23 or 0x5C
* Light intensity 1-65535 lux
* Lightweight I2C; requires the corresponding runtime feature

***

## 6. Electrical Sensors

### 6.1 Current Sensor ACS712 (type:15)

**Detailed Documentation**: [sensor-current.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-current.html)

**Features**:

* ADC collection
* Range 5A/20A/30A
* Requires calibration parameters

### 6.2 Voltage Sensor (type:15)

**Detailed Documentation**: [sensor-voltage.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-voltage.html)

**Features**:

* ADC + voltage divider circuit
* Measurement range 0-25V
* Requires divider ratio parameters

***

## 7. Communication Devices

### 7.1 Modbus Device (type:51)

**Detailed Documentation**: [modbus-device.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/modbus-device.html)

**Features**:

* RS485 interface
* Modbus RTU master
* Supports multi-slave scanning

### 7.2 IR Remote Control (type:38)

**Detailed Documentation**: [ir-remote.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/ir-remote.html)

**Features**:

* NEC/RC5 decoding
* Requires active `irRemote`; `esp32s3-F8R8` excludes the driver

### 7.3 RFID Reader MFRC522 (type:38)

**Detailed Documentation**: [rfid-mfrc522.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/rfid-mfrc522.html)

**Features**:

* SPI interface
* Read RFID card UID
* Requires active `rfid`

***

## 8. Other Peripherals

### 8.1 NeoPixel WS2812B (type:45)

**Detailed Documentation**: [neopixel.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/neopixel.html)

**Features**:

* Single-wire control RGB LED strip
* Supports multiple LEDs in series

### 8.2 Rotary Encoder (type:43)

**Detailed Documentation**: [encoder.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/encoder.html)

**Features**:

* A/B phase counting
* Supports rotation and button press

### 8.3 SD Card (type:37, placeholder)

**Detailed Documentation**: [storage-sd-card.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/storage-sd-card.html)

**Status**: SPI mode is partially implemented and file actions need extension; production use requires a validated custom build

### 8.4 Device Event (type:60)

**Detailed Documentation**: [device-event.md](https://www.fastbee.cn/doc/en/device/v2/peripherals/device-event.html)

**Features**:

* Logical event source
* Used for rule linkage

***

## Pin Assignment Principles

### Safe Pins

* ✅ **GPIO34-39**: Input-only, suitable for ADC/digital input
* ✅ **GPIO32-39**: ADC1, available after WiFi is enabled (preferred)
* ❌ **GPIO6-11**: Connected to Flash, not recommended
* ❌ **GPIO4,12-15,25-27**: ADC2, unavailable after WiFi is enabled
* ⚠️ **GPIO0**: BOOT button, use with caution
* ⚠️ **GPIO5**: STATE indicator LED, occupied by default

### I2C Devices

* SDA: GPIO21/22 (recommended)
* SCL: GPIO22/21 (recommended)
* Multiple I2C devices can share SDA/SCL, but addresses must not conflict

***

## Web Configuration Process

### Step 1: Add Peripheral

1. Navigate to Web interface → **Peripheral Configuration**
2. Click **Add Peripheral**
3. Select peripheral type
4. Fill in peripheral ID and name
5. Assign pins (refer to pin assignment principles)
6. Fill in parameters (e.g., I2C address, initial state, etc.)

### Step 2: Enable Peripheral

1. Confirm pin wiring is correct
2. Check **Enable**
3. Click **Save**
4. Check serial log to confirm successful initialization

### Step 3: Create Execution Rules

1. Navigate to **Peripheral Execution**
2. Add rule and configure trigger
3. Configure actions (e.g., GPIO control, sensor read, display, etc.)
4. Save and enable rule

### Step 4: Configuration Backup

1. Navigate to **Device Configuration > Advanced Configuration**
2. Export peripherals.json for backup
3. Save as local file

After visual configuration, keep the exported `peripherals.json` with the board model and firmware version so it can be reused on identical hardware or restored after a field change.

***

## FAQ

### Q1: Peripheral not responding?

* Check if the peripheral is enabled
* Check if pin configuration is correct
* Check if wiring is secure
* Check serial log to confirm initialization status

### Q2: I2C device initialization failed?

* Check if SDA/SCL are reversed
* Check if I2C address is correct
* Check if pull-up resistors are present
* Confirm power supply is 3.3V

### Q3: ADC values abnormal?

* Check if voltage exceeds 3.3V
* Confirm using ADC1 pins (GPIO32-39)
* Check ADC attenuation and calibration parameters

### Q4: Sensor readings inaccurate?

* Check if sampling interval is too short (DHT ≥2 seconds)
* Check if sensor power supply is stable
* Confirm sensor type configuration is correct

***

## Related Documentation

* [Examples](https://www.fastbee.cn/doc/en/device/v2/examples.md) - 48 practical application examples
* [Peripheral Execution Guide](https://www.fastbee.cn/doc/en/device/v2/periph-exec.md) - Trigger and action configuration
* [Complete Sensor Guide](https://www.fastbee.cn/doc/en/device/v2/peripherals/sensor-guide-complete.html) - 40+ sensor detailed specifications
* [Architecture Design](https://www.fastbee.cn/doc/en/device/v2/dev/architecture.html) - System architecture and peripheral management module

***
