Arduino Due to drive a Sainsmart 16-relay 12 volt relay board

I’m using an Arduino Due to drive a Sainsmart 16-relay 12 volt relay board. I know that the Due is 3.3 volts, but the problem I’m having is that when the output pin goes low there’s a residual 0.15 volts on the circuit, and the relay remains on (the opposite of my original concern that the 3.3 volts will not be able to drive the circuit.) I used a 580 ohm resistor to pull down the voltage to no avail, so this isn’t just a pull-down issue. What’s going on here? Do I need to use an intermediate transistor to fix this?

FYI – the Due has all the features that I need, and I need more than 8 relays for my project, so it’s important that I use this configuration.

I have used dual relay boards but not the one you are speaking of. I didn't need any pull down resistors with my setup.

Assuming you set the pin as an output and digital write the pin HIGH in your set up code. Assuming you have a 12 V power supply for your relay board power.

When you digital write the pin LOW in your code the relay doesn't close?

Most relay shields are active LOW. So the lower you pull that voltage, the more chance the relays will remain on.

To turn the relays OFF you need to send the input HIGH (or leave it open circuit)

I think I got it. The Sainsmart 16 relay 12 volt board pins are normally high at 5v. They need to be driven low, but the Arduino due board can't sink this voltage. By inserting a P2N222A transistor, setting the emitter to ground, this drives the Sainsmart pin to 0, and thus energizes the relay. This means I'll want to create an interface board between the Arduino and the Sainsmart relay board with 16 transistors, but that appears to be the solution.

Any other more elegant ideas?

danmertens: I think I got it. The Sainsmart 16 relay 12 volt board pins are normally high at 5v. They need to be driven low, but the Arduino due board can't sink this voltage. By inserting a P2N222A transistor, setting the emitter to ground, this drives the Sainsmart pin to 0, and thus energizes the relay. This means I'll want to create an interface board between the Arduino and the Sainsmart relay board with 16 transistors, but that appears to be the solution.

Any other more elegant ideas?

Your relay shield is behaving fine, there's no need for any extra interface. It's just your understanding that's getting the better of you.

You make the relays ACTIVE by sending them LOW and that's already happening. You turn them off again by sending them HIGH.

So within your sketch you would have this kind of thing.

//Turn relay ON
digitalWrite (relayPin, LOW);

//turn relay off again
digitalWrite (relayPin, HIGH);

Note: Many of these boards do not need to be driven by a 5V power supply. A 3.3V power supply should work fine. And can be less dangerous for your Due. Simply replace the 5V Power input with a 3.3V from the Due board.

I wonder if what ever danmertens is trying to turn on and off with the relay is hooked up to the appropriate terminals on the relay. There are three terminals and it can be confusing.

Also thought it was a matter of sinking current not voltage. The spec sheet for the board he is using talks about

12V 16-Channel Relay interface board, and each one needs 15-20mA Driver Current

One of the product reviews said this (for use with a Raspberry Pi)...

This board works well with the Rpi but requires a little thought to implement correctly.

First of all the VCC-JD jumper must be removed to isolate the coil voltage from the signal voltage.

The logic is backwards from what might be expected. When the Rpi GPIO or port expander pin is "off" (sinking voltage) the relay is energized.

The two relay version of this board is easily modified so that when a high is presented, the relay energizes. A trace cut and a couple of jumpers are all that are needed.

Other than that, no other considerations are needed.

There are some that say that another driver transistor is needed to interface this to the Rpi. This is NOT true. Having said that, there is the advantage that the logic is reversed (GPIO Hi=ON) when a transistor is added. One could add a hex inverter like a 74HC540 and do the same thing. The VCC-JD/VCC jumper must be re moved and +5 volts from a separate power supply be fed to VCC-JD. A wall-wart works nicely and maintains isolation.

I recommend that a I2C port expander such as the MPC23107 or MPC23008 be used with this relay board. An SPI bus port expander could also be used (MPC23S17 or MPC23S08) with the Rpi. Utilizing both I2C buses on the RPI, that means that a total of 256 relays can be connected to the Rpi. In addition another 256 relays can be connected via the SPI bus. for a grand total of 512 relays controlled by a single Rpi.