Skip to content

PWM / DAC Actions ​

Action Types ​

ActionactionTypeDescription
ACTION_SET_PWM4Set PWM duty cycle
ACTION_SET_DAC5Set DAC output value

Configuration Examples ​

The peripheral execution page is shown below. When configuring PWM/DAC actions, verify the target peripheral, duty cycle range, and whether to use the trigger received value.

Example 1: Set PWM Duty Cycle (LED Dimming) ​

Scenario: Set LED brightness to 50% (duty cycle 128/255)

Configuration Steps:

  1. Edit the rule in the Peripheral Execution Management page

  2. Click the Add Action button

  3. Fill in the action configuration:

    FieldValueDescription
    Action TypeSelect Set PWMPWM output
    Target PeripheralSelect led_pwmPWM output peripheral
    Duty Cycle Value1288-bit resolution 0-255
  4. Click the Save button

💡 Tip: Duty cycle range depends on the peripheral's configured pwmResolution: 8-bit→0~255, 12-bit→0~4095


Example 2: Use Received Value to Dynamically Set PWM ​

Scenario: Dynamically control motor speed based on platform-delivered value

Configuration Steps:

  1. Edit the rule, add an action

  2. Fill in:

    • Action Type: Select Set PWM
    • Target Peripheral: Select motor_pwm
    • Use Received Value: ✅ Enabled
    • Note: The value passed at trigger time will be used as the PWM value
  3. Click Save

💡 Tip: When "Use Received Value" is enabled, the platform sending [{"id":"motor_pwm","value":"200"}] will directly set it as the PWM value


Example 3: Set DAC Output Value ​

Scenario: Set DAC output voltage (ESP32 only supports GPIO25/26)

Configuration Steps:

  1. Edit the rule, add an action

  2. Fill in:

    • Action Type: Select Set DAC
    • Target Peripheral: Select dac1
    • Output Value: 200 (range 0-255, 8-bit resolution)
  3. Click Save

💡 Tip: ESP32 DAC is 8-bit; values 0-255 correspond to voltage 0-3.3V


Method 2: JSON Configuration File Import ​

Compatible Peripheral Types ​

ActionCompatible Peripheral type
ACTION_SET_PWMGPIO_PWM_OUTPUT(17), PWM_SERVO(41)
ACTION_SET_DACDAC(27)

Precautions ​

  1. PWM Range: Values exceeding the resolution range will be clamped to the maximum value
  2. DAC Pins: ESP32 only supports DAC output on GPIO 25/26
  3. Servo Control: PWM_SERVO peripheral sets the pulse width corresponding to the angle via ACTION_SET_PWM

FastBee | fastbee.cn