I am trying to control a relay with Pi3B.

Whenever I run GPIO.setup(port, GPIO.OUT) my relay starts working,

then any other command I try, eg. GPIO.output(port, GPIO.HIGH) or GPIO.output(port, GPIO.LOW) doesn't change the relay

Agian When I switch the GPIO.setup(port, IN) or GPIO.cleanup() my relay turns off. So only way I can control that relay is changing the IN/OUT mode of that port. What is missing here?

Here is my connection.

Relay VCC - Pi Board Pin 02

Relay GND - Pi Board Pin 06

Relay IN - Pi Board pin 08

Relay is 220v- 5v one channel relay

  • Is your pin numbering correct? wiringpi.com/pins – MadMike Apr 4 '17 at 8:54
  • Try driving something simple (like a LED light) to factor the relay out of the problem. – Dmitry Grigoryev Apr 4 '17 at 11:32
  • Your relay module is not suitable for Pi control. Buy a relay module which specifies it can be controlled by a 3.3V GPIO. – joan Apr 4 '17 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.