1

I have had a new SSR delivered today.

I've been using a mechanical one just fine but it if in the lounge so wanting something quieter.

I am not so sure how to correctly wire it up as one side of the terminals are not marked to indicate their function.

I hooked it up com and no as I had on the mechanical and when running the script it turns on but not off.

Dc+ to 5v pin Dc- to gnd pin Channel 1 to gpio 22 Chanel 2 to gpio 17

I have tried com and n in both positions but get the sane result. Turns on but not off.

This is the relay Ihave

https://www.amazon.co.uk/dp/B00SYEDG7I/ref=pe_1909131_77697001_tnp_email_TE_AMZLdp_1

LIGHTSON SCRIPT

import RPi.GPIO as GPIO

def lights_on():
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(17,GPIO.OUT)
    GPIO.output(17,GPIO.HIGH)
    return '<img class="right" src="lightson.png" width="32" height="32">'

output = lights_on()    
f = open('/var/www/html/lightsout.html', 'w')
print >> f, output
f.close()

LIGHTSOFF SCRIPT

import RPi.GPIO as GPIO

def lights_off():
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(17,GPIO.OUT)
    GPIO.output(17,GPIO.LOW)
    return '<img class="right" src="lightsoff.png" width="32" height="32">'

output = lights_off()    
f = open('/var/www/html/lightsout.html', 'w')
print >> f, output
f.close()
1

If you are trying to switch a DC voltage, you can't use a SSR. They are used to switch AC voltage only.

EDIT There are two types of SSRs. One for switching AC voltage and one for switching DC voltage.

  • It might be fairer to say that the SSR spec'd in the question can't switch DC voltages - there are options for switching DC. – goobering Apr 30 '16 at 18:11
  • How have you both determined this as I am not seeing it say that? – Sauced Apples Apr 30 '16 at 18:19
  • Looking at the photo form the link on your original post I see 240 VAC on the black component ( which is the actual SSR ) – Garnett Haines Apr 30 '16 at 18:25
  • 240 VAC means 240 volts AC – Garnett Haines Apr 30 '16 at 18:27
  • ebay.co.uk/itm/… would this be fine? – Sauced Apples Apr 30 '16 at 18:28
1

That relay may not be suitable for the Raspberry Pi.

The blurb indicates that a low signal is 0-2.5V and a high signal is 3.3-5V. Perhaps the Pi isn't managing to generate a high signal.

You could test by connecting one of the relay inputs to a 5V pin rather than GPIO 17/22.


See if this script has any effect.

import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

print("output low")

GPIO.setup(17, GPIO.OUT)

GPIO.output(17, GPIO.LOW)

time.sleep(5)

print("output high")

GPIO.output(17, GPIO.HIGH)

time.sleep(5)

print("input")

GPIO.setup(17, GPIO.IN)

time.sleep(5)
  • Comments are not for extended discussion; this conversation has been moved to chat. – Ghanima Apr 30 '16 at 18:53
0

your board has on board driver so all you will need to do is turn on and off your GPIO and it will work fine. to make sure you can directly connect the relay input to 5V and GND and see if it turns on and off.

the relay you have will do AC switching only but you can get the SSR which can do DC also. when i work with AC and Pi together i try to isolate Pi from AC, just to prevent possible damage. in future you can use a PI hat and SSR relay board with On board isolation.

And Pi GPIO are 3.3V and lot of time these relay work with 5V only so if you use a SSR board like this you dont have to worry about the voltage shift.

with I2C you can chain multiple relay board together and control more relay using your Pi and at the same time you will have your GPIO for other uses.

-1

Toy need a signal level converter, like this one

  • Can you explain a little bit why? – Sauced Apples Apr 30 '16 at 16:05
  • @SaucedApples the situation is that the relay expects a 5V(Transistor-to-Transistor Logic, or TTL) signal level, its used on Arduino very often, if not always. The RPi uses a 3.3V(Complementary Metal-Oxide-Semiconductor, or CMOS) levels used in modern Integrated Circuits(or IC's). It's is just fine : no harm done, the signal is simple too weak to "fire-up", i.e. it can not open a transistor fully, so it can supply a relay with an opening signal. You need just to "translate" a weaker CMOS-level signal from RPi to TTL-level signal expected by a module. That's it! – Alexey Vesnin Apr 30 '16 at 19:51
  • That is a little nonsensical, @AlexeyVesnin. 1) logic level voltages do not strictly correspond to circuit technology. In fact CMOS based devices operate on different voltage levels, including 5V, 3V3, and lower voltages. 2) While Arduinos come with 5V logic levels they are not TTL but CMOS (e.g. the ATMegas are CMOS), see also here – Ghanima Apr 30 '16 at 20:12
  • @Ghanima I've pulled out a historical info, which is, of course, is not so strict nowdays. I do remember in my life when it was strict, but it was year 1989 =) Nowdays these level-naming conventions have absolutely no connection with a chip basis, of course. I've just made it as clear as possible, and - maybe too simple – Alexey Vesnin Apr 30 '16 at 21:02

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.