Touch buttons on ESP32-S3 board

Sculptonics
Posts: 2
Joined: Mon Sep 01, 2025 6:33 am

Touch buttons on ESP32-S3 board

Postby Sculptonics » 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):
  • 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;
}
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

ahsrabrifat
Posts: 201
Joined: Sat Jan 18, 2025 2:31 pm

Re: Touch buttons on ESP32-S3 board

Postby ahsrabrifat » Tue Sep 09, 2025 6:04 pm

According to the ESP32-S3 Series datasheet, the touch sensor pins are multiplexed with GPIO1 to GPIO14 and their corresponding RTC GPIOs. This multiplexing means that if a GPIO is assigned to another function (like SPI or UART), it cannot be used for touch sensing. Identify GPIOs on the SuperMini that are not assigned to other functions and can support touch sensing. For instance, GPIOs like GPIO0, GPIO2, GPIO4, GPIO12, GPIO13, GPIO14, GPIO15, GPIO25, GPIO26, GPIO27, GPIO32, and GPIO33 can be configured as touch inputs, provided they are not already in use for other functions.
If internal touch sensing is not feasible, you might explore external capacitive touch controllers that communicate with the ESP32-S3 via I2C or SPI. These modules can provide multiple touch inputs without relying on the limited GPIOs of the SuperMini.
If touch sensing is a critical feature for your project, consider using a different ESP32-S3 development board that offers dedicated touch pins. For example, the ESP32-S3 DevKitC-1 provides more accessible touch GPIOs.
The generic ESP32 can work in this case too.
https://www.theengineeringprojects.com/ ... ensor.html

Sculptonics
Posts: 2
Joined: Mon Sep 01, 2025 6:33 am

Re: Touch buttons on ESP32-S3 board

Postby Sculptonics » Fri Sep 12, 2025 3:04 pm

According to the ESP32-S3 Series datasheet, the touch sensor pins are multiplexed with GPIO1 to GPIO14 and their corresponding RTC GPIOs. This multiplexing means that if a GPIO is assigned to another function (like SPI or UART), it cannot be used for touch sensing. Identify GPIOs on the SuperMini that are not assigned to other functions and can support touch sensing. For instance, GPIOs like GPIO0, GPIO2, GPIO4, GPIO12, GPIO13, GPIO14, GPIO15, GPIO25, GPIO26, GPIO27, GPIO32, and GPIO33 can be configured as touch inputs, provided they are not already in use for other functions.
If internal touch sensing is not feasible, you might explore external capacitive touch controllers that communicate with the ESP32-S3 via I2C or SPI. These modules can provide multiple touch inputs without relying on the limited GPIOs of the SuperMini.
If touch sensing is a critical feature for your project, consider using a different ESP32-S3 development board that offers dedicated touch pins. For example, the ESP32-S3 DevKitC-1 provides more accessible touch GPIOs.
The generic ESP32 can work in this case too.
https://www.theengineeringprojects.com/ ... ensor.html
Using of ESP -IDF allows me to work with touch pins, but I can't get response with ESP-ADF :(

ahsrabrifat
Posts: 201
Joined: Sat Jan 18, 2025 2:31 pm

Re: Touch buttons on ESP32-S3 board

Postby ahsrabrifat » Mon Sep 15, 2025 4:27 pm

I think you need to Patch periph_touch in ADF for ESP32-S3.

Who is online

Users browsing this forum: No registered users and 1 guest