User avatar
edsulst
Posts: 59
Joined: Sat Nov 16, 2019 7:39 am
Location: Goes, The Netherlands

Problem with relais module

Sat Feb 13, 2021 3:04 pm

Hi there,

I have a problem controlling a relais module.
I've bought a 5V relais rodule (https://www.hobbyelectronica.nl/product ... anaals-5v/) and when I connected this to my Raspberry I blew up my GPIO pins. I don't what I was doing wrong, because I've connected the VCC to the 5volt and GND to the ground on the Raspbery.

So I bought another Raspberry and connected the VCC to the 3.3volt and the GND to the ground of the Raspberry.
This works without any problems. At least, I thought.
With some buttons I control my GPIO pins and those GPIO pins are connected to the relais module.
After I press a button the correct relais will come up. When I press another button the first realais is going down and the second relais will come up. Sometimes it works, sometimes it doesn't.
For some reason my Raspberry completely shuts down, and not in a normal way.

I though it was because the power that the relais module needs is to large so it drains the power to my Raspberry and if the power is too low, the Raspberry is going down.

So, with that in mind, I bought a 3.3V relais board (https://nl.aliexpress.com/item/40003320 ... 4c4dyUfsGc).
Unfortunately this gives me the same problem. I sometimes can press one or to buttons but then my Raspberry shuts down for no reason.
(I know there must be a reason, but I don't know what to do anymore)

Below you will find my code. The code works, although someone suggested to make routines, because the 8 buttons to control my relais module are almost the same codewise. Therefore the Pyton code could be a lot shorter.
I will try to take a look at that, but for now my code works fine.

In short what my code does:
When pressing a button a movie starts to play and a relais turns on and stays on for the time of te movie.
If you press another button, all relais are turning off, another movie starts to play and another realais turns on.
The playing of the movies works like a charm, but when I connect the relais module, the problems like I mention here above starts.

Does anybody can help me out with some suggestions with the 3.3v or 5v relais board ?

// Edwin.

My code:

Code: Select all

#!/usr/bin/env python

##################################################################### 
## 
## SGB Seinhuis Infotainment Systeem.
## 
## Dit systeem bevat 8 drukknoppen die elk een relais aansturen.
## De drukknop start een filmpje en schakelt een relais die een led/spot aanzet.
## De led/spot blijft gedurende de tijd van het filmpje branden.
## 
## Er is een 9e drukknop gedefinieerd waarbij er tussen (momenteel) 3 talen (nl, uk, de) geschakeld kan worden.
## Wordt er met meerdere talen gewerkt, dan moeten er dus voor elke knop 3 filmpjes in de genoemde talen beschikbaar zijn.
## 
## Van alle acties m.b.t. de drukknoppen wordt per dag een logfile bijgehouden, mits er een internetverbinding is.
## 
## Het systeem is met 2 knoppen in- of uit te schakelen, waarbij de gehele stroomkring onderbroken wordt.
## 
#####################################################################


import RPi.GPIO as GPIO
import os
import sys
from subprocess import Popen
import time
import logging
from datetime import datetime
from tinytag import TinyTag 

vandaag = datetime.today().strftime('%Y-%m-%d')
logmap = "/var/www/html/logging/"
logbestand = logmap + vandaag + ".txt"
logging.basicConfig(format='%(asctime)s %(message)s',datefmt='%d-%m-%Y %H:%M:%S', filename=logbestand,level=logging.DEBUG)

Talen = ['nl','uk','de'] # define list of the languages
keuze = 0 # set counter to 0, initially use the first language. Note the first is 0 not 1
Taal = Talen[keuze]
print(Taal)
omxc = Popen(['omxplayer', '-o', 'both', '-b', '/var/www/html/audio/' + Talen[keuze] +'.mp4'])
time.sleep(0.25)


def button_stopmovie(channel):
    os.system('killall omxplayer.bin')
    time.sleep(2)
    GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_3_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_4_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_5_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_6_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_7_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_8_GPIO, GPIO.HIGH)  
    player = True
    
def button_shutdown(channel):
    os.system('killall omxplayer.bin')
    time.sleep(2)
    GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_3_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_4_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_5_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_6_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_7_GPIO, GPIO.HIGH)
    GPIO.output(RELAIS_8_GPIO, GPIO.HIGH)  
    time.sleep(3)
    os.system("sudo shutdown -h now")
    time.sleep(3)

GPIO.setwarnings(False)  # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering

