Sonoff Basic + wall push button with pilot light

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
kirkokuev
Normal user
Posts: 14
Joined: 24 Feb 2018, 21:23

Sonoff Basic + wall push button with pilot light

#1 Post by kirkokuev » 24 Feb 2018, 21:38

Hello, I am running an installation of multiple espeasy sonoff basics. To toggle them I use wall push-button switches, which trigger GPIO14 on sonoff basics.
Wall push-button switches have blue pilot light led inside, which is intended to make them visible at night. But I can't figure out a way to make them light up with sonoff. There is no separate power connection to light up this led, I guess it feeds itself magically on 220v installation even with one wire, connected to switch. In switch data sheet is stated that blue led is 0.15 mA. Sonoff uses 3.3v on it's gpio, which is probably not enough to drive the led. Here is a link to my push-button switch
https://www.schneider-electric.com/en/p ... 8682-unica
Currently as a work around I connect push-button and sonoff to impulse relay, but that is not a good solution, I can't get state of the button and impulse relay is fairly expensive.
So my question is how to enable pilot light on a push-button switch with direct connection to sonoff gpio?

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Sonoff Basic + wall push button with pilot light

#2 Post by toffel969 » 25 Feb 2018, 10:31

I think your pilot light is a glow lamp rather than a LED. You will need at least 100v to light them up. Replacing them with a led driven by the son off seems like an option.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

kimot
Normal user
Posts: 190
Joined: 12 Oct 2017, 20:46

Re: Sonoff Basic + wall push button with pilot light

#3 Post by kimot » 25 Feb 2018, 14:31

It is LED with circuit to allow 230 V.
Try bypass this circuit or change by normal LED
https://www.shopelektro.cz/vypinace-a-z ... e-led-lamp

kirkokuev
Normal user
Posts: 14
Joined: 24 Feb 2018, 21:23

Re: Sonoff Basic + wall push button with pilot light

#4 Post by kirkokuev » 25 Feb 2018, 20:09

Ok, so I took apart one switch. I found inside led with some components, should I bypass all of them and shunt + and - directly to legs of led?
here is a photo
Image

kimot
Normal user
Posts: 190
Joined: 12 Oct 2017, 20:46

Re: Sonoff Basic + wall push button with pilot light

#5 Post by kimot » 26 Feb 2018, 15:17

I think you cannot use it this simply way = modify LED circuit and connect switch contacts to sonoff

Color LEDs need 2.5 - 3.5V and sonoff GPIO is 3.3V

I can imagine this circuit:

+3.3V ----- R1 ------ R2 -------- LED ---------- GND

GPIO connect between R1 and R2.
R1 + R2 must be that value, to limit current for LED to correct level.

And
U(R2) + U(led) must be greater or equal min U (logH) for ESP2866.

I(led)*R2 + U (led ) >= min U (logH) ( cca 2,458 V )

(R1+R2) = ( 3.3 - U(led) ) / I(led)

U(led) depends mostly on LED color and technology - 2.5 - 3.5 V
So R2 not needed and R1 very small or nothing.

BUT !!! then, if you press switch, you will short +3.3V and GND !!!!
So, it is not possible this easy way...

kirkokuev
Normal user
Posts: 14
Joined: 24 Feb 2018, 21:23

Re: Sonoff Basic + wall push button with pilot light

#6 Post by kirkokuev » 27 Feb 2018, 11:32

I have touched legs of led with wires, coming from sonoff and led surprisingly worked, so maybe there is no need to attach additional resistors. However, I wonder if connected led will somehow affect how espeasy reads signal from push-button, wouldn't it think that button is always pressed?

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Sonoff Basic + wall push button with pilot light

#7 Post by toffel969 » 27 Feb 2018, 13:12

kirkokuev wrote: 27 Feb 2018, 11:32 I have touched legs of led with wires, coming from sonoff and led surprisingly worked, so maybe there is no need to attach additional resistors. However, I wonder if connected led will somehow affect how espeasy reads signal from push-button, wouldn't it think that button is always pressed?
Hi

What exactly are you trying to do though?

If I understand correctly you want to :
1. Use the Switch as push button for the Sonoff
2. Have the LED lit up to improve visibility at night

For
1. Connect the Switch between GPIO14 and GND
2. Does not need to be attached to GPIO, but only to 3,3v and GND.

