Adding relay to the router

I know this topic has come up before and my head is starting to hurt from reading…

I am using a mini-rambo board.

I currently have the board in an enclosure. I’ve added start Gcode that sends a M106 P0 command at the start of a print to turn on the fans on the enclosure.

I’d like to take advantage of the M3 command to turn on a relay and start the spindle/router.

Can someone point me in the right direction for this? I’m assuming there’s something I’d have to do in Marlin to fix this. The mini-rambo has a second fan port I’m assuming I could use to implement this.

It is easier if you are just concerned with on/off. If you search for “arduino relay” on amazon, you’ll find a lot of choices that can be triggered by 5V. You need one with a big rating on the VAC. Alternatively, the IOT Relay on amazon has nice plugs, and takes almost any input to turn it on/off. It looks like it is “currently unavailable” though…

In the software, it’s already set to pin 18:

That looks like it’s used for the LCD though, so unless you have that turned off, I think we need to change it.

There is a P3 expansion port, with nothing on it.

The third pin on P3 is arduino pin 13, if I’m reading this right, so that might be a good candidate. I do not know if any of the P3 pins are PWM capable, but if you’re hoping to speed control or dimming control, then we might have to look a little harder to find a good candidate.

I’m really only looking to do on/off. This is just to power the dewalt 660 on/off as needed. I’m using CNC.js, so every time I run the machine right now I have to hit resume on both cnc.js and on the LCD.

Oh… and I am using the LCD. Not sure why at this point. I do all my work from CNC.js.

Thanks for pointing me in that direction. If I get some time, I’ll try compiling the firmware and installing it. I don’t think I left an easy way to get a USB cable into the controller box I designed. Hindsight :roll_eyes: I’ll hook up the multimeter and run a test job to see if it goes high.

I figured pretty much any relay should work. I think all of mine are only 5 amp, though.

I wouldn’t mess with any of those pins unless you disable the LCD in the firmware. You wouldn’t want to be milling, and having Marlin decide it wants to adjust the LCD brightness and turn off your spindle, or power cycle the relay at 8kHz. I think if you turn off the LCD, the pause acts differently and only need cncjs to resume, but I’m not 100%.

You should be able to use that other fan port too, with M106 P1 S255. But it also might be configured to do something else in your current firmware, like a case fan which comes on when the motors are enabled, or an extruder fan that comes on when the hot end temp is over 50C.

Since you have a pi attached to the USB, you can install the firmware updater plugin in Marlin, and then install avrdude through ssh. You can then use arduino to compile a .hex file, and then use octoprint to flash the .hex onto the rambo. It is a bit of a pain to set up, but the really nice thing is, you can save that .hex file and use it again if you want to revert, or have more than one configuration. Plus, you don’t have to unplug anything…

For that matter, I can install avrdude onto the pi and just run the command manually to flash the hex. I don’t have Octoprint on this Pi. Just cnc.js.

I like the idea of using the P3 pin and I’ll try to go down that route.

1 Like

I bought this:

Solid state relay

Says it works on as low as 3V, will have to test it out, someone mentioned current draw might be an issue. Not sure if I want to use the mini rambo and have m3 involved or just a button on the raspberry pi. My plan is to control an entire power bar at once.


I’m using a similar one to that as a relay for my dust collector controlled by a pi zero.

You might want to get a good heatsink for it.

Open Builds has it for sale:

1 Like

Saw that a while ago, neat, but too big for me, also $15 with free amazon shipping vs $4x + who knows shipping in $cdn. :slight_smile:

Heatsink, maybe, it’s rated 20A and I have a 10A fuse at the switch so as long as it’s less than 10A shouldn’t heat up that much.


1 Like

I like that one because it is so self contained. No AC wires exposed.

You mean you can’t 3d print a case :smile:

I know myself too well. I wire it up in a hacky way, just to “make sure it works” and then when it works, I don’t go back and make it safe.

1 Like

You really need to work on your OCD.

1 Like

Don’t forget SSRs fail closed(on).