# Declare Relays pins
RELAIS_1_GPIO = 12
RELAIS_2_GPIO = 16
RELAIS_3_GPIO = 18
RELAIS_4_GPIO = 22
RELAIS_5_GPIO = 32
RELAIS_6_GPIO = 36
RELAIS_7_GPIO = 38
RELAIS_8_GPIO = 40
GPIO.setup(RELAIS_1_GPIO, GPIO.OUT) # GPIO Assign mode
GPIO.setup(RELAIS_2_GPIO, GPIO.OUT) # GPIO Assign mode
GPIO.setup(RELAIS_3_GPIO, GPIO.OUT) # GPIO Assign mode
GPIO.setup(RELAIS_4_GPIO, GPIO.OUT) # GPIO Assign mode
GPIO.setup(RELAIS_5_GPIO, GPIO.OUT) # GPIO Assign mode
GPIO.setup(RELAIS_6_GPIO, GPIO.OUT) # GPIO Assign mode
GPIO.setup(RELAIS_7_GPIO, GPIO.OUT) # GPIO Assign mode
GPIO.setup(RELAIS_8_GPIO, GPIO.OUT) # GPIO Assign mode

# Declare pushbutton pins
# Don't forget to add a "1 kOhm" resistor between each pushbutton and GPIO pin or you'll fry your pins !!!
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP)  # Pushbutton
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Pushbutton
GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Pushbutton
GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Pushbutton
GPIO.setup(29, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Pushbutton
GPIO.setup(31, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Pushbutton
GPIO.setup(33, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Pushbutton
GPIO.setup(35, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Pushbutton
GPIO.setup(19, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Pushbutton Taal !!

# Declare button to stop the playing movie
#GPIO.setup(37, GPIO.IN, pull_up_down=GPIO.PUD_UP)
#GPIO.add_event_detect(37,GPIO.RISING,callback=button_stopmovie, bouncetime=5000) 

# Declare button to shutdown Raspberry Pi
GPIO.setup(37, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.add_event_detect(37,GPIO.RISING,callback=button_shutdown) 

# Set states
last_state1 = True
last_state2 = True
last_state3 = True
last_state4 = True
last_state5 = True
last_state6 = True
last_state7 = True
last_state8 = True

input_state1 = True
input_state2 = True
input_state3 = True
input_state4 = True
input_state5 = True
input_state6 = True
input_state7 = True
input_state8 = True
quit_video = True

player = True

# Declare time for turning off the relays after specific time
now = time.time()
stop = now - 1
while True:
    # Declare movies and logname
    movie1 = ("/var/www/html/movies/" + Talen[keuze] + "/1_" + Talen[keuze] + ".mp4")
    movielog1 = ("film 1 " + Talen[keuze])
    movietime1 = TinyTag.get(movie1)
        
    movie2 = ("/var/www/html/movies/" + Talen[keuze] + "/2_" + Talen[keuze] + ".mp4")
    movielog2 = ("film 2 " + Talen[keuze])
    movietime2 = TinyTag.get(movie2)

    movie3 = ("/var/www/html/movies/" + Talen[keuze] + "/3_" + Talen[keuze] + ".mp4")
    movielog3 = ("film 3 " + Talen[keuze])
    movietime3 = TinyTag.get(movie3)

    movie4 = ("/var/www/html/movies/" + Talen[keuze] + "/4_" + Talen[keuze] + ".mp4")
    movielog4 = ("film 4 " + Talen[keuze])
    movietime4 = TinyTag.get(movie4)

    movie5 = ("/var/www/html/movies/" + Talen[keuze] + "/5_" + Talen[keuze] + ".mp4")
    movielog5 = ("film 5 " + Talen[keuze])
    movietime5 = TinyTag.get(movie5)

    movie6 = ("/var/www/html/movies/" + Talen[keuze] + "/6_" + Talen[keuze] + ".mp4")
    movielog6 = ("film 6 " + Talen[keuze])
    movietime6 = TinyTag.get(movie6)

    movie7 = ("/var/www/html/movies/" + Talen[keuze] + "/6_" + Talen[keuze] + ".mp4")
    movielog7 = ("film 7 " + Talen[keuze])
    movietime7 = TinyTag.get(movie7)

    movie8 = ("/var/www/html/movies/" + Talen[keuze] + "/6_" + Talen[keuze] + ".mp4")
    movielog8 = ("film 8 " + Talen[keuze])
    movietime8 = TinyTag.get(movie8)
    
    # Read states of inputs
    input_state1 = GPIO.input(7)
    input_state2 = GPIO.input(11)
    input_state3 = GPIO.input(13)
    input_state4 = GPIO.input(15)
    input_state5 = GPIO.input(29)
    input_state6 = GPIO.input(31)
    input_state7 = GPIO.input(33)
    input_state8 = GPIO.input(35)

    # check relay time
    now = time.time()
    if now >= stop:
        # turn off all relays
        GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
        GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
        GPIO.output(RELAIS_3_GPIO, GPIO.HIGH)
        GPIO.output(RELAIS_4_GPIO, GPIO.HIGH)
        GPIO.output(RELAIS_5_GPIO, GPIO.HIGH)
        GPIO.output(RELAIS_6_GPIO, GPIO.HIGH)
        GPIO.output(RELAIS_7_GPIO, GPIO.HIGH)
        GPIO.output(RELAIS_8_GPIO, GPIO.HIGH)   
          
    
    if GPIO.input(19) == 0: # check the input switch , 1 = pressed
            os.system('killall omxplayer.bin')
            GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_3_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_4_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_5_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_6_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_7_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_8_GPIO, GPIO.HIGH)  
            player = True
            keuze +=1 # increment counter 'x'  to point at next language
            if keuze > 2: # there are 3 languages available, in the list above, so if counter is greater than 2 (remember first is 0) then start at 0 again
                keuze = 0
            Taal = Talen[keuze]
	    print(Taal)
	    omxc = Popen(['omxplayer', '-o', 'both', '-b', '/var/www/html/audio/' + Talen[keuze] +'.mp4'])
            time.sleep(2) # switch debounce, switches are 'noisy' and you will get multiple triggers so wait a while for these to stop
    
    #If GPIO(7) is shorted to Ground
    if input_state1 != last_state1:
        if (player and not input_state1):
	    os.system('killall omxplayer.bin')
            # turn off all relays
            GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_3_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_4_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_5_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_6_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_7_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_8_GPIO, GPIO.HIGH)
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie1])
	    logging.info(movielog1)
            # turn relay 1 on for video 1
            time.sleep(2)
            GPIO.output(RELAIS_1_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime1.duration
            player = True
    elif not input_state1:
	    os.system('killall omxplayer.bin')
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie1])
	    logging.info(movielog1)
            # turn on relay 1 for video 1
            time.sleep(2)
            GPIO.output(RELAIS_1_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime1.duration
	    player = True
    if GPIO.input(7) == 0:
        time.sleep(5)

    #If GPIO(11) is shorted to Ground
    elif input_state2 != last_state2:
        if (player and not input_state2):
            os.system('killall omxplayer.bin')
            # turn off all relays
            GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_3_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_4_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_5_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_6_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_7_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_8_GPIO, GPIO.HIGH)
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie2])
	    logging.info(movielog2)
            # turn on relay 2 for video 2
            time.sleep(2)
            GPIO.output(RELAIS_2_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime2.duration
            player = True
        elif not input_state2:
	    os.system('killall omxplayer.bin')
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie2])
	    logging.info(movielog2)
            # turn on relay 2 for video 2
            time.sleep(2)
            GPIO.output(RELAIS_2_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime2.duration
            player = True
    if GPIO.input(11) == 0:
        time.sleep(5)
            
    #If GPIO(13) is shorted to Ground
    elif input_state3 != last_state3:
        if (player and not input_state3):
            os.system('killall omxplayer.bin')
            # turn off all relays
            GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_3_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_4_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_5_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_6_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_7_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_8_GPIO, GPIO.HIGH)
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie3])
	    logging.info(movielog3)
            # turn on relay 3 for video 3
            time.sleep(2)
            GPIO.output(RELAIS_3_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime3.duration
            player = True
        elif not input_state3:
	    os.system('killall omxplayer.bin')
            omxc = Popen(['omxplayer', '-o', 'both',  '-b', movie3])
	    logging.info(movielog3)
            # turn on relay 3 for video 3
            time.sleep(2)
            GPIO.output(RELAIS_3_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime3.duration
            player = True  
    if GPIO.input(13) == 0:
        time.sleep(5)         

    #If GPIO(15) is shorted to Ground
    elif input_state4 != last_state4:
        if (player and not input_state4):
            os.system('killall omxplayer.bin')
            # turn off all relays
            GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_3_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_4_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_5_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_6_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_7_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_8_GPIO, GPIO.HIGH)
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie4])
	    logging.info(movielog4)
            # turn on relay 4 for video 4
            time.sleep(2)
            GPIO.output(RELAIS_4_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime4.duration
            player = True
        elif not input_state4:
	    os.system('killall omxplayer.bin')
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie4])
	    logging.info(movielog4)
            # turn on relay 4 for video 4
            time.sleep(2)
            GPIO.output(RELAIS_4_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime4.duration
            player = True
    if GPIO.input(15) == 0:
        time.sleep(5)
            
    #If GPIO(29) is shorted to Ground
    elif input_state5 != last_state5:
        if (player and not input_state5):
            os.system('killall omxplayer.bin')
            # turn off all relays
            GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_3_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_4_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_5_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_6_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_7_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_8_GPIO, GPIO.HIGH)
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie5])
	    logging.info(movielog5)
            # turn on relay 5 for video 5
            time.sleep(2)
            GPIO.output(RELAIS_5_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime5.duration
            player = True
        elif not input_state5:
	    os.system('killall omxplayer.bin')
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie5])
	    logging.info(movielog5)
            # turn on relay 5 for video 5
            time.sleep(2)
            GPIO.output(RELAIS_5_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime5.duration
            player = True 
    if GPIO.input(29) == 0:
        time.sleep(5)          

    #If GPIO(31) is shorted to Ground
    elif input_state6 != last_state6:
        if (player and not input_state6):
            os.system('killall omxplayer.bin')
            # turn off all relays
            GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_3_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_4_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_5_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_6_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_7_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_8_GPIO, GPIO.HIGH)
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie6])
	    logging.info(movielog6)
            # turn on relay 6 for video 6
            time.sleep(2)
            GPIO.output(RELAIS_6_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime6.duration
            player = True
        elif not input_state6:
	    os.system('killall omxplayer.bin')
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie6])
	    logging.info(movielog6)
            # turn on relay 6 for video 6
            time.sleep(2)
            GPIO.output(RELAIS_6_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime6.duration
            player = True  
    if GPIO.input(31) == 0:
        time.sleep(5)  

    #If GPIO(33) is shorted to Ground
    elif input_state7 != last_state7:
        if (player and not input_state7):
            os.system('killall omxplayer.bin')
            # turn off all relays
            GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_3_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_4_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_5_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_6_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_7_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_8_GPIO, GPIO.HIGH)
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie7])
	    logging.info(movielog7)
            # turn on relay 7 for video 7
            time.sleep(2)
            GPIO.output(RELAIS_7_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime7.duration
            player = True
        elif not input_state7:
	    os.system('killall omxplayer.bin')
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie7])
	    logging.info(movielog7)
            # turn on relay 7 for video 7
            time.sleep(2)
            GPIO.output(RELAIS_7_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime7.duration
            player = True 
    if GPIO.input(33) == 0:
        time.sleep(5)
            
    #If GPIO(35) is shorted to Ground
    elif input_state8 != last_state8:
        if (player and not input_state8):
            os.system('killall omxplayer.bin')
            # turn off all relays
            GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_3_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_4_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_5_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_6_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_7_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_8_GPIO, GPIO.HIGH)
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie8])
	    logging.info(movielog8)
            # turn on relay 8 for video 8
            time.sleep(2)
            GPIO.output(RELAIS_8_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime8.duration
            player = True
        elif not input_state8:
	    os.system('killall omxplayer.bin')
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie8])
	    logging.info(movielog8)
            # turn on relay 8 for video 8
            time.sleep(2)
            GPIO.output(RELAIS_8_GPIO, GPIO.LOW)
            # set stop time

pcmanbob
Posts: 10702
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Problem with relais module

Sat Feb 13, 2021 3:41 pm

So the problem with you 3.3V relay board is that the 3.3V pin on the pi gpio header will not supply enough current to run your relay board if that's the way you have it connected.

The reason you probably damaged your first pi is because the 5V relay board uses the IN pins as a ground for the control circuit which is running at 5V, see link below for details of how these boards work.

viewtopic.php?f=91&t=83372&p=1225448#p1225448.

So to get your 5V relay board to work with the pi gpio without damaging it you need an interface circuit between the pi and the relay board , you will also need a separate 5V supply to power the relay board is you have an 8 way relay board.

Example circuit

Image

As for the 3.3v board the links page actually shows them as 5V relays , so I would need to see a picture of the actual board you have showing the information and general layout of the board from above to make sense of what you actually have.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

ghp
Posts: 1757
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Problem with relais module

Sat Feb 13, 2021 3:54 pm

For the first board
I've bought a 5V relais rodule (https://www.hobbyelectronica.nl/product ... anaals-5v/) and when I connected this to my Raspberry I blew up my GPIO pins. I don't what I was doing wrong, because I've connected the VCC to the 5volt and GND to the ground on the Raspbery.
it is pretty clear you have problems when connecting this one jumper VCC to JD-VCC. Then the gpio pins 'see' more than 3.3V.
On the other side when connecting VCC to 3.3V, JD-Vcc to 5V, not clear that the current in the GPIO lines in high enough to enable the relais.

