I’ve used touch pins on esp32 to change a lamp into a touch-controlled lamp. I’m now trying to use the M5StampS3, which uses the esp32-S3. The ESPHOME document indicates touch works differently on this chip. When I configure a touch pin I get a very high value out, but it doesn’t change at all when I touch the medal the pin is connected. Any idea on configuration to make this works. This is the configuration I’m trying to make work with a touch sensor.
esphome:
name: m5-esp32-s3-orange-1-relay
friendly_name: m5 esp32 s3 orange 1 relay
esp32:
board: esp32-s3-devkitc-1
framework:
#type: arduino
type: ESP-IDF
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "FR-Lamp-Touch"
password: !secret wifi_password
# Enable Web server.
web_server:
port: 80
captive_portal:
sensor:
# hack so the touch sensor doesn't kick off at power on
- platform: uptime
name: Uptime Sensor
id: time_since_boot
update_interval: 30s
esp32_touch:
setup_mode: true
binary_sensor:
- platform: esp32_touch
name: "ESP32 Touch Pad GPIO5"
pin: GPIO5
threshold: 290
filters:
# Small filter, to debounce the spurious events.
- delayed_on: 10ms
- delayed_off: 10ms
#on_press:
on_click:
- min_length: 10ms
max_length: 500ms
# Short touch to turn light on and off
then:
if:
# test to ignore random event on boot
condition:
- lambda: 'return id(time_since_boot).raw_state > 10;'
then:
- button.press: pwr_btn
# restart-button
button:
- platform: restart
name: "restart-esp32-dim-touch"
- platform: template
name: pwr btn
id: pwr_btn
on_press:
then:
if:
condition:
and:
# if light is off
- switch.is_off: light_state
then:
# then we turn it on
- switch.turn_on: light_state
else:
# else it's on so we turn it off
- switch.turn_off: light_state
switch:
- platform: gpio
name: "light_state"
pin: GPIO7
id: light_state