2

I'm trying to use a 5V relay with my Raspberry Pi B (lastest revision) and my Pi refuses to set the value to 1 for the pin connected to my relay. I'm following this tutorial

Steps to reproduce:

$ echo 4 >/sys/class/gpio/export $ cd /sys/class/gpio/gpio4 $ echo out >direction $ echo 1 >value $ cat value 0

  • Assuming no error messages were given when you entered those commands. Something must be pulling gpio4 low. I'd remove it (the relay?) and confirm you understand the hardware. – joan Sep 30 '14 at 18:15
  • Yeah, no error messages are given. When I remove the relay, it does in fact work. I've created the circuit from this diagram. Hmm, I agree that it's probably an issue with the circuit (or my job recreating it). – rgardner Sep 30 '14 at 22:50
  • Perhaps the circuit uses a PNP transistor and you've used an NPN? – joan Oct 1 '14 at 5:57
  • Please post this as an answer and then marked as solved, thanks! – Fred Jan 25 '15 at 11:28
0

Turns out that the circuit uses a NPN transistor and I was using a PNP transistor. The PNP transistor was pulling the relay LOW and preventing the Raspberry Pi from setting the value to HIGH (1).

edit:

It may have been a misconnection in the wiring. The transistor was definitely switched, but a bad connection may have been fixed in the process.

  • No, a PNP transistor would not explain this unless you also misidentified the base and had an insufficient base resistor. With a properly chosen resistor, no transistor misconnection or mis selection could force the GPIO to read low. – Chris Stratton Jan 26 '15 at 3:39
  • Hmm, I only recall switching the transistor. It's possible that a misconnection was fixed in the process. I don't have concrete evidence at the moment to support either claim, so I'll update my answer with that information. – rgardner Jan 28 '15 at 0:09
  • Still, this cannot happen unless your base resistor is too small. – Chris Stratton Jan 28 '15 at 13:10

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.