I converted a couple of cheap touchlamps into ‘smart’ touchlamps using an ESP32 and a Robotdyn dimmer.
The lamps are the same as this one from Argos:
The existing touch dimmer module looks like this one - it was removed entirely, apart from the eyelet and the wire that ran to it:
In its place, I installed a Robotdyn Triac dimmer (AC Dimmer Module, 1 Channel, 3.3V/5V logic, AC 50/60hz, 110V~400V - Hardware, Software, Gadgets & Future Tech News):
…and an ESP32 like this one here https://amzn.eu/d/03XHzhj:
I soldered together the ESP32, power supply (JZK 2 pcs HLK-PM01 AC DC 220V to 5V Step Down Power Supply Module Isolated Power Supply Module : Amazon.co.uk: Business, Industry & Science) and terminals onto a perf board. I didn’t include a fuse on my board, because I’m in the UK and our plugs are fused:
…and printed a couple of enclosures; one for the board and another for the dimmer. I used two enclosures so I could fit them through the hole in the base, and either side of the shaft that runs through the middle and connects to the bulb holder.
I re-used the touch connector wire (connected to the lamp base) for my touch pin on the ESP32.
Here they are in action!: https://youtu.be/VoGnTOn7O2s
Unfortunately, dimming produces an annoying flicker, hence dimming is currently not enabled via touch in my YAML. I could just do away with the dimmer altogether, wire the bulb to mains AC and just use the ESP32 to control a smart bulb via touch.
YAML for ESPHome here:
esphome:
name: "smart-touch-1"
friendly_name: Smart Touch Lamp 1
esp32:
board: esp32-s3-devkitc-1
framework:
type: arduino
# Enable logging
logger:
level: info
# level: debug
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
ota:
- platform: esphome
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:
esp32_touch:
setup_mode: true
measurement_duration: 0.25ms
binary_sensor:
- platform: esp32_touch
name: "Touch Pad Pin 13"
pin: GPIO13
threshold: 40000
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 cycle through brightnesses
then:
- number.increment:
id: dimmer_control
cycle: true
number:
- platform: template
name: Dimmer Control
id: dimmer_control
min_value: 0
max_value: 100
step: 100
optimistic: true
set_action:
then:
- light.turn_on:
id: dimmer
brightness: !lambda 'return x / 100.0;'
# restart-button
button:
- platform: restart
name: "restart-esp32-dim-touch"
# AC Dimmer Configuration
light:
- platform: monochromatic
id: dimmer
name: "Smart Lamp"
output: ac_dimmer_output
restore_mode: RESTORE_DEFAULT_OFF
#on_turn_on: IS THIS NEEDED??
# - light.turn_on:
# id: dimmer
# brightness: 1.0 # Set initial brightness to 100% on power up
output:
- platform: ac_dimmer
id: ac_dimmer_output
gate_pin: GPIO12 # Gate pin for controlling the dimmer (GPIO12)
zero_cross_pin:
number: GPIO5 # Zero-cross pin for synchronization (GPIO5)
mode:
input: True
inverted: yes







