# Switching a relay from its supply (2 Relay Module, VCC to IN1, doesn't work)

I searched far and wide but couldn't find an answer to my question. I've read the datasheet and I've look at schemes. I'm not very experienced with electronics.

This is the module I will be talking about:

Let's say I apply 5V to VCC from a given power supply, and then connect the ground. If I short IN1 and IN2 with VCC, nothing happens. Why is this so? Logic dictates it should, because when an Arduino controls the relay it powers the relay from 5V and then uses the same power supply to switch the relay with a pin connected to IN1 and IN2.

Why wouldn't it work with a simple 5V power supply? The power supply I used was my phone's adapter, it delivers exactly 5V.

Is there a way to short something to make it work?

Here's my scheme:

The scheme's idea is to switch between 5V from the wall and 5V from a battery. If power from the wall is available, then the battery is disconnected and recharged, if power is out then the battery kicks in.

I know MOSFETs will probably be better in this case but I've already soldered the thing.

Thanks!

• I found that if you apply 5V to D1 and D2 instead, the relay switches on/off and works as I intend to use it. Isn't there a way to make it work using the pins that are already there? – Eduard G Jun 28 '17 at 14:20
• See my answer about the IN pins needed negative logic, i.e. they need to be pulled low to turn on the relays. – J Rodgers Jun 28 '17 at 14:24

The module you are using needs the inputs to be pulled to 0V (ground) in order to switch the relay.

Check the manufacturers webpage for the module:

https://www.sainsmart.com/sainsmart-2-channel-5v-relay-module-for-arduino-raspberry-pi.html

This has a picture of the input circuitry on the module, which uses an optocoupler:

You need to redesign the rest of your circuit to take account of the fact that the inputs take negative logic:

INput: Low, Relay ON INput: Vcc or floating, Relay OFF

• Ohh. That helps! So the Arduino also connects them to ground when pulling a pin low? – Eduard G Jun 28 '17 at 14:26
• Yes - with most microcontrollers and digital logic, you can consider a logic Low as a connection to Ground, and a logic High as a connection to the positive supply. – Peter Bennett Jun 28 '17 at 15:32

If I'm not mistaken, these modules are "active low", which means IN1 and IN2 are already pulled to VCC and you have to pull them low (read: connect to GND) to activate the relays.