The other board uses relais with coil power given as 0.36W/0.45W. At 3V, the current is min 120mA per relais (even more if the 0.45W apply). When powering the board from RPI 3.3V , then this current is drawn from the Pi internal 3.3V regulator which might be overloaded. With 8 channels used, this is an extra Ampere... Try a separate regulator for the relais board like a LD1117AV33 + capacitors and ensure the 5V supply can provide 1A more then the Pi is needing. As TO220 RthJA is 50°C/W and thermal power is prox (5-3.3)V*1A 1.7W it will receive 20°C degree + 50*1,7=105°C. Pretty hot, so a small heat sink is recommended.

User avatar
edsulst
Posts: 59
Joined: Sat Nov 16, 2019 7:39 am
Location: Goes, The Netherlands

Re: Problem with relais module

Sat Feb 13, 2021 5:18 pm

@pcmanbob

So you reccomend a separate 5V power supply connected to my 5V relay board.
Ok, I'll try that. Is 5.2V and 2A enough ? (Only one relay will be turned on at a time.)


ghp did also mention something about the current, but I'm afraid I don't know what he means.


As for your image:
On the left is the Raspberry and on the right is the relay board.
The interface circuit is in the middle, but is this something I can buy anywhere ?
If so, can you point me in a direction or a product/model number ?

For my Raspberry, I'm using the power supply that was shipped with it. It's 5.2V and 2A.
That should be enough for my Raspberry itself.

