0
\$\begingroup\$

This is my diagram: Circuit Diagram of NodeMCU connected to Relay

I'm running a breadboard with a NodeMCU powered by a USB 5V say from my laptop.

From the NodeMCU, I'm taking a 3.3v out to the VCC of the Relay and GND to GND of the relay with a D4 or D6 as my data pin to IN1 on the relay.

On the other side, I'm running a twisted wire pair from an AC strip to the relay and from there to the bulb.

I've stripped one wire and run it into the NC port and the same one comes from the COM back to the bulb.

My question is, is this okay and am I gonna blow something? I've not used resistors or the like. Also, can I run the bulb also through a DC source like a 9V battery instead of pluggin into the AC mains?

Update: I'm a nOOb to electronics so to clarify certain things, 1) The "lamp" is a 3W LED in a normal bulb holder. The bulb is rated at 220-240VAC at 50Hz 2) It is very possible I got the diagram wrong. It is my understanding of how the relay circuit works. 3) The relay is actually a 4-relay board with an opto-coupler etc (Refer to image)Relay with Opto-coupler

Relay Board link: REES52 Relay with Optocoupler

Imgur link to actual photos of my setup

\$\endgroup\$
  • \$\begingroup\$ What are the specifications on your "bulb"? What rated voltage? \$\endgroup\$ – Marla Dec 31 '18 at 15:58
  • \$\begingroup\$ In the diagram the note says "5V relay board with optocoupler". You're feeding it with 3.3V, and showing a traditional relay with a coil -- no optocoupler. What's actually going on there? \$\endgroup\$ – TimWescott Dec 31 '18 at 16:03
  • \$\begingroup\$ Your circuit shows the bulb as a 3 watt LED lamp and not a bulb. \$\endgroup\$ – Andy aka Dec 31 '18 at 16:04
  • \$\begingroup\$ @Marla - 220-240VAC at 50Hz. 3W LED in a holder connected to my AC Mains. \$\endgroup\$ – CoderX Dec 31 '18 at 16:13
  • \$\begingroup\$ @TimWescott - I'm sorry I'm bad at circuit diagrams I could be totally wrong. Please check the image. \$\endgroup\$ – CoderX Dec 31 '18 at 16:13
3
\$\begingroup\$

Firstly, think about what you're doing here. You say you're an electronics noob and you're playing with mains electricity.

You've kind of got the idea of the circuit, but missed out the optocouplers and various power supply inputs that are present on your relay board. My suggestion would be to do this in a safer way to start with, using say, a 12v battery and a 12v lamp or an LED instead of jumping straight into working with the mains which, could kill you, burn down your house or blow up your laptop if you get something wrong.

So, how to make this work...

Replace the 250V supply with something low voltage and safe, say 8AA alkaline batteries in a holder or a PP3 battery. Replace your 250v LED with a low voltage lamp 12v, 9v, 6v or whatever is close to your supply voltage, or ideally, an LED with a suitable series resistor (1k or more should do for a maximum of 12v) to limit the current.

The relay board has optocouplers, these need to be powered on the low voltage side via the Vcc pin. There's another Vcc pin on the relay board probably for the 5v relay coils. You'll also need to connect all the power supply (GND) ground connections on the input side together otherwise it won't work.

The 5v relay coils probably won't work from your 3.3v powered Node MCU but the optocouplers may.

Once you get the whole thing working with an LED, you can progress to wiring it for mains operation, but learn some more about mains electricity safety before you do that.

You shouldn't be messing with your bits and pieces of circuits on a breadboard. You'll have a proper enclosure which can be closed up to prevent you getting a shock or an eyeful of molten metal if something goes wrong. You'll also have properly fused the supply, be running it through an RCD and will have earthed the box if it's metal.

\$\endgroup\$
  • \$\begingroup\$ Okay. I completely agree with you which is why I have asked if a DC battery current will work. So thanks for a bit more clarification on this. I'm not gonna use the AC mains and safety is of utmost concern here for me as well. I'll get a lower VAC LED or something. As for GND. I run a wire from the GND of the NodeMCU board to the GND of the Relay optocoupler. I'm adding pictures of my setup. \$\endgroup\$ – CoderX Dec 31 '18 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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