Bathroom mirror touch sensor for esp8266 or esp32

Or perhaps something like this could be an option:

I ordered a couple of these - they have a diffused white and blue light when on/off, so I think they could be a direct replacement of what you’re looking for.

https://www.aliexpress.com/item/1005005236832720.html

When on, the ground is connected between in/out. When off, the ground is disconnected (~270k ohm). The advertised minimum 5v (up to 24v) input is always connected because it is designed to pass through high pwm signals and drive a single color PWM led strip. But I just need it as a switch, not to drive any LED strips. So I think all I need to do is connect the input to continuous 5v and gnd, then hook the output to the button pin on qinled / WLED.

If you want it as a remote wifi switch without wled on it, you can probably just install esphome on an esp32 and just hook up relevant GPIOs on this switch with a 5v-3.3v level shifter or resistor

Update:

Summary:

  • always get the on/off models (not the dimming versions).
  • most 12-24 labels seem to work with 5v, besides we are only detecting whether output ground is floating or connected to ground, so most of these work the same way.
  • the bigger they are the better the sensitivity
  • the square ones with built-in LED on/of statuses have low sensitivity, a lot of these can only penetrate 1-5mm, despite the advertised thickness. The large round ones (with no status LEDs and sold as under table/cabinet sensors) work better, and can sense through 10mm glass.

After testing a few of these, I found the square models have low sensitivity when put behind glass. Some of these work only behind thin glass but lose sensitivity when the glass is thicker. The added thickness of the diffuser didn’t help either.
( https://www.aliexpress.com/item/1005005236832720.html )
The square ones have two conductors on the left and right of the switch that senses touch, and these aren’t good enough for thicker glass.

There are alternative switches that I tried that are designed for sensing through tables. These work well with thicker glass:

https://www.aliexpress.com/item/1005008518539875.html

These definitely penetrate through tables and glass. This is a 10cm version but there is also a 5cm version. The good thing about the round ones are that they have a much larger copper/tin conductor area in the back and so they are more sensitive. The larger the area the better the sensitivity.

The switches that I bought were labelled 12v-24v, but when I tested with 5v most of them work well enough to detect touch. Since I want to use these as WIFI switches then I can just drive these directly from the 5v off of my ESP32.

Most of these switches are designed to drive a PWM LED on the output ground connection, so usually the in/out voltage are fused together. The connection that we are interested in is the ground (-) output port.

When the switch is on, the output ground is connected to ground. When it is off, the output ground will be floating (disconnected).

I used this esphome configuration and just connected that ground (-) output pin to GPIO4 because it can specify an internal pullup (if you use WLED then you might need to put a pullup resistor yourself from 3.3v).

binary_sensor:
  platform: gpio
  pin:
    number: GPIO4
    mode:
      input: true
      pullup: true
  name: capswitch_1
  filters:
    - delayed_on: 350ms
    - delayed_off: 350ms

And if you want to tie that in to the ESP32 dev board’s on-board led you could try this:

binary_sensor:
  platform: gpio
  pin:
    number: GPIO4
    mode:
      input: true
      pullup: true
  name: capswitch_1
  filters:
    - delayed_on: 350ms
    - delayed_off: 350ms
  on_press:
    then:
      - switch.turn_on: blueLED
  on_release:
    then:
      - switch.turn_off: blueLED

switch:
  - platform: gpio
    pin:
      number: GPIO2
      mode: output
    id: blueLED