Skip to content

GPIO Digital Output ​

Overview ​

GPIO digital output is used to control relays, LEDs, buzzers, DC motors, and other actuators. Outputs high/low levels to drive external loads.

Supported Peripheral Types ​

Typetype ValueDescription
GPIO_DIGITAL_OUTPUT12Standard digital output

Pin Description ​

  • ESP32: GPIO 0-5, 12-33 (some pins have limitations)
  • ESP32-C3: GPIO 0-10, 18-21
  • ESP32-S3: GPIO 0-21, 35-48

Note: GPIO 6-11 (ESP32) are reserved for internal Flash use and cannot be configured as outputs.

Typical Applications ​

ApplicationWiringDescription
LEDGPIO → Resistor(220Ω) → LED → GNDHigh level to light up
RelayGPIO → Relay Module INMost modules trigger on low level
BuzzerGPIO → Active Buzzer+High level to sound
DC MotorGPIO → Motor Driver ModuleRequires external driver circuit

Digital output directly drives physical loads. When configuring, keep the peripheral disabled first, confirm the trigger level of the relay or motor driver module, then verify with individual actions.

Configuration ​

Different peripheral types will display different parameters. Before saving, verify peripheral ID, type, pins, and enable status.

Step 1: Navigate to Peripheral Management Page ​

  1. Open a browser and navigate to the ESP32 IP address
  2. After logging in, click Peripheral Configuration in the left menu

Step 2: Add GPIO Digital Output Peripheral ​

  1. Click the Add Peripheral button

  2. Fill in the configuration:

    FieldValueDescription
    Peripheral IDled1 or relay1Unique identifier
    NameStatus LED or Fan RelayDisplay name
    Peripheral TypeGPIO Digital Output (type: 12)Standard digital output
    Pin Configuration2 or 15Fill according to actual wiring
    Initial State00=Low level, 1=High level
  3. Click Save

Step 3: Verify Configuration ​

  1. Find the newly added peripheral in the peripheral list
  2. Click the Enable toggle
  3. Use the control panel to test output state

Method 2: JSON Configuration File Import ​

Add the following configuration to the peripherals array in data/config/peripherals.json:

LED Output ​

json
{
  "id": "led1",
  "name": "Status LED",
  "type": 12,
  "enabled": false,
  "pins": [2],
  "params": {
    "initialState": 0,
    "pwmChannel": 0,
    "pwmFrequency": 1000,
    "pwmResolution": 8,
    "defaultDuty": 0
  }
}

Relay Output (Low Level Trigger) ​

json
{
  "id": "relay1",
  "name": "Relay-Fan",
  "type": 12,
  "enabled": false,
  "pins": [15],
  "params": {
    "initialState": 0,
    "pwmChannel": 0,
    "pwmFrequency": 1000,
    "pwmResolution": 8,
    "defaultDuty": 0
  }
}

Buzzer ​

json
{
  "id": "buzzer",
  "name": "Alarm Buzzer",
  "type": 12,
  "enabled": false,
  "pins": [4],
  "params": {
    "initialState": 0,
    "pwmChannel": 0,
    "pwmFrequency": 1000,
    "pwmResolution": 8,
    "defaultDuty": 0
  }
}

Peripheral Execution Integration ​

GPIO digital output can serve as the action target of peripheral execution rules:

Action TypeactionTypeDescription
ACTION_HIGH0Output high level
ACTION_LOW1Output low level
ACTION_HIGH_INVERTED13Logic high (physical low level)
ACTION_LOW_INVERTED14Logic low (physical high level)
ACTION_BLINK2Blink (actionValue=interval ms)
ACTION_BREATHE3Breathing light effect

Web Interface Configuration Steps ​

Step 1: Create Execution Rule

  1. Click Peripheral Execution in the left menu
  2. Click the Add Rule button
  3. Fill in basic configuration and configure triggers

Step 2: Add GPIO Action

  1. Click the Add Action button

  2. Fill in action configuration:

    FieldValueDescription
    Action TypeSelect High Level or Low LevelChoose based on requirements
    Target PeripheralSelect relay1GPIO output peripheral
    Execution Delay0Execute immediately
  3. Click Save

💡 Tip: For low-level trigger relay modules, use "Logic High (Inverted)" or "Logic Low (Inverted)"


JSON Configuration Example ​

json
{
  "targetPeriphId": "relay1",
  "actionType": 0,
  "actionValue": "",
  "useReceivedValue": false,
  "syncDelayMs": 0,
  "execMode": 0
}

Notes ​

  1. Initial State: initialState of 0 means default low level on power-up, 1 means high level
  2. Low-Level Trigger Relay: Use ACTION_HIGH_INVERTED(13) / ACTION_LOW_INVERTED(14) for logic inversion
  3. Current Limit: ESP32 single pin maximum output current is 40mA; external driver circuit needed for high-power loads
  4. PWM Parameters: Even for digital output type, PWM parameters in params must be retained (framework compatibility design), but they do not affect digital output behavior
  5. Platform Downlink Control: Platform can control output state via MQTT: [{"id":"relay1","value":"1"}]

FastBee | fastbee.cn