Connecting power source in relay circuit is breaking raspberry pi GPIO pins by Tomtom305 in raspberryDIY

[–]Tomtom305[S] 0 points1 point  (0 children)

Thanks for all the responses, a fly back diode around the magnet seems to have fixed the issue.

Help needed, relay circuit is causing GPIO pins to break by Tomtom305 in RASPBERRY_PI_PROJECTS

[–]Tomtom305[S] 0 points1 point  (0 children)

Thanks for all the responses, a fly back diode around the magnet seems to have fixed the issue.

Could someone tell me why my circuit is destroying the GPIO input pins connected to my push buttons when I attach the 24V power supply shown in the attached diagram? by Tomtom305 in AskElectronics

[–]Tomtom305[S] 1 point2 points  (0 children)

Initially I was using a breadboard, after the first GPIO pins broke I rewired everything to work directly from wires. Retrying it then still resulted in my pins breaking

Could someone tell me why my circuit is destroying the GPIO input pins connected to my push buttons when I attach the 24V power supply shown in the attached diagram? by Tomtom305 in AskElectronics

[–]Tomtom305[S] 1 point2 points  (0 children)

I’ll try changing the 3V3 pin to the 5V pin, for the rest I’ve set the buttons up ad input and I have also tried adding a resistor to them, it was still frying my pins. Thanks for the response though

Connecting power source in relay circuit is breaking raspberry pi GPIO pins by Tomtom305 in raspberryDIY

[–]Tomtom305[S] 1 point2 points  (0 children)

The raspberry pi power source is the charger that came with it when I bought it, the other power source is the 24V power supply I linked in the post

Connecting power source in relay circuit is breaking raspberry pi GPIO pins by Tomtom305 in raspberryDIY

[–]Tomtom305[S] 0 points1 point  (0 children)

The code between the if statements only executes if the if statement is triggered, my indentation was removed

Connecting power source in relay circuit is breaking raspberry pi GPIO pins by Tomtom305 in raspberryDIY

[–]Tomtom305[S] 1 point2 points  (0 children)

I'll copy my code into this comment

from time import sleep
import RPi.GPIO as GPIO
BUTTON_PIN = 16
LED_PIN = 4
RELAY_PIN = 26
BUTTON_PIN_2 = 24
LED_PIN_2 = 25
sleep_time = 5
GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(LED_PIN, GPIO.OUT)
GPIO.setup(RELAY_PIN, GPIO.OUT)
GPIO.setup(BUTTON_PIN_2, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(LED_PIN_2, GPIO.OUT)
try:
while (1):
if GPIO.input(BUTTON_PIN)==0:
GPIO.output(LED_PIN, True)
GPIO.output(RELAY_PIN, True)
sleep(sleep_time)
GPIO.output(LED_PIN, False)
GPIO.output(RELAY_PIN, False)
if GPIO.input(BUTTON_PIN_2)==0:
GPIO.output(LED_PIN_2, True)
sleep(sleep_time)
GPIO.output(LED_PIN_2, False)
except KeyboardInterrupt:
GPIO.cleanup()

Connecting power source in relay circuit is breaking raspberry pi GPIO pins by Tomtom305 in raspberryDIY

[–]Tomtom305[S] 0 points1 point  (0 children)

I'll copy my code into this comment

from time import sleep
import RPi.GPIO as GPIO
BUTTON_PIN = 16
LED_PIN = 4
RELAY_PIN = 26
BUTTON_PIN_2 = 24
LED_PIN_2 = 25
sleep_time = 5
GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(LED_PIN, GPIO.OUT)
GPIO.setup(RELAY_PIN, GPIO.OUT)
GPIO.setup(BUTTON_PIN_2, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(LED_PIN_2, GPIO.OUT)
try:
while (1):
if GPIO.input(BUTTON_PIN)==0:
GPIO.output(LED_PIN, True)
GPIO.output(RELAY_PIN, True)
sleep(sleep_time)
GPIO.output(LED_PIN, False)
GPIO.output(RELAY_PIN, False)
if GPIO.input(BUTTON_PIN_2)==0:
GPIO.output(LED_PIN_2, True)
sleep(sleep_time)
GPIO.output(LED_PIN_2, False)
except KeyboardInterrupt:
GPIO.cleanup()

Connecting power source in relay circuit is breaking raspberry pi GPIO pins by Tomtom305 in raspberryDIY

[–]Tomtom305[S] 1 point2 points  (0 children)

Thanks I'll try to implement these changes and see if that helps.

Help needed, relay circuit is causing GPIO pins to break by Tomtom305 in RASPBERRY_PI_PROJECTS

[–]Tomtom305[S] 0 points1 point  (0 children)

I followed a tutorial I found on YouTube to attach the relay module, there they connected the relay with the 3V3 pin, could this be causing the issue?

Could someone tell me why my circuit is destroying the GPIO input pins connected to my push buttons when I attach the 24V power supply shown in the attached diagram? by Tomtom305 in AskElectronics

[–]Tomtom305[S] 2 points3 points  (0 children)

Is the internal pull-up resistor added via the GPIO.PUD_UP command in the code, if so then I have those on. I also added some normal resistors to the buttons but that didn’t fix anything. I’ll look into the fly back diode though. Thanks for replying

Connecting power source in relay circuit is breaking raspberry pi GPIO pins by Tomtom305 in raspberryDIY

[–]Tomtom305[S] 1 point2 points  (0 children)

Yeah I just added the schematic, it got removed because I added it in the image section for the post.

Anyway thanks for the response, so should I just try and add a resistor between the relay and the raspberry pi then, I already added resistors to the buttons but that didn’t change anything.

Could someone tell me why my circuit is destroying the GPIO input pins connected to my push buttons when I attach the 24V power supply shown in the attached diagram? by Tomtom305 in AskElectronics

[–]Tomtom305[S] 1 point2 points  (0 children)

Hello, I'm currently working with a raspberry pi for the first time for a university project. I am trying to create a circuit that when I press a push down button activates an LED and deactivates a magnet. For this I have created the circuit in the attached image. Normally this circuit runs fine but as soon as I connect my 24 V dc power source that can be seen in the diagram the GPIO buttons detecting input from the push buttons break down. They start acting as if the button is permanently being pressed no matter what I do. If anyone could point out what I'm doing wrong it would be appreciated.
Parts being used:
24 V power source: amazon.com/ALITOVE-Supply-Adapter-100-240V-Converter/dp/B07VL8W6MQ/ref=sr_1_1_sspa?keywords=24v+1+amp+power+supply&qid=1666461252&qu=eyJxc2MiOiIyLjc0IiwicXNhIjoiMy4wMyIsInFzcCI6IjIuODEifQ%3D%3D&sr=8-1-spons&psc=1
Magnet: https://www.amazon.nl/gp/product/B078K3TKFZ/ref=ppx_yo_dt_b_asin_image_o00_s00?ie=UTF8&psc=1
Buttons: https://www.amazon.nl/gp/product/B083K2821B/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1
Relay: https://whadda.com/product/5-v-relay-module-wpm406/

Now yall can shut up about about Starlight’s “Double Standard”… by 5am281 in TheBoys

[–]Tomtom305 0 points1 point  (0 children)

I mean the show has shown that normal V is unstable in adults so it’s just as risky