This is the circuit I have been using to implement a latching relay with a Raspberry Pi or a C.H.I.P., using only the 3.3V power supply.
Two logical outputs are used to reset & set the relay, and I’m using one of the two relay contacts to be able to double-check the current relay state.
You should use basic 20ms impulses to drive the relay. Here is a basic python sample code that does this on a Raspberry Pi:
try: import RPi.GPIO as GPIO except RuntimeError: print("Error importing RPi.GPIO! This is probably because you need superuser privileges. You can achieve this by using 'sudo' to run your script") exit(1) import time # example of GPIO init GPIO.setmode(GPIO.BOARD) # probe: pin #15, GPIO22 # set/reset: pins #16/18, GPIO 24/23 probe = 15 set = 16 reset = 18 GPIO.setup(probe, GPIO.IN) GPIO.setup(set, GPIO.OUT, initial=GPIO.LOW) GPIO.setup(reset, GPIO.OUT, initial=GPIO.LOW) # setting the relay output to LOW GPIO.output(reset, 1) time.sleep(0.02) GPIO.output(reset, 0) if GPIO.input(probe): # alarm if probe is not LOW print("unable to reset the relay, stopping here") exit(1) else: log.info("ok, latching relay is now LOW")
The relay is a NEC EE2, and is able to handle main 250Vac power, for a basic 60W load. It’s quite simple, and thus can be easily soldered on a basic breakout board.
Have fun! 🙂