ZH_AC_DIMMER 1.1.0
Loading...
Searching...
No Matches
ESP32 ESP-IDF component for AC dimmer

Tested on

  1. ESP32 ESP-IDF v5.5.1

Features

  1. Supports frequency up to 400 Hz.
  2. Automatic frequency detection.

Attention

For correct operation, please enable the following settings in the menuconfig:

GPIO_CTRL_FUNC_IN_IRAM
CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM
CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
CONFIG_GPTIMER_ISR_CACHE_SAFE
CONFIG_GPTIMER_OBJ_CACHE_SAFE

Using

In an existing project, run the following command to install the components:

cd ../your_project/components
git clone http://git.zh.com.ru/esp_components/zh_ac_dimmer

In the application, add the component:

Examples

#include "zh_ac_dimmer.h"
void app_main(void)
{
esp_log_level_set("zh_ac_dimmer", ESP_LOG_ERROR);
config.zero_cross_gpio = GPIO_NUM_16;
config.triac_gpio = GPIO_NUM_17;
for (uint8_t i = 0; i <= 100; ++i)
{
vTaskDelay(100 / portTICK_PERIOD_MS);
}
for (uint8_t i = 100; i > 0; --i)
{
vTaskDelay(100 / portTICK_PERIOD_MS);
}
}
Structure for initial initialization of AC dimmer.
esp_err_t zh_ac_dimmer_init(const zh_ac_dimmer_init_config_t *config)
Initialize AC dimmer.
#define ZH_AC_DIMMER_INIT_CONFIG_DEFAULT()
AC dimmer initial default values.
esp_err_t zh_ac_dimmer_stop(void)
Stop AC dimmer.
esp_err_t zh_ac_dimmer_start(void)
Start AC dimmer.
esp_err_t zh_ac_dimmer_deinit(void)
Deinitialize AC dimmer.
esp_err_t zh_ac_dimmer_set(uint8_t value)
Set AC dimmer dimming value.