Turn Your 3D Printer On/off Using Octoprint

23,257

79

18

About: Passionate maker

Octoprint is a great solution for controlling your 3D printer. However, it's missing one key function. You can't turn the 3D printer on and off. I often have to run to my basement just to turn the 3D printer on then I give it few minutes to heat up before it can start printing. Well, today I'll show you how you can turn your 3D printer on and off using Octoprint and a relay.

There are multiple ways of doing this. Both for the software and hardware but I'll be showing a very simple solution that is compatible with almost any 3D printer. I've also made a video tutorial which I'd highly suggest watching as well.

https://youtu.be/dQNBeAZpRmk

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Components

I assume you already have your Octoprint set up and running as I won't be covering any of that here. If you don't you can check the official guide here. You'll also need a relay module board. The ones used for Arduino will work just fine. Something like this. I'll be building my own module but that's just because I'm still waiting for the ones I ordered to arrive. If you want to build one yourself too I'd suggest checking out this instructable.

You'll also need a power cord that will be cut but you can use the one your printer came with. Lastly, We'll make a cable connecting the raspberry pi and the relay module.

Before building anything I'd suggest making checking if the relay module will work with 3V3. Power the relay board with 5V and use 3V3 signal to trigger it. You should hear click and the COM and NO pins should be shorted. If nothing happens you need to make a slight modification. It's just a matter of add single resistor. I'd suggest checking this instructable which talks about it in step 6. Once the relay is working you can move on.

Step 2: Cutting the Power

In order to turn the printer on or off we'll be using a relay to control the mains voltage. Since you'll be working with the mains voltage you need to be really careful. I'm not responsible for any injury or damage you may cause.

First, we need the power cord for the 3D printer. It should be the one shown in the picture. It might look slightly different but that's fine. If you have power brick instead they usually have power cord like this as well. Or you can simply follow the instructions and replace the power cord with your DC power cable which is even better.