// Edwin.

pcmanbob
Posts: 10702
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Problem with relais module

Sat Feb 13, 2021 5:30 pm

Yes the 5.2V 2A power supply will be fine for you relay board,

The interface is a single ULN2803A Darlington driver chip.

You can buy them ready soldered to a PCB but you will still need to solder header pins to the PCB.

Then you need some female - female Dupont cables to connect it all together.

Example board .. https://www.amazon.co.uk/SODIAL-ULN2803 ... 502&sr=8-1

or just the chip on its own .. https://www.amazon.co.uk/Laqiya-ULN2803 ... 618&sr=8-1
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
edsulst
Posts: 59
Joined: Sat Nov 16, 2019 7:39 am
Location: Goes, The Netherlands

Re: Problem with relais module

Sat Feb 13, 2021 5:46 pm

Great pcmanbob,

Thank you for your support.
I've just ordered a pcb from Amazon.

User avatar
edsulst
Posts: 59
Joined: Sat Nov 16, 2019 7:39 am
Location: Goes, The Netherlands

Re: Problem with relais module

Fri Feb 19, 2021 12:02 pm

@pcmanbob

I still have one question about connecting the relay to the Pi.

In your image the GND from the Pi is connected to the GND of the ULN2803A interface and to the GND of the relay module, next to relay 1.
The Vcc of the relay module (next to relay 8) is not connected, correct ?

One end of the external power supply is connected to the GND.
But what about the other end. Do I need to connect this to Vcc or Vcc-JD ?

pcmanbob
Posts: 10702
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Problem with relais module

Fri Feb 19, 2021 12:21 pm

edsulst wrote:
Fri Feb 19, 2021 12:02 pm

In your image the GND from the Pi is connected to the GND of the ULN2803A interface and to the GND of the relay module, next to relay 1.
The Vcc of the relay module (next to relay 8) is not connected, correct ?
Correct you need a common ground between the pi, ULN2803A and the relay board.

regarding Vcc see below
One end of the external power supply is connected to the GND.
But what about the other end. Do I need to connect this to Vcc or Vcc-JD ?
You have two options regarding the positive from the power supply for the relay board ,

1. You can remove the blue jumper from the Vcc & Vcc-JD and connect the positive to both pins,
if you do this then leave the Vcc next to In8 unconnected ( what's shown on the diagram )

2. You can leave the blue jumper in place and connect the positive to the Vcc pin next to the In8 pin.

What ever you do don't connect Vcc or Vcc-JD to the pi gpio header, 5V or 3.3V pins.

The negative or ground from the relay board power supply needs to be connected to the ground pin next to the Vcc & Vcc-JD pins.

Hope this has cleared up any confusion.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
edsulst
Posts: 59
Joined: Sat Nov 16, 2019 7:39 am
Location: Goes, The Netherlands

Re: Problem with relais module

Fri Feb 19, 2021 1:36 pm

Great, now I need how to proceed.
I wasn't sure what to do with the Vcc next to the In8 pin, but now I know I have 2 options to connect the Vcc.

I try to go ahead with the connection in the image, so I need to connect both Vcc and Vcc-JD to the postitive of the external power supply.
(I've tried to connect the Vcc to the 5V of the Pi earlier but I blew up my GPIO pins, so that wasn't a success ;) )

User avatar
edsulst
Posts: 59
Joined: Sat Nov 16, 2019 7:39 am
Location: Goes, The Netherlands

Re: Problem with relais module

Sat Feb 20, 2021 7:43 pm

Well, today I've connected the Pi, circuit board and relay module, but I still have the same problem.

When pressing a button the relay turns on and directy turns off. And then my Pi shuts down.
It doesn't matter if I connect the positive of the external power supply to the Vcc and Vcc-JD or if I connect the jumper between those pins and connect the positive to the Vcc next In8 pin.

I don't know what to do anymore. :?
All the code works fine if I don't connect the power to the relay module.
I have 2 of those modules and both gives me the same problem.

Does anybody have another idea what's going wrong ?

Gr. Edwin.

ghp
Posts: 1757
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Problem with relais module

Sat Feb 20, 2021 8:43 pm

You have a setup we can't see. So some details are needed:
- you mentioned two different relais board. Which one did you use for your setup ?
- do you use an ULN2803 as proposed by pcmanbob ?
- could you provide a sketch of your setup, including pi power supply and external power supply

How is your electronic lab equipment
- do you have some resistors 1k or so and LED, breadboard and patch cables which could be used to detect some voltage levels
- a multimeter ?

Did you solder the setup
- check for 'hidden' shorts
- or did you use patch cables and breadboard which would be perfect for debugging

I assume you have a PI with power supply, relais board with another relais-power-supply (5V?) , a ULN2803 breakout, a LED, 1kResistor, some patch cables and a breadboard. You should be familiar with connecting LED, resistor in right way .

I would propose the following steps:
(1) disconnect everything

(2) basic relais board functionality: connect relais board only to relais-power-supply and connect one input of relais board to its GND. Relais should switch on, when the input is disconnected it should switch off otherwise.

