I am creating a smart switch for some exterior lights. It is going well except for one thing. I am trying to figure out a way to detect when someone uses the physical switch to turn on the light and not my webpage or speaker.
I can track when someone turns on the light with a "smart " option (speaker/webpage/app) but if someone uses the physical switch, I have no way of knowing. I want to create a schedule for these exterior lights to turn on and off. but if someone uses the physical switch, then that schedule is messed up.
So does anyone know of a good way to detect when the light is turned on with the switch?
I have tried connecting a 120v to 5v converter from the terminal on the switch that goes to the lights to a pin on my microcontroller. So when the light is on that pin becomes HIGH. This worked ok, but I dont like that its 5v, I rather have it be 3.3v.
the reason I am looking for another option is because I cant find any 120 to 3.3v converters that are linear and the 120 to 5v ones I have found, dont seem to be reliable. So i was hoping there was someone who thought of something I havent.
I have seen those before. the only thing that made me nervous with that current sensor, the ACS712 module, is using it with the 120v. Every tutorial ive seen or read about someone using it, they were always using a smaller power supply, like only 25v. Reading some articles, it looks like it should be fine with the higher voltage but thats the only reason I was hesitant.
thats a good simple solution. When i find a converter that is reliable. Unfortunately the only ones I have found seem to be cheaply made and fail after a couple month. Plus I am new to them but a lot of the ones I find are switching power supplies. Which for this use case I dont think will work. but again im new to those and have not experimented with them much.
But thank you for the comment, this is definitely something that will probably work if i need to.
Using a phone charger, or similar, is a very safe way to solve the needs. Mains can, and do, kill people, when used by none professionals.
Chargers are usually reliable. Don't by cheap Ebay mystery circuitry.....
Have the light switch operate a relay , use a contact as a digital
Input .
Depending on the wiring you might need the relay to operate the light via its contact and a spare contact set as the digital input ( eg if a feed from the smart switch would also operate the relay).
Another option is to use the smart switch and light switch in a “ two way circuit “ and drive the relay from the feed to the bulb.
That way you can detect if the light is on and switch it off and visa versa via your smart switch
To facilitate our help, you can post a drawing showing the physical positions (location) of your "arduino", the lamp and the physical switch.
And it would also help if you post a schematic of your project.
I suggest using an optocoupler with a resistor in parallel with the lamp.
With the lamp is on, current (very small, around 20mA) passes through the opto and informs that the lamp is on.
With it is off, nothing passes through the opto and it will know that the lamp is off.
Something similar to this schematic:
So this is a rough drawing of what I have now. The part I am trying to alter or get rid of is the bottom middle, the 120v to 5v transformer. essentially what that is doing is getting power when the light is turned on, gets volts down to 5v and connects to a pin. I read that pin state and if light is on it will be HIGH. This way regardless if the physical switch is used or smart function is used. I will know the light is on. Due to part availability, part quality and space (im trying to fit all this in an electrical box behind the switch) I was hoping there was something else i could do to get the light state. I would have no problem changing any part of this configuration.
at the moment a current sensor seems like my best shot?
and please forgive me if the drawing is bad. I dont have to make many of these so im an amateur