This is my first Raspberry Pi project. I’m a bit of a noob at the Pi, Python and other types of programming languages, as well as circuits and such. I’m trying to open my sliding gate to the entrance of our house with a Pi, utilising Python.
I have connected the Raspberry Pi3 to my PC via WI-Fi, using the command line over ssh. I have then used jumper wires to connect the Pi’s GPIO pins to the pins on a Arduino Compatible 4 Channel 12V Relay Module. From the Pi to the relay module, I have connected the ground to the ground, 5v to the VCC, and GPIO 17 (BCM) to IN2. On the relay module I have jumper wires connecting from the 2nd channel to the control board of the gate motor at TRG and COM, which I am quite certain are the correct inputs as when I stick the wires in, the gate opens/closes. When I run the code the gate doesn’t open. I am a Python code on the command line, which is to operate a GPIO pin to complete a circuit and open the circuit so that the gate can be opened and closed. I’ll take a picture of the Pi, relay module and gate motor, as well as a picture of the Python code that I am using. I am assuming the Python code is incorrect, or that the Pi cannot give the relay enough power.
Would anybody have any ideas as to how I could make this work?
#!/usr/bin/python
#import required python libraries
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
pinList = [17]
for i in pinList:
GPIO.setup(i, GPIO.OUT)
GPIO.output(i, GPIO.HIGH)
def trigger() :
for i in pinList:
GPIO.output(i, GPIO.LOW)
time.sleep(0.5)
GPIO.output(i, GPIO.HIGH)
try:
trigger()
except KeyboardInterrupt:
print " Quit"
GPIO.cleanup()