BTT Power Relay Integration
by danlor on Apr.04, 2025, under 3dprinting, Technology
Last night, I wired in the relay and immediately encountered a Catch-22 I hadn’t anticipated. The relay relies on a dead man’s switch signal from the MCU. However, the Raspberry Pi must set the signal high, and it takes longer to boot than the relay’s timeout period allows.
Complicating matters, I’m using an integrated MCU/Pi board without a dedicated power connection for the Raspberry Pi. As a result, cutting power to the 24V PSU shuts down the entire system, including the Pi.
I have asked BTT about this, and I’ll see what they come back with.
As an interim solution, I have wired the relay to cut power only to the SSR. I configured Klipper to assert PS-ON (pin PD14) at boot, which keeps the relay open after pressing the reset button. I’m still considering whether I want to enable this programmatically. For now, I simply press a green button when starting a print.
[output_pin power]
pin: PD14
value: 1
shutdown_value: 0
[gcode_macro POWER_ON]
description: Turn on the printer via the relay
gcode:
{ action_respond_info('Switching ON SSR Power') }
SET_PIN PIN=power VALUE=1
[gcode_macro POWER_OFF]
description: Turn off the printer via the relay
gcode:
{ action_respond_info('Switching OFF SSR Power') }
SET_PIN PIN=power VALUE=0
I have added the POWER_ON and POWER_OFF macros to PRINT_START and PRINT_END. I’m not sure if I want to override the SHUTDOWN_HEATERS macro to simplify things.