(3) basic Pi function, validate LED and resistor: use a LED, 1k-resistor in series and connect between RPI GPIO pin (one of these you use for the relais ) and PI-GND. When python code switches the GPIO high LED should shine. Pi should continue running, of course.

(4) This is basically a check that the ULN is not broken. Connect ULN2803 to GPIO pins, but connect 1k Resistor and LED on ULN2803 output (low side), other side (high side) to PI 3.3V. Ensure Pi-GND is connected to ULN-GND. When GPIO is switched high the LED should shine.

(5) with setup from 4, remove the Pi 3.3V connection !! (nothing connected to PI 3.3V or pi 5V!!) and connect your relais-power-supply-GND to ULN-GND and the LED high side to relais-power-supply-plus-5-volt. Led should shine a little bit brighter, but easily be controlled by Pi GPIO.

(6) the full chain: remove resistor and LED from (5), connect ULN output to relais board input. Connect relais board GND to ULN-GND which is connected to PI-Gnd. Connect relais-power-supply GND to RELAIS-GND. Connect relais-power-supply+5V(?) to Relais board Vin and only there (!!). Nothing connected to PI 3.3 or Pi 5V (!!)

pcmanbob
Posts: 10702
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Problem with relais module

Sat Feb 20, 2021 9:19 pm

Then the first thing you need to do is post pictures lots of pictures showing how its all connected.

because if you have it all connected correctly then it should work.

I suggest you upload your picture to an image sharing site ( use imgur.com )

then just post links to them in your your post.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
edsulst
Posts: 59
Joined: Sat Nov 16, 2019 7:39 am
Location: Goes, The Netherlands

Re: Problem with relais module

Tue Feb 23, 2021 9:23 am

I don't have the setup at home, but next Sunday I will take photo's.
Also I will connect an LED to the output of the Pi to test if the LED turns on when I press a button.
If possible I will measure the voltage with a multimeter.

You hear from me when I have more information.

Gr. Edwin.

pcmanbob
Posts: 10702
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Problem with relais module

Tue Feb 23, 2021 1:00 pm

If you pi is shutting down evert time you activate a gpio , then it might be prudent to let us look at the pictures before you power the system up again ,

you must have got some thing wrong as a number of users have used the ULN2803A in the circuit shown and its worked without any problems.

We don't want you killing another pi..
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
edsulst
Posts: 59
Joined: Sat Nov 16, 2019 7:39 am
Location: Goes, The Netherlands

Re: Problem with relais module

Tue Feb 23, 2021 1:22 pm

The only time my Pi shuts down is when I activate the GPIO pin to turn on a relay on the module.

Take the snippet below.
When I activate GPIO 7 the omxplayer starts and is playing a movie. This works, so I can control GPIO 7 without any problems.
In the same code all relays are set to HIGH (= turned off) and only RELAIS_1_GPIO (in my code declared as GPIO 12) is set to LOW (= turned on).

As long as I don't connect the relaymodule (Vcc and GND) my code works just fine, but when I connect the power to the relaymodule and activate GPIO 7, the Pi is starting the movie and shutting down after the 2 second delay to activate the relay. I can hear 2 clicks on the relay so it turns on but turns off again because the Pi is shutting down.

As for your question: I will take photo's so you can take a look at how it's connected.

Gr. Edwin.

Code: Select all

#If GPIO(7) is shorted to Ground
    if input_state1 != last_state1:
        if (player and not input_state1):
	    os.system('killall omxplayer.bin')
            # turn off all relays
            GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_3_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_4_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_5_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_6_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_7_GPIO, GPIO.HIGH)
            GPIO.output(RELAIS_8_GPIO, GPIO.HIGH)
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie1])
	    logging.info(movielog1)
            # turn relay 1 on for video 1
            time.sleep(2)
            GPIO.output(RELAIS_1_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime1.duration
            player = True
    elif not input_state1:
	    os.system('killall omxplayer.bin')
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie1])
	    logging.info(movielog1)
            # turn on relay 1 for video 1
            time.sleep(2)
            GPIO.output(RELAIS_1_GPIO, GPIO.LOW)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime1.duration
	    player = True
    if GPIO.input(7) == 0:
        time.sleep(5)

pcmanbob
Posts: 10702
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Problem with relais module

Tue Feb 23, 2021 2:03 pm

If you have it connected correctly using the ULN2803A then setting the gpio pin to high should turn your relay on and setting it to low should turn it off.

So I would say you definitely have some thing connected incorrectly.

it should work like this for example.

Setting gpio pin to high > turns on input 1 on ULN2803A which in turn turns on output 1 on ULN2803A > which makes a ground connection to IN1 on relay board.


So it sounds like you don't have the ULN2803A connected between the pi gpio and the relay board because if you set a gpio pin low and it activates the relay its providing the ground for the IN pin on the relay board via the pi gpio pin.

I would again recommend you don't power the project until we have had time to look at the pictures....

