i am new to these circuit things, i am using Node MCU (ESP8266) board with relay board. To connect to a bulb, but i want to keep my old (one way) switch as it is. Also i want to add internet switching to this button.

How my circuit should look like? Two way switch will be compulsory to use here? What my circuit should look like? with two way switch and one way switch.

Thank you! (in advance)

closed as off-topic by per1234, user31481, gre_gor, jfpoilpret, KIIV Feb 7 '18 at 7:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about Arduino, within the scope defined in the help center." – per1234, Community, gre_gor, jfpoilpret, KIIV
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Welcome to Arduino SE. Please realize that this is not a free design house, homework-answering service or an on-line technical encyclopedia, copied out to you on demand. People will help you take the next step if your question shows that you've done as much as you possibly could on your own - which your post doesn't. Please revise your question showing your work and findings so far. Or delete the question if Internet searches give you your answer anyway. – user31481 Feb 4 '18 at 23:43
  • 1
    are you ok with the light switch being "wrong" if you change it remotely? if so, then just use a relay and have the nodeMCU toggle the relay on switch change, as well as from http. you connect the relay module to GND, VIN, and GPIO 4 or 5. Connect the switch to GND and the other GPIO 4/5, and set the pin mode to INPUT_PULLUP. Connect the AC hot to the relay. done. – dandavis Feb 6 '18 at 0:27

First of all, a light bulb works on regular 110 or 230V AC depending on where you live, so directly connecting a wire to, for example, see if the hardware switch is turned on, would fry the NodeMCU. You'll need a relay break-out board that can handle these outputs on the COM/NO/NC (which most of them do) but they usually operate on 5V DC.

A NodeMCU can thus only supply the trigger signal to the relay, you'll need for example a AC to 5V DC power supply (like an iPhone adapter) to power your circuit. The circuit will contain of the relay board (connected with its DC in and out to the adapter and the com port to one of the GPIO's from the NodeMCU) and the NodeMCU itself as the 'brain' of the operation.

I don't exactly know what you mean by 'two-way switch' but the way I'd handle the situation is to wire the switch to the NodeMCU. This means the switch is connected to the 5V power adapter and when the switch is on, the nodeMCU will know because there will be a positive value at one of the GPIO's (whichever you choose). You can then also handle both commands from a server and the switch itself.

I'm doing kind off the same thing here with a NodeMCU working as a garageport opener with MQTT communication to a Homebridge server and MQTT broker running on a Raspberry Pi. If you want the code (still work in progress though) let me know ;)

EDIT Here is the schematic you asked for. not the prettiest thing but it should make things clear. Let me know if you have any more questions!


simulate this circuit – Schematic created using CircuitLab


  • Hello, thank you for great explanation, but i want to know the circuit diagram. Is that possible from your side. I am using proper system as your mentioned. But i am not getting the circuit connections to connect the switch from relay to bulb. Can you help me with its suggestion? – user3201500 Feb 4 '18 at 20:13
  • I edited the answer with a schematic for you @user3201500 – Beau Mangodt Feb 4 '18 at 22:19
  • OK sure i will check and revert you soon. – user3201500 Feb 5 '18 at 8:44
  • That's not exactly "keeping the old switch as it is" - However, to keep the old switch, as long as it's a "two-way" switch, then, yes, you can keep the old switch, but you still have to make a minor change to it's wiring - and then wire in the relay – Jaromanda X Feb 5 '18 at 9:26
  • @JaromandaX Yea, I know... but there is no other way to let the NodeMCU have full control over the circuit. If you wanna attach an app to the system which controls the lights and if you just wire in the relay to the existing circuit, then when the power switch is flicked, the NodeMCU would not know about it. You have to have a input which signals the nodemcu that the switch is flicked. It's better this way, trust me I'm an engineer :D – Beau Mangodt Feb 5 '18 at 9:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.