I do a lot of printing that ends up finishing the job in the wee hours of the morning, and wanted to have a way the printer would shut down after finishing the print. Browsing the Duet3D Gcode rference, I found that codes M80 and M81 control the external PS port, and that by using that signal abd a couple of relays and a small 5 volt power supply I could get the printer to shut down automatically.
I used a 5 volt relay board, with the input connected to the PS_ON pin and the ground connected to the GND pin. The 5 volt power supply supplies 5 volts to the relay board. The jumper on the relay board is set to trigger when the PS_ON pin goes low.
I used an adjustable delay board to power the printer up until the PS_ON signal goes high and activates the signal relay.
The line (L - hot) power wire is connected to the 5 volt power supply and the common poles on both relays. The NC (normally closed ) relay terminal on the delay relay and the NO (normally open) relay terminal on the signal relay are then connected to the line (L) terminal on the printer PSU. The neutral power line is connected to the neutral (N) terminal on the 5 volt power supply and the neutral (N) terminal on the printer PSU.
I set the delay relay to remain closed for 5 seconds, and then open, as the signal relay will have closed and sent line current to the NO terminal and on to the printer PSU.
You will need to put an M80 command in the config.g file on the SD card so the PS_ON pin goes high, otherwise, after the delay relay opens, the printer will shut down again.
To shut the printer down after finishing a print, simply put an M81 S1 command either at the end of the gcode file or in S3D in the ending script. The S1 parameter delays the shutdown until all cooling fans have turned off, letting the hot end cool off properly.
The 5 volt power supply remains powered up to keep the delay relay from sending power to the printer PSU. You will need to cut the power and then reapply power to get the printer to power up again, unless you install the optional override switch.
I have my printer in the basement, so I have it plugged into a remote control power socket, so I can power it up or down from my desk.
Attached are a circuit diagram, pictures of the finished unit and the stl files for the case and lid.
Link to delay module: https://www.amazon.com/gp/product/B07H5D3R3M/ref=ppx_yo_dt_b_asin_title_o04_s00?ie=UTF8&psc=1
Link to signal relay: https://www.amazon.com/gp/product/B07QGT6RGX/ref=ppx_yo_dt_b_asin_title_o05_s01?ie=UTF8&psc=1
Link to 5 volt power supply: https://www.amazon.com/gp/product/B07CBS768L/ref=ppx_yo_dt_b_asin_title_o07_s01?ie=UTF8&psc=1
Link to fused power cord receptacle: https://www.amazon.com/gp/product/B082ZFRV1B/ref=ppx_yo_dt_b_asin_title_o05_s00?ie=UTF8&psc=1