Edit...

So I have draw out just a single circuit for on gpio pin controlling a single relay , not shown any power connections.

Image

Were wires cross and have a black dot they are connected , were they cross with no dot they are not connected.

so gpio 25 connects to 1B, 1C connects to IN1, all grounds are connected together.

You must make sure that the pi, UNL2803A & relay board are either mounted on resting on a no conduction surface or short circuits will be present on the underside of each PCB.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
edsulst
Posts: 59
Joined: Sat Nov 16, 2019 7:39 am
Location: Goes, The Netherlands

Re: Problem with relais module

Sun Feb 28, 2021 1:34 pm

Well, it was an interesting morning.
I first take a lot of photo's of my complete setup and I also made a video to show you when my Pi shuts down.

First my total setup: https://imgur.com/GvKG8ET

Next is my Pi with flatcable to the GPIO Extension board: https://imgur.com/CrqF8y2

Then a closeup of my Extension board: https://imgur.com/MnVzC5l
The first 3 connections on the left and on the right are connected to a set of pins where I can connect my battery module (I think the pcf2127), so the date is set if I don't have an internet connection.

De other connections on the left (cables with numbers 1-9) are for the push buttons.
As you can see I've added an resistor.
The thin cables on the right are female dupont cables that connects to the circuit board between the GPIO pins and the relay module.

This is a photo of the connection of the circuit board: https://imgur.com/cx2RAg6
The dupont cables are connected from the GPIO pin to the "B" connectors on the circuit board.

From the circuit board, the dupont cables are connected to the relay module: https://imgur.com/mJ2EpN2

This is a photo of my pushbuttons: https://imgur.com/dZN8Flu (The lights are not connected. They are just for fun, but don't get connected)

I also have a picture of the power supply for the relay module: https://imgur.com/rvomcQd
As you can see it's a 5.2 - 2A power supply.

That are all of the photo's I've made this morning.


Now, to show you what's happening I've made a video: https://imgur.com/V7TF8sN
I press the top left button and relay 1 turns on. (=GPIO 12)
This is going well a couple of times (I've pressed the butten a couple of times), but at about 43 seconds in the video you can hear two clicks when I press the button and my Pi shuts down. (don't forget to turn up the volume)
No matter how I connect the relay module (VCC next to IN8 or the VDD-JD) it completely shuts down.
Sometimes right after the button press when the relay kicks in and sometimes after a few presses.
I also connected a Diode between the GPIO pin and the circuit board, so the current can't flow back, but this didn't help also.

As a last step I disconnect the power from the relay board and connect an green LED to the GPIO pin (pin 12) and the GND.
I've booted my Pi and press the same button as I did before.
I can press it again and again and every time my LED turns on.
You can see a video of it here: https://imgur.com/x3kMnxx (sorry for the shaking video)

It seems to my that my code is working just fine, because the LED in the last example works.

I really don't know what to do anymore. Perhaps you can give me some hints to try something else.

Oh BTW, I did made some changes to the code since the circuit board between the Pi and relay module switches from LOW to HIGH.
This is my codesnippet for the buttonpress. It's almost the same for all buttons, exept the movie that's playing and the relay that will turn on off course.

Code: Select all

#If GPIO(7) is shorted to Ground
    if input_state1 != last_state1:
        if (player and not input_state1):
	    os.system('killall omxplayer.bin')
            # turn off all relays
            GPIO.output(RELAIS_1_GPIO, GPIO.LOW)
            GPIO.output(RELAIS_2_GPIO, GPIO.LOW)
            GPIO.output(RELAIS_3_GPIO, GPIO.LOW)
            GPIO.output(RELAIS_4_GPIO, GPIO.LOW)
            GPIO.output(RELAIS_5_GPIO, GPIO.LOW)
            GPIO.output(RELAIS_6_GPIO, GPIO.LOW)
            GPIO.output(RELAIS_7_GPIO, GPIO.LOW)
            GPIO.output(RELAIS_8_GPIO, GPIO.LOW)
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie1])
	    logging.info(movielog1)
            # turn relay 1 on for video 1
            time.sleep(2)
            GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime1.duration
            player = True
    elif not input_state1:
	    os.system('killall omxplayer.bin')
            omxc = Popen(['omxplayer', '-o', 'both', '-b', movie1])
	    logging.info(movielog1)
            # turn on relay 1 for video 1
            time.sleep(2)
            GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
            # set stop time in seconds
            #stop = time.time() + 10
	    stop = time.time() + movietime1.duration
	    player = True
    if GPIO.input(7) == 0:
        time.sleep(5)

pcmanbob
Posts: 10702
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Problem with relais module

Sun Feb 28, 2021 2:10 pm

So first question is the pi actually rebooting or is it just the display turning off ? ( does it go through a boot up )

Second question when you suffer the problems what is the read LED doing is it going out or flashing ?

I would suggest you start by breaking the problem down, write a short test program that just turns one relay one for 10 seconds then turns it off,

Code: Select all

