Touch switch with led, responding to the output state of relay

Here I’m sharing my experiments with wemos D1Mini/ Node MCU with tasmota firmware installed in it and LED Touch Switch.
I have seen a video in Youtube by Dr.Zzzs showing how to install a touch switch LED to a sonoff basic flashed with Tasmota firmware. I tried the same on my wemos D1 Mini.
But I found that the built-in led responds only when we use the touch switch, it won’t respond if we use openhab/alexa/siri/google assistant.
So I did some modification(hack) to the touch switch as follows:

  1. I used transistor BC547 to ground the switch (This is how the switch works in tasmota, connecting
    the switch assigned pin to the ground). We should use this circuit as the output of Touch switch is High
    while ON. If there is any other method like using a resistor instead of transistor please let me know. Please follow the diagrams
    for more information.

  2. I found that the LEDs negative pin is connected directly to the ground pin of Touch Switch and the other pin
    connected to the output pin of Touch Switch Via a 300Ω resistor.
    So I made a deep scratch to break the copper connecting to the output and LED(as shown in the attached

  3. I want the inbuilt LED to be ON while the relay output is OFF and LED to be OFF while relay Output is ON
    (so that I can see the touch switch in the night).
    To do this I have to invert the logic from the Wemos D1/Node MCU. To invert the logic I used a BC547
    transistor in combination with a resistor. The circuit is shown in the picture.

Now everything working perfectly as I need. Now the LED responds to My voice commands. I hope this may help some of you looking for touch switches in their projects.

1 Like

What are the tasmota settings, please?
And can you share the associated items
Also, a video would be great.


Tasmota settings:
Generic Module
D1 pin to Relay1, and D2 pin to Switch1

Items file fo rthe Touch Switch as follows:

Switch LEDTB "Tube Light" <Light> [ "Switchable" ]{mqtt=">[broker:cmnd/Jacksroom/POWER1:command:*:default],<[broker:stat/Jacksroom/POWER1:state:default]"}

I will make a video soon.

Get these parts:

  1. Node MCU/ Wemos D1Mini or any similar products with at least two digital out pins.
  2. Touch switch
  3. Transistors BC547- 2nos per touch switch
  4. Resistors 1K Ohm- 2nos per touch switch
  5. Small general purpose PCB
  6. Jumper wires or similar for connections

@jacobkuriakose thanks! I planned on trying the same thing but hadn’t got around. Glad to know it’s possible!! Thx! I have a switch hooked to my sonoff but wanted it lit when off vs on.

1 Like

If you are planning to do this with a sonoff please follow this video by Dr.Zzz

I was inspired from this video.

Hi Jacob,

You gave me very good direction in this small challenge.

I have some alterations though, that makes everything a bit simpler.

Just scratch the copper directly under the 300Ω resistor (see picture). The copper runs from the right side of te resistor to a VIA in the PCB, half under the black plastic of the 3-pin connector.

Connect the right side of the 300Ω resistor to D1.
D1 outputs 3.3V when ON/HIGH and the 300Ω resistor protects the LED.
Pull-down D1 to ground and assign D1 as a Relay or Relay_n (software based inverted logic for the led)

Also you can pull-down D2 to ground and assign D2 as Switch_n, to accept the 3.3V that the OUTPUT pin gives when the switch is on.

Everything else (the transistors) is not necessary (anymore).

Do the following in Tasmota web GUI Console:

  1. SetOption114 1 (all switches are detached from their respective relays)
  3. Rule1 1