Ognjen Regoje bio photo

Ognjen Regoje
But you can call me Oggy


I make things that run on the web (mostly).
More ABOUT me and my PROJECTS.

me@ognjen.io LinkedIn

Relay not working with Raspberry Pi GPIO

#raspberry pi #technical

Was experimenting with Raspberry Pi and a relay recently (to turn lights on and off of-course) and had an issue with a GPIO pin being set to low not turn the relay off.

Turns out that the pins low is actually 3.3v and that was enough to trigger high on the relay itself.

Fixed by switcing the pin mode between input and output. If the pin is in input mode it’s voltage is 0.

  RELAY_PIN = 13

  # Turn the relay on:
  GPIO.setup(RELAY_PIN, GPIO.OUT)

  # Turn it off:
  GPIO.setup(RELAY_PIN, GPIO.IN)