I am trying to automate our front gate. The gate is operated by a 12V remote control. My idea is to get the Raspberry Pi to press the button and automate this.
Working towards this I have connected a 6V battery pack to buzzer through a battery to duplicate the functionality of the remote.
This simple circuit worked. You can press the button and the buzzer sounds.
I added an S9013 transistor across the switch and connected the base to the Raspberry Pi through a 10KΩ resistor.
Here is my circuit diagram:
I have got a simple piece of code running.
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT) while True: GPIO.output(18, True) time.sleep(1) GPIO.output(18, False) time.sleep(1)
This should cause the buzzer to beep each time the output goes HIGH.
I have reworked the example to flash an LED. This worked so I know the GPIO pin is correct.
What could I be doing wrong?
Update: Tying the Raspberry Pi GND to the GND of the batteries fixed it.