I received a document from a friend and he recommended this relay for GPIO control, as it's already been manufactured into a board with ready to use screw terminals. It has build in FETs to source the extra current required for mechanical relays to be triggered.
There are 4 connections required:
A common ground (that's shared to all relays) that connects to the RPi
Separate inputs powered by individual RPi GPIO lines (to trigger relays)
A high voltage input
A high voltage output
The high voltage inputs/outputs are the connections that are made or broken by the relays in accordance to their input lines.
This is the AWESOME C program he shared with me for remotely switching GPIO pins over SSH.
I haven't got time to tried it. It would be appreciated if you shares me your feedback with this program.
#include <wiringPi.h>
#include <ncurses.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
int main (int argc, char *argv[]) {
char charIn;
int input;
int pinStatus[8] = {0}; //Set all array elements = 0
int pinName[8] = {4,17,18,21,22,23,24,25};
int i;
int row;
int col;
int delay = 100;
if (wiringPiSetup() == -1) return(1); //wiringPi initialisations
for (i = 0; i < 8; i++) {
pinMode(i,OUTPUT); //GPIO initialisations
}
if (argc == 2) delay = atoi(argv[1]);
if (argc > 2) {
printf("Invalid Arguements.\n");
return(2);
}
initscr(); //Initialise window
noecho(); //Don't echo keystroke onto the window
curs_set(0); //hide cursor in terminal
timeout(delay);
while(charIn != 27) { //while ESC isn't pressed
clear();
getmaxyx(stdscr, row, col);
for (i = 0; i < 8; i++) {
mvprintw(row / 2 + i - 4,col/2 - 6, "GPIO%02d: %s\n", i ,(digitalRead(i))?" ON":" OFF");
}
refresh();
charIn = getch();
input = charIn - 49; //get keypress data
if (input >= 0 && input < 8) { // check if keypressed
switch ((digitalRead(input))) {
case 0:
digitalWrite(input,HIGH);
pinStatus[input] = 1;
break;
case 1:
digitalWrite(input,LOW);
pinStatus[input] = 0;
break;
}
}
}
clear();
refresh();
endwin();
return 0;
}




