How to connect a 3 way switch along with a spark controlled SPDT relay?

Hi All
First let me describe the requirement. I want to control an electronic equipment with spark core (from an app) as well as with a physical switch. The solution I came up with is to connect the relay along with a 3 way switch as shown below.

The issue is if I turn it off from the switch then there is no way of displaying its state in the app (which is currently off)??

Is there any solution to this ??
OR
Have I got it all wrong (combining with a 3 way switch)?? if so any other solution to control a device by spark as well as with a physical switch??

It depends what you want to do in the case the core wants the lamp on and your switch off? another option is to connect the switch to an input of the core, then your software can decide what to do

@bijay, if you are using AC voltage then you will need a voltage or current sensor to know if the light is on. Or perhaps a photocell that measures the light level. :smile:

Yes, I think a photocell is probably the easier thing you could use.

I’ve yet to find a current sensor I like for measuring AC current. Given the alternating nature of AC current current sensors are a bare to use.

@harrisonhjones, agreed on the current sensor issue. I plan to test a hall effect sensor idea to detect the presence of a current, not the magnitude to keep it to a boolean value. If successful, I will post my findings. :smile:

1 Like

I think that is very do-able. I have both an invasive and non-invasive current sensor and I have decided that while accurately determining current is difficult determining IF something is running wouldn’t be too hard.

1 Like

I agree with @remcohn. Let the spark handle switching the light, and take user input to control it. Like a momentary switch or even an (ON)-OFF-(ON) rocker for a more intuitive feel.

@CuriousTech, if there is existing AC wiring then it will be hard (and against construction code) to use the switch that way. :smile:

@peekay123 You wouldn’t want to use a big AC lightswitch anyway since it’s not momentary. A rocker would probably fit in a standard switch plate, but why put it there unless it’s convenient?

@CuriousTech, I believe the diagram shows an AC circuit and switch. He also wants to control the load with that switch thus the three way circuit. The Spark is not the sole power control point.

@peekay123 Right. I’m just offering alternatives to the 3-way. To me, that adds an unnecessary layer of complexity, when all you need to do is tell the Spark to handle it with the single relay as the only AC switch.

@peekay123, @harrisonhjones : your idea of using a photocell is probably the best option for a light bulb but I don’t think it will be of use if the load is something other than a light bulb. In that case as suggested by you something to measure the presence of a current will be help full. But currently I am not able to find anything that will serve the purpose.

@CuriousTech : Sorry but I could not grab your idea of “spark handling the switch and the user input to control it”.

The sole purpose of the 3 way switch is to control the load even if the wi-fi is down.

The spark is just less responsive when the internet is down. If you connect switches to interrupt capable pins, it will still catch the change. I’m not sure if it can set a pin from an interrupt though? You can test it all by switching off your router.

The idea is to only use the spark to switch the light via relay. To control that relay manually, connect 2 momentary switches to 2 digital interrruptable pins and ground. Set both pins to INPUT_PULLUP and attach interrupt routines as FALLING to each. When you get an interrupt on one, switch the relay on, for the other switch the relay off. Does that make sense?

1 Like

That’s really helpful , Thanks

Ok. The problem is we want to now use the physical switch as an input to the spark to help drive the On/Off decision. And with no new wiring. I think I came up with a great little hack to solve this… no sensors (light or current), just a digital input port.

In a nutshell, you bypass the wall switch and wire the output of the hot wire from the spark straight to the switch. Now, instead of the switch being attached to the lightbulb, you attach it to GND. On the ‘IN’ side of the switch leave one side open and attach the other to the existing copper running to the spark relay. Remove this wire from the spark relay and attach it to a digital port. Set that port up as a Digital Input port with that is pulled high by a resistor (internal or external). This digital port can now be read or interrupted on to get the wall switch position or event for changes.Write your code appropriately.

Let me know if this might actually work!

1 Like

@bijay: They make these things called “current sensors.” They come in either invasive or non-invasive versions. The invasive versions have a high watt low resistance resistor that they measure the voltage drop across to determine current. The non-invasive have a inductive ring which you feed the to-be-measured-wire through and the induced current in the ring can be measured. Sadly both of these methods are hard to use with AC for measuring true current but if you only need to know if they are “on” or “off” then either will work quite easily.

[Edit] After re-reading this I could see how the first sentence in my post could be see as condescending. I did not mean for that at all. Just a heads up

2 Likes

Sorry for digging this old thread up. @cloris if I understand your arrangement correctly, I should use a switch with one end connected to ground and other end collected to say D1. Then I need to set D1 as PULL_UP (I guess or may be PULL_DOWN??). Then I would be contonously digital reading the pin inside loop(). Based on any change in D1 I will change the state of the pin the relay is connected to.

Is my understanding correct?? Please let me know

Yes. By making D1 an INPUT that is PULLED_UP, it will stay HIGH in it’s natural state. When you flip your light switch and connect it to ground, D! will go LOW. As far as continuously reading… to start. I would wire up an interrupt to handle catching the state change from HIGH to LOW and vice versa. You should be able to test this out real easy on a bread board with some tiny stuff before you go into the wall.

Good Luck!

I agree with @CuriousTech the processor is more than smart enough to check switches, and turn a relay on or off. No light sensors required for this feat. Let the core/photon control the light (on or off).