Building a Raspberry Pi IOT Garage Door Opener - Part 2 (Hardware Setup)
Pretty simple really. 4x of the relay modules pins are connected to the Raspberry Pi GPIO pins. The normally open output of the relay will be connected across the garage door switch inputs. Then we simply have the USB WiFi dongle and power for the Pi.
I found the Pi A+ and relay fitted very nicely together inside a Pi2 Model B Case. The A+ has the same mounting points as the Pi2/B+ so clips in fine
Connecting the relay module to the Raspberry Pi
Pi Pin 6 (GND) -> Relay GND
Pi Pin 9 (GND) -> Relay IN1
Pi Pin 11 (GPIO 17) -> Relay VCC
Relay Normally Open -> Garage Door Switch
Relay Common -> Garage Door Switch
If your relay module has a jumper between VCC and RVCC - remove it.
The relay is a 5V relay, so it requires a 5V power supply. Our GPIO pins go between 0V (low) and 3.3V (high), so we need to have a separate supply for the relay and opto-coupler.
Here is a circuit diagram of the relay module.
We are connecting the IN1 pin to GND and the VCC pin to our GPIO pin. Therefore, when the GPIO pin goes high (3.3V), current will flow through the opto-coupler (U1) which will trigger the relay. We will use the normally open pin of the relay so the garage door switch is only pressed while the relay is activated.
- Mount the Raspberry Pi board into the case
- Connect the relay module to the Pi GPIO's using your Dupont cables.
I mounted my relay on it's side on-top of the A+ board. On a slight angle it fitted very nicely between the USB port and the DSI connector.
- A dab of hot glue at both ends of the relay module keeps it in place nicely. I also glued the output wires to keep these from 'wiggling' about.
- Make sure you don't glue the WiFi dongle in place. We will need to remove this and plug in a keyboard in the software setup.
That's the hardware sorted.
We won't connect it to the garage just yet as we first we need to setup the software to communicate with our relay module.
Part 3 (Software Setup - Steps 1-4) is now up HERE.