Make sure the power cord is unplugged from the wall and remove about 5cm / 2inch of insulation about 20cm / 8inch from the end that plugs into the printer. I've used x acto knife to remove the insulation. All of my cuts were very shallow to assure I wouldn't damage any of the wires inside. Simple make a shallow cut and then rip the insulation. After removing the insulation you'll see 3 wires inside. Make sure their insulation is ok if not you'll need to get a new power cord. Cut the brown(black if it's US plug) wire right in the middle and strip both ends.

These two ends need to be screwed in a terminal on the relay board. One must be connected to the common pin(labeled COM) and the other to either the NC or NO pin. NC stands for normally closed and NO for normally open. I've used NC which means the printer is only on when the relay is energized.

Step 3: Connecting Pi

With the power cord hooked up, it's time to connect the raspberry pi. The relay module has 3 pins: 5V, GND, and signal. Intuitively the 5V and GND will be connected to the corresponding pins on the pi while the signal can be connected to any GPIO pin. We'll define the pin in the software later.

You can make your own cable to connect the pi and the relay module like did. An easier solution would be to simply use jumper wires. I would suggest using pins 3,4 and 6 as they are right next to each other yet they provide power and GPIO. I've personally used pins 17,18 and 20 since my relay needs just 3V instead of 5V.

Step 4: Software

Fortunately installing the software is really easy as we'll be using a pre-existing plugin. Open the Octoprint in your browser and log in. Next, click the settings icon and choose the plugin manager on the left-hand side. You'll see a list of plugins but you need to select the get more button on the bottom. Then simply search for PSU. At this point, you should see PSU control plugin submitted by Shawn Bruce. Go ahead and install it. It will take few minutes and afterward you'll be prompted to restart your Octoprint.

After the reboot, the plugin is installed and you'll see lightning bolt icon on the top bar. We are not done yet, few things need to be set up. Go to settings and on the left-hand side select the new PSU control option. Choose switching method to GPIO pin and GPIO mode to BOARD. If you used the pins 3,4 and 6 on your pi as I suggested then for the On/Off GPIO Pin enter 3. If you used any other pins then here you'll select which pin is being used as the signal for the relay. Do NOT enter the number after the GPIO but the number of the pin. For example, if you're using GPIO21 you'll enter 40 because GPIO21 is on pin 40.

The remaining setting can be left at default.

Step 5: Enclosure

We're almost done. Now would be a good time to see if you can control the relay. Leave the power cord unplugged and simply have the relay module connected to the pi. From the web interface turn the power on and off couple of times and you should hear the relay click each time. If not check the wiring and make sure the relay module is working. you can also check if the GPIO pin voltage is changing.

Last but not least is to add cover for the relay module. Don't even think about plugging the power cord in without any sort of cover. There is exposed mains voltage on the board. I have designed this simple enclosure that will house relay module and neatly route the cord. The STL files are available here and also on Thingiverse. If you're building this I'm sure you have a 3D printer so it shouldn't be a problem. Make sure to add zip ties on the cable as I did in the picture. These will act as a strain relief.

Now you can cross you fingers plug the power cord in and hope nothing blows up. If you did everything right you'll be able to turn your 3D on and off with Octoprint. Another first world problem solved. You're welcome :D If you find this useful please check out my youtube channel where I build cool stuff.

1 Person Made This Project!

Recommendations

  • CNC Contest

    CNC Contest
  • Make it Move

    Make it Move
  • Teacher Contest

    Teacher Contest

18 Discussions

0
None
CZREDER

26 days ago

hello, great job ... how transistor is used ? have you circuit map?

0
None
wesley35601

7 months ago

I can't get my Raspberry Pi to turn on and off my Makerbot Replicator 2x. Do you have any suggestions? I've already tried every combination of different pins available and I still have no luck. When I plug the trigger wire into the Pi, it turns my printer off. But the software will not turn it on. When I unplug the cable it does turn back on. I've tried the opposite config on the relay and still had no luck. I believe it's a software problem, any tips?

1 reply
0
None
didiersee

Question 7 months ago

Congratulations and thank you for sharing. Please can i have diagrame with composants values for make module relay. My mail is didiersee@yopmail.com. Thank you from Belgium.

Circuit commande relai.jpg
1
None
KegRaider

10 months ago

Hi Gyro,

You made a typo in your instructable regarding the relay connection.
"One must be connected to the common pin(labeled COM) and the other to either the NC or NO pin. NC stands for normally closed and NO for normally open. I've used NC which means the printer is only on when the relay is energized."

The last sentence should read "I've used NO which means the printer is only on when the relay is energized."

NO - Normally Open: In the relaxed state, the relay switch is open circuit (off), when energized, the circuit is complete and engages the switch.
NC - Normally Closed: In the relaxed state, the relay switch is closed circuit (on), when energized, this disengages the switch and renders the link open circuit.

Other than that, great build. I did the exact thing today with your tips. I did however use an ABS housing with female IEC and GPO outlets, with the relay mounted securely inside the housing with all connections covered with heatshrink tubing. This way, I can use the box later for other project ideas....maybe.

0
None
wolverine969

11 months ago on Introduction

Hi,

can you please let me know what type of relay I require to remotely power my 3d printer. Attached is the adapter specifications.

IMG_0876.jpg
3 replies
0
None
wolverine969wolverine969

Reply 11 months ago

Hi,

Thanks for the feedback. Will the attached device work for me and will I be able to use it to control and led and computer fan?.

I presume that the relay will have its own power supply like a 5v adapter. The rest of the devices will be powered by their own power adapters

8DCD6B42-3981-486B-919A-FBDF1A238C05.png
0
None
_Gyrowolverine969

Reply 11 months ago

yea, that work however the plugin for octoprint only supports one output so I don't know how you'd control them separately.

0
None
_Gyrowolverine969

Reply 11 months ago

If you put the relay on the AC side like shown in the instructions, any relay rated for at least 230V and at least 1A is fine.

0
None
JohnM801

1 year ago

I like this project, but I dont like having it switch the AC or Mains voltage. Would I be able to do the same, but on the DC side of the power supply?

1 reply
0
None
_GyroJohnM801

Reply 1 year ago

It would be possible but you need a separate relay for each voltage and the relay has to be rated for high current because some printer can go easily over 20A on the 12V rail.

0
None
PickleMasterD

1 year ago

Hi

How can I power the Pi with the same power source. Right now it is being powered of the same PSU. I dont want to have to have a spperate cable to power the Pi so I can power the relay on off.

Any help would be appreciated.

THANK YOU!

0
None
timzoet

1 year ago

can you also do it with a USB relay on windows?

0
None
DimitrisGR

1 year ago

I just put my octoprint Raspbery Pi 3 B+ on my AM8 printer and i just cannot get it.
The printer uses an 20Amp psu and several users say that this must be sometime upgrade to 30A, is the relay capable to manage such loads?

3 replies
0
None
_GyroDimitrisGR

Reply 1 year ago

Sure. It's 20A at 12V but this is swithing the mains voltage. If your mains is 220V then the relay has to switch about 1A.

0
None
DimitrisGR_Gyro

Reply 1 year ago

Oh, so amperage is for output that is 12V, so there must be no problem for it.
Guess you use different power suply for octoprint or you use ATX?

0
None
_GyroDimitrisGR

Reply 1 year ago

Yea I have octoprint plugged in separate phone charger.

0
None
Droxz

1 year ago

Nice one and thanks for sharing :)