Final changes for the shutoff relay and e-stop
by danlor on Apr.11, 2025, under 3dprinting, Technology
After speaking with BTT, I confirmed that PS-ON(PD14) pin needs to be brought high on power on. This needs to happen before the RPI boots. So I recompiled the main MCU firmware to include this change, and flashed it. I’ll need to retune klipper next so I can make sure the printer cleanly shuts down when triggered.

Additionally, I have wired the E-Stop into pin (!)PF2. This is normally used for the Z endstop (motor 3) but I’m using a virtual endstop through TAP. When pressed the printer executes:
{action_emergency_stop("Emergency Stop Triggered. Shutting down!")}
I’m still working out how best to cleanly shut down the rpi. I’m kind of surprised this isn’t already built in. Here are my power macros
[gcode_button ESTOP_BUTTON]
pin: !M3_z_diag
press_gcode:
{action_emergency_stop("Emergency Stop Triggered. Shutting down!")}
[gcode_macro POWER_ON]
description: Turn on the printer via the relay
gcode:
{ action_respond_info('Switching Relay ON') }
SET_PIN PIN=power VALUE=1
[gcode_macro POWER_OFF]
description: Turn off the printer via the relay
gcode:
{ action_respond_info('Switching Relay OFF') }
SET_PIN PIN=power VALUE=0
[delayed_gcode shutdown_machine]
gcode:
POWER_OFF
{action_call_remote_method("shutdown_machine")}
initial_duration: 0.0
Then Run
UPDATE_DELAYED_GCODE ID=shutdown_machine DURATION=1
When I want to power off the printer. Initial tests have gone well.
This requires the installation of a community module “G-Code Shell Command” through KIAUH