So interference with GPIO wouldnt be a problem

If you want to control the LED as well (you could also control brightness using pwm command) , I suggest different approaches:

- switch of serial (in advanced tab) and use RX/TX (GPIO 1/3) to drive the LED. One of the two could give you problems with the unit not booting (not sure which one it was).
- Solder two cables parallel to the orignial Sonoff push-button (GPIO 0) and you that for the switch input. GPIO 14 would then remain free to drive the LED.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

kirkokuev
Normal user
Posts: 14
Joined: 24 Feb 2018, 21:23

Re: Sonoff Basic + wall push button with pilot light

#8 Post by kirkokuev » 28 Feb 2018, 13:16

If I understand correctly you want to :
1. Use the Switch as push button for the Sonoff
2. Have the LED lit up to improve visibility at night

For
1. Connect the Switch between GPIO14 and GND
2. Does not need to be attached to GPIO, but only to 3,3v and GND.
Thank you, that is clear explanation, exactly what I needed. Fortunately, I have three-wire cables going to all switches, so I can use two wires as GPIO and GND, and third one to connect with 3.3v. Ground will be common both for GPIO and 3,3v. I will have to modify switch, currently it uses spring contacts for led, so I will replace those with wires. If that will work I will get rid of impulse relays.
Controlling of LED wasn't a part of my plan, but having that as option is also useful.

kimot
Normal user
Posts: 190
Joined: 12 Oct 2017, 20:46

Re: Sonoff Basic + wall push button with pilot light

#9 Post by kimot » 28 Feb 2018, 23:32

If led lights, when connected directly to gpio, it means, that current flow through internal pullup is enough for this.
I think, you can use it this way - sonoff will read 1 when switch not pressed and 0 for pressed switch ( and LED will switch off for this moment )

kirkokuev
Normal user
Posts: 14
Joined: 24 Feb 2018, 21:23

Re: Sonoff Basic + wall push button with pilot light

#10 Post by kirkokuev » 04 Mar 2018, 14:43

Ok, so I followed suggestion from kimot, connected LED straight to gpio and ground and LED lights up allright on two switches. But, strangely, while one of sonoff is working perfectly, the other one is giving false positives (switch turns on and off on itself, as if I pushed the button). Both configs of espeasy are the same. Looks like the LED gives some noise. Is there any way to filter it out?

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Sonoff Basic + wall push button with pilot light

#11 Post by Domosapiens » 04 Mar 2018, 20:28

Use the internal pull-up for GPIO14 ?
Or
Use a pull-up resistor of 100K for GPIO14 to 3V3?
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

kirkokuev
Normal user
Posts: 14
Joined: 24 Feb 2018, 21:23

Re: Sonoff Basic + wall push button with pilot light

#12 Post by kirkokuev » 05 Mar 2018, 12:54

Domosapiens wrote: 04 Mar 2018, 20:28 Use the internal pull-up for GPIO14 ?
Or
Use a pull-up resistor of 100K for GPIO14 to 3V3?
I enabled internal pull-up, it won't help, however without it things are much worse, switch goes off randomly even when wires are not connected to led and I touch them with bare hand.
Would you elaborate on connecting resistor? Where exactly should I put it?

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Sonoff Basic + wall push button with pilot light

#13 Post by toffel969 » 05 Mar 2018, 13:51

kirkokuev wrote: 05 Mar 2018, 12:54
Domosapiens wrote: 04 Mar 2018, 20:28 Use the internal pull-up for GPIO14 ?
Or
Use a pull-up resistor of 100K for GPIO14 to 3V3?
I enabled internal pull-up, it won't help, however without it things are much worse, switch goes off randomly even when wires are not connected to led and I touch them with bare hand.
Would you elaborate on connecting resistor? Where exactly should I put it?
I really think it's a bad idea to drive the LED via the same GPIO that you are trying to use as input. Just don't and you dont have a problem.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

kimot
Normal user
Posts: 190
Joined: 12 Oct 2017, 20:46

Re: Sonoff Basic + wall push button with pilot light

#14 Post by kimot » 05 Mar 2018, 14:56

Try some serial resistor with LED.
LED will light less, but log 1 on GPIO will be better defined.
Will be good measure voltage on GPIO and compare with specification for log1 on ESP2866.

kirkokuev
Normal user
Posts: 14
Joined: 24 Feb 2018, 21:23

Re: Sonoff Basic + wall push button with pilot light

#15 Post by kirkokuev » 06 Mar 2018, 10:06

Something is wrong with the forum today.
Ok, I think I should revert to first suggestion and connect led separately, will try to do this on a weekend.

kirkokuev
Normal user
Posts: 14
Joined: 24 Feb 2018, 21:23

Re: Sonoff Basic + wall push button with pilot light

#16 Post by kirkokuev » 08 Mar 2018, 12:28

Reporting progress, I connected led separately as per toffel969 suggestion, good news that interference is gone. But led now is very bright, like two or three times brighter than on other switches, even those connected to 220v. I will see how well it works in the night, but I am not sure if it is appropriate for bedroom. Also is there any way to control 3.3v output on sonoff?

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Sonoff Basic + wall push button with pilot light

#17 Post by toffel969 » 08 Mar 2018, 13:52

kirkokuev wrote: 08 Mar 2018, 12:28 Reporting progress, I connected led separately as per toffel969 suggestion, good news that interference is gone. But led now is very bright, like two or three times brighter than on other switches, even those connected to 220v. I will see how well it works in the night, but I am not sure if it is appropriate for bedroom. Also is there any way to control 3.3v output on sonoff?
Either put a resistor in series or drive it of the other gpio, then you can set b rightness by means of pwm
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

kirkokuev
Normal user
Posts: 14
Joined: 24 Feb 2018, 21:23

Re: Sonoff Basic + wall push button with pilot light

#18 Post by kirkokuev » 09 Mar 2018, 12:45

So I reconnected led to the pin next to 3.3v, I can see that led is glowing, but much less than on 3.3v, it glows as much as on gpio14, but without interference. So far so good.
I disabled serial port and tried to control it via GPIO1 but with no effect ,it won't turn off or on, just stays glowing all the time.
Image

OK, I tinkered a little bit more, so this is not a GPIO1, but GPIO3, and I am actually able to control it via commands. Seems like problem is solved, thank you all for help.

pierce
New user
Posts: 2
Joined: 11 Apr 2022, 10:59

Re: Sonoff Basic + wall push button with pilot light

#19 Post by pierce » 11 Apr 2022, 11:41

This setup was done on a Sonoff Basic Rev 1, isn't it? I need to run a similar setup on some Sonoffs Basic R2 but since GPIO14 was removed, I was wondering if I can hook up a Pulse Switch to GPIO0 without having any problems. In hand with a small short cord it works, but I was wondering if I use long cables if it causes any problems relating to high resistance.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Sonoff Basic + wall push button with pilot light

#20 Post by TD-er » 11 Apr 2022, 11:55

Sonoff units always have their button (or at least one button for those with more than one) connected to GPIO-0.
By default it is pulled up and closing the button will pull it to GND.
This way you can use the button to enter flash mode during boot.

So if you plan to add something to GPIO-0, make sure it is not pulled down for a long enough time during boot.
e.g. a sensor which may send data is enough to make a reboot randomly fail when connected to GPIO-0.

pierce
New user
Posts: 2
Joined: 11 Apr 2022, 10:59

Re: Sonoff Basic + wall push button with pilot light

#21 Post by pierce » 11 Apr 2022, 12:27

Yes exactly. It will only be a return back pulse switch so it will give me the option to leave Basics on all the time while anyone else at home can use the wall switches as normal use. PS I have a Gewiss Playbus Pulse switching system at home. Eventually, I will remove the relays and use the switches as a Simple Rocker Switch. But my main concern is the protection of the CPU since probably ELV switching will run in parallel with 220v cables in the same piping. Any ideas, please??

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Sonoff Basic + wall push button with pilot light

#22 Post by TD-er » 11 Apr 2022, 16:29

Never assume these Sonoff units will be galvanic isolated.
The ones with power meters are obviously not isolated but the 'basic' ones are IMHO also not safe.
For example the older versions had a big trace on the PCB to carry the mains voltage to the connected appliance, but to handle more current, those were made thicker with tin and thus not isolated at all.
Also the distance between traces is not according to European safety rules so in humid environments you may still get sparks and/or shocks.

When switching something, please use optocouplers and make sure to use wires with proper isolation as thin wires should also not be placed near high voltage wiring with the kind of mediocre isolation you often see in these modules.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 33 guests