Another Relay x16 question

The board is OPTICALLY ISOLATED so your GPIO output needs to be LOW and sink around 2mA of current for the relay to switch.

If you are powering the board from the DC input connector with 12V then all you need is a GROUND connection and 16 digital inputs that can SINK this 2mA of current.

The issue is that the opto isolators are driven with 5V via a 1K resistor. When you pull the GPIO low, it sinks around 2mA of current and the relay switches on. Now, if your GPIO is 5V based, the input will go to 5V when you switch off the relay. There is virtually no current drawn by the opto, small leakage maybe, but not enough to switch it on.

If however your GPIO is 3.3V and you set the GPIO to high, the opto will be seeing 5V - 3.3V = 1.7V and will most likely still be flowing enough current to switch on the opto, which confirms what you are seeing.

The only way around this is to use a transistor to drive the input of the board. Put a 10K pull down on the transistor base to keep it off when the GPIO is unknown (during bootup it is usually an input) Use a 4K7 to the transistor base from your GPIO pin. When the input to the transistor is pulled high with your 3.3V GPIO output, the transistor switches on and pulls the opto LOW and draws current so the relay switches ON. With the GPIO output low, the transistor will be off and there is no current flow through the opto.