import RPi.GPIO as GPIO
import time

GPIO.setwarnings(False)  # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering

# Declare Relays pins
RELAIS_1_GPIO = 12
GPIO.setup(RELAIS_1_GPIO, GPIO.OUT) # GPIO Assign mode

print("turn relay 1 on")
GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
time.sleep(10)
print("turn relay 1 off")
GPIO.output(RELAIS_1_GPIO, GPIO.LOW)
code based on your original posted code.

So if you run the above code assuming it still the correct gpio pin for relay 1 does your pi still exhibit the same problem ?

Also what's the white flat ribbon cable connecting to ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
edsulst
Posts: 59
Joined: Sat Nov 16, 2019 7:39 am
Location: Goes, The Netherlands

Re: Problem with relais module

Sun Feb 28, 2021 2:21 pm

The white cable is an extension cable to connect the sd card to the pi.
Now I can simply disconnect the flatcable and insert it into another Pi.

I will test the code as soon as I can.
The setup isn't at my home so I need to pick it up and set it up here, so I can test things.

pcmanbob
Posts: 10702
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Problem with relais module

Sun Feb 28, 2021 2:49 pm

The white cable is an extension cable to connect the sd card to the pi.
That would probably be a good idea just to eliminate it form causing any problems.

One test you could do that would require no code and should eliminate the code being the problem,

it looks like its the white dupont cable that is controlling relay 1 via the ULN2803A board ,

If this is correct, then disconnect it from the screw terminal and just connect it by hand to a 3.3v terminal ( top left on your extension connector ) so the relay is activated , do you still see the same problem with the pi ?

Edit...

looking again at the ULN2803A connection to the relay board , you appear to have a problem with the connections from the ULN2803A and the relay board you have 8 wires connected but it looks like you have not connection to 8C ?

the connection to com is correct with no connection to it.

Image
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
edsulst
Posts: 59
Joined: Sat Nov 16, 2019 7:39 am
Location: Goes, The Netherlands

Re: Problem with relais module

Sun Feb 28, 2021 7:16 pm

Hi pcmanbob

If I use your suggested code to test the relay on and off, the Pi still shuts down as soon as I run the code from the terminal.
It does not reboot, it completely shuts down.
I hear 2 clicks. The led on the relay turns on and of and the Pi shuts down.

I also removed the flatcable and inserted the SD Card into the Pi.

On the ULN2803A I have 9 connections on the B-side (including GND) and 8 on the C-side.
It's an optical illusion, because 8C really is connected. The COM isn't connected.

If I connect the white dupont cable directly to the 3.3v terminal it stays on.
But it turns on as soon as I boot up the Pi and I cannot turn the relay off and on again, besides disconnecting the white cable.

As soon as I connect the power to the relay board en turn on the Pi and press a button the problem occurs.
When I disconnect the power supply from the relay board, all buttons are working fine. Off course, the relay's don't work without power ;)

ghp
Posts: 1757
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Problem with relais module

Sun Feb 28, 2021 8:41 pm

What is the load switched with this relais ? Possibly it produces voltage/current spikes on mains which are causing the Pi power supply to switch off.
When devices with switching PSU are shut on, you might have quite high inrush current which cause other PSU on same mains to fail.
My proposal is to temporarily use a power bank to power the pi. If system stays stable, then you found the problem.

In the video, it looks as if the monitor attached is shutting down, is it switched by a relais ?

For the tests, I would propose to not use this sd card xtension cable (just to be sure).

pcmanbob
Posts: 10702
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Problem with relais module

Sun Feb 28, 2021 9:26 pm

In your video I can see the display go off, but when it comes back on it does not look like the pi is rebooting , it looks like the display is just turning on.

The test with just moving the white Dupont cable , you need the pi running then just connect the cable to 3.3V does it cause the same problem ,

want I want is the relay to switch without using any software that's why I want you to just connect it by hand .

You say the shuts down but it looks like it starts up again , which is why I said is it rebooting ,

As in shuts down but then starts up again.

Can you post a video of just the monitor showing the whole sequence of the monitor switching of and of it starting back up.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
edsulst
Posts: 59
Joined: Sat Nov 16, 2019 7:39 am
Location: Goes, The Netherlands

Re: Problem with relais module

Sun Feb 28, 2021 9:30 pm

Tomorrow I will use a powerbank for the Pi.
It’s not the monitor that shuts down, it’s the Pi.
On the monitor the “no signal found” is displayed, so there is power to the monitor.

I don’t know how much current the relayboard can handle.
I’ll try to find out tomorrow.

Also I will test the relay cable by connecting and disconnecting the dupont to find out if it shuts down the Pi.

ghp
Posts: 1757
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Problem with relais module

Sun Feb 28, 2021 11:07 pm

You have this code snippet for shutdown
GPIO.setup(37, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.add_event_detect(37,GPIO.RISING,callback=button_shutdown)

I had sporadic problems with false trigger by such code.
Disable this when testing, just to be sure.

Return to “Python”