I've setup a MCP23017 16-bit I/O expander with a rPi model B via i2c, and I am able to control components like LEDs on the channels GPA0-GPA7 using code like this;
# set GPA pins to output i2cset -y 1 0x20 0x00 0x00 # set GPA0 pin to on, (led on) i2cset -y 1 0x20 0x14 0x1
However what I want to do is control a 12V electromagnetic lock from a relay, and though I am able to trigger the relay, its unreliable and setting a pin on the MCP23017 to LOW doesn't always trigger the relay.
The led on the relay board is dim, compared to when its manually triggered by putting IN2 to GND
The relay is triggered active-low, and the relay specs suggest 0-0.5V is required to trigger it.
# set GPA0 pin to on, (relay on) i2cset -y 1 0x20 0x14 0x0
The circuit is currently setup like this with a relay instead of the led;
The relay however is triggered active-low, and so is looking for a Voltage between 0-0.5 Volts compared to ground.
However low-output on the MCP23017 GPA0 pin is measured at about 0.7 - 0.9 volts, and this doesn't appear to be low enough to trigger the relay.
The data sheet for the MCP23017 says that output-low should be less than 0.6 V. So at the very least the MCP23017 is out of spec.
The schematic from a similar relay board;
- 5V 2-Channel Relay interface board, and each one needs 15-20mA Driver Current