I am having troubles setting a simple Relais to On and Off. My code is quite simple:


now when this runs it puts the pin to high correctly, but not back to low afterwards. i.e. the pin stays high forever or in other words, the relais opens but does not close.

i have tried this with multiple pins and they all show the same behaviour.

When measuring voltage between one of the 5V pins and the output pin with a multimeter, it shows that the pin has 5v when high and 1.7v when low. shouldnt it be 0v when low? i guess that 1.7v is enough to keep the relais open? could 5v-1.7v = 3.3v mean something?

Is this a problem of the relais or of the pi?

  • If you feed 5V into any GPIO pin on your Raspberry you will let the magic blue smoke escape and a blue smoke refill costs at least £35. You will get a dead RPi to frame and hang on your wall. You may be too late already you RPi may be dying. The maximum voltage on ANY GPIO is 3.3V. – Dougie Sep 28 '19 at 7:56
  • @Dougie i am not feeding the 5V into a pin, i am just measuring it. – clamp Sep 28 '19 at 7:58
  • You are probably using one of the relay modules designed for Arduino (but as you haven't specified what we can't know). While they MAY work on a 5V Arduino they are a prime example of POOR circuit design and may damage your Pi (as well as not working). – Milliways Sep 28 '19 at 8:07
  • @Milliways that is true. it is a Mingling JQC-3FF-S-Z China/Ebay relais. Can you recommend a proper one for Raspberry? – clamp Sep 28 '19 at 8:10
  • 1
    @clamp, You might like to read the warning, explanation, and relay selection in my answer to the following question: raspberrypi.stackexchange.com/questions/99988/…. – tlfong01 Sep 28 '19 at 8:17

Browse other questions tagged or ask your own question.