Notifications
Clear all

Is my GPIO set-up correct?  

  RSS
VJ
 VJ
(@vj)
Active Member
Is my GPIO set-up correct?

Hello,

I'd like to use my GPIO to turn on some Fans. I got a relay module like this one to power on the fans. I'm using the GPIO Pin1 as an output to activate the relay's IN1 side with the GPIO GND connected to the relay's DC- side. but it doesn't seem to work. What am I doing wrong? I attached a picture of the wiring diagram I made.

Regards

Best Answer by Sembazuru:

Unfortunately, you are using your relay wrong. The link you provided has 3 variants, a 24V, a 12V, and a 5V. Which is yours? For the rest of this message I'll assume you have the 24V module. These modules aren't just relays, but have an active circuit between the relay coil and the control input screw terminals. This active circuit needs to be powered. The GPIO can't provide enough voltage for any of the 3 modules (the 5V might work, but will be marginal). Here is the hookup diagram from the Amazon product listing:

You are missing the connection to the DC+ on the right side of the picture. If you are using the 24V module variant, I'd connect the +24V from the printer also to the +DC to power the trigger/coil side. The pin1 output of the GPIO is an "open drain" type output. This means that when OFF the output is floating and can't provide power and when ON it is pulled to ground, or low. You need to set the jumper on the relay module to "Low Trigger". You also need to provide your own pull-up to a positive voltage to enforce a high signal when the output is OFF. I haven't done the math for what pullup resistor would be ideal, but I suspect a 100k resistor would be sufficient (this is based on my habit of using 10k pull-up resistors for 5v and 3.3v logic, 24v logic is a magnitude of order more voltage so I'd increase the pull-up by a magnitude of order). I would put this resistor between the DC+ and IN terminals on the relay module.

Here is your schematic with my redlines.

Remember to double and triple check your wiring before providing power. There are no "oopsie" protections on the GPIO board so there is always the risk of damaging anything (GPIO, Printer, other attached electronics) from connecting things incorrectly.

Posted : 05/03/2025 3:04 pm
Sembazuru
(@sembazuru)
Prominent Member
RE: Is my GPIO set-up correct?

Unfortunately, you are using your relay wrong. The link you provided has 3 variants, a 24V, a 12V, and a 5V. Which is yours? For the rest of this message I'll assume you have the 24V module. These modules aren't just relays, but have an active circuit between the relay coil and the control input screw terminals. This active circuit needs to be powered. The GPIO can't provide enough voltage for any of the 3 modules (the 5V might work, but will be marginal). Here is the hookup diagram from the Amazon product listing:

You are missing the connection to the DC+ on the right side of the picture. If you are using the 24V module variant, I'd connect the +24V from the printer also to the +DC to power the trigger/coil side. The pin1 output of the GPIO is an "open drain" type output. This means that when OFF the output is floating and can't provide power and when ON it is pulled to ground, or low. You need to set the jumper on the relay module to "Low Trigger". You also need to provide your own pull-up to a positive voltage to enforce a high signal when the output is OFF. I haven't done the math for what pullup resistor would be ideal, but I suspect a 100k resistor would be sufficient (this is based on my habit of using 10k pull-up resistors for 5v and 3.3v logic, 24v logic is a magnitude of order more voltage so I'd increase the pull-up by a magnitude of order). I would put this resistor between the DC+ and IN terminals on the relay module.

Here is your schematic with my redlines.

Remember to double and triple check your wiring before providing power. There are no "oopsie" protections on the GPIO board so there is always the risk of damaging anything (GPIO, Printer, other attached electronics) from connecting things incorrectly.

See my (limited) designs on:
Printables - https://www.printables.com/@Sembazuru
Thingiverse - https://www.thingiverse.com/Sembazuru/designs

Posted : 06/03/2025 3:39 pm
VJ liked
VJ
 VJ
(@vj)
Active Member
Topic starter answered:
RE: Is my GPIO set-up correct?

Oh great, thanks for the help! I did get a 24V model.

Just to make sure I got it right; add a 100k resistor, plug that in between the IN1 and DC+ while keeping everything the same, plus adding the power from the PSU/printer's 24V+ to the DC+ side of the relay module, as well as setting the Low Trigger on the module. Is that correct?

Thanks again!

Posted : 06/03/2025 11:46 pm
LarGriff liked
Sembazuru
(@sembazuru)
Prominent Member
RE: Is my GPIO set-up correct?

Yes, that looks good. Good on you to repeat my instructions in your words to make sure you understood.

See my (limited) designs on:
Printables - https://www.printables.com/@Sembazuru
Thingiverse - https://www.thingiverse.com/Sembazuru/designs

Posted : 07/03/2025 3:06 am
VJ liked
VJ
 VJ
(@vj)
Active Member
Topic starter answered:
RE: Is my GPIO set-up correct?

So your suggestion (and updating the firmware, which I'd forgot to do, oops) worked like a charm, the fans came on at the start of the print as per the G-code. However, after the first test print, the fans won't turn off even when the print is finished. Now they stay on all the time even after turning the power off and back on. Any Ideas? It's not a big deal as I usually turn off the power to the printer when not in use, but it would be nice for the fans to turn themselves off and the end of the print rather than staying on all the time.

I did add the M265 line in the end G-code just after M107 in prusasclicer to flip the fan status as per the GPIO Docs.

 

Posted : 13/03/2025 5:45 pm
Share: