Touch buttons on ESP32-S3 board
Posted: Tue Sep 02, 2025 7:24 am
Hello. I'm trying to use the touch sensor feature on ESP32-S3 Supermini board with ESP-ADF (Master). ESP-IDF Release/v5.3.
I am using recommended example https://github.com/espressif/esp-adf/tr ... p3_control and information from the page
https://docs.espressif.com/projects/esp ... touch.html.
I have configured some parameters in the custom board files (settings for ESP32-LyraT V4.3):
The buttons defined as touch doesn't work with this settings.
However, the functions are working properly if the pins are configured as simple buttons.
What should I change in the above settings? Touch buttons are very important for our project. Thank you for all the suggestions
I am using recommended example https://github.com/espressif/esp-adf/tr ... p3_control and information from the page
https://docs.espressif.com/projects/esp ... touch.html.
I have configured some parameters in the custom board files (settings for ESP32-LyraT V4.3):
- board_key_init in components/my_board/my_board_v1_0/board.c
Code: Select all
esp_err_t audio_board_key_init(esp_periph_set_handle_t set)
{
periph_touch_cfg_t touch_cfg = {
.touch_mask = TOUCH_PAD_SEL4 | TOUCH_PAD_SEL7 | TOUCH_PAD_SEL8 | TOUCH_PAD_SEL9,
.tap_threshold_percent = 70,
};
esp_err_t ret = ESP_OK;
esp_periph_handle_t touch_periph = periph_touch_init(&touch_cfg);
AUDIO_NULL_CHECK(TAG, touch_periph, return ESP_ERR_ADF_MEMORY_LACK);
ret = esp_periph_start(set, touch_periph);
return ret;
}
- pin definition in components/my_board/my_board_v1_0/board_def.h
Code: Select all
#define INPUT_KEY_NUM 6
#define BUTTON_REC_ID GPIO_NUM_36
#define BUTTON_MODE_ID GPIO_NUM_39
#define BUTTON_SET_ID TOUCH_PAD_NUM9
#define BUTTON_PLAY_ID TOUCH_PAD_NUM8
#define BUTTON_VOLUP_ID TOUCH_PAD_NUM7
#define BUTTON_VOLDOWN_ID TOUCH_PAD_NUM4
#define INPUT_KEY_DEFAULT_INFO() { \
{ \
.type = PERIPH_ID_BUTTON, \
.user_id = INPUT_KEY_USER_ID_REC, \
.act_id = BUTTON_REC_ID, \
}, \
{ \
.type = PERIPH_ID_BUTTON, \
.user_id = INPUT_KEY_USER_ID_MODE, \
.act_id = BUTTON_MODE_ID, \
}, \
{ \
.type = PERIPH_ID_TOUCH, \
.user_id = INPUT_KEY_USER_ID_SET, \
.act_id = BUTTON_SET_ID, \
}, \
{ \
.type = PERIPH_ID_TOUCH, \
.user_id = INPUT_KEY_USER_ID_PLAY, \
.act_id = BUTTON_PLAY_ID, \
}, \
{ \
.type = PERIPH_ID_TOUCH, \
.user_id = INPUT_KEY_USER_ID_VOLUP, \
.act_id = BUTTON_VOLUP_ID, \
}, \
{ \
.type = PERIPH_ID_TOUCH, \
.user_id = INPUT_KEY_USER_ID_VOLDOWN, \
.act_id = BUTTON_VOLDOWN_ID, \
} \
}
- pins configuration in components/my_board/my_board_v1_0/board_pins_config.c
Code: Select all
// button pins
int8_t get_input_rec_id(void)
{
return BUTTON_REC_ID;
}
int8_t get_input_mode_id(void)
{
return BUTTON_MODE_ID;
}
// touch pins
int8_t get_input_set_id(void)
{
return BUTTON_SET_ID;
}
int8_t get_input_play_id(void)
{
return BUTTON_PLAY_ID;
}
int8_t get_input_volup_id(void)
{
return BUTTON_VOLUP_ID;
}
int8_t get_input_voldown_id(void)
{
return BUTTON_VOLDOWN_ID;
}
However, the functions are working properly if the pins are configured as simple buttons.
What should I change in the above settings? Touch buttons are very important for our project. Thank you for all the suggestions