Skip to content

How to add a one push Moonraker controlled physical power button to your Klipper instance

License

Notifications You must be signed in to change notification settings

3DPrintDemon/BTT-Relay-v1.2-Moonraker_INSTANT_Power-On-Button

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

kofi_s_tag_dark

If you like my work & would like to say thank you & support my efforts please head on over to https://ko-fi.com/3dprintdemon

BTT_Relay_v1.2_Moonraker_Instant_Power_On_Button_for_Klipper

How to add a physical power on button that needs only a single push to re-power your Klipper Printer using the BTT Power Relay v1.2! Normally with this relay in the power off state you need to switch back on the Printer Power GPIO pin then toggle the Reset Power pin. This method below requires only one quick push of a physical momentary button mounted on the printer or enclouser becuase Moonraker will now activate both pins at the same time for you! Magic!

To Use BTT Relay v1.2 As A Moonraker Power Device

To make use of this you must enable your RPI as a secondary MCU so it can control your shutdown relay hardware. Use this link to do that.

After you've followed the process in that link be sure that this is added to your printer.cfg file.

[mcu host]
serial: /tmp/klipper_host_mcu

Word of warning! Adding a power control device like a power shutdown relay can sometimes involve working with & modifying your printer’s wiring that runs on mains level voltage!
 This can be extremely dangerous with a definite risk of serious injury, fire, loss of property & even death! You have been warned. I accept no liability or responsibility for any loss, death or injury caused directly or indirectly by you or anyone else attempting this! This is all on you, attempt implementation ENTIRELY AT YOUR OWN RISK!

Example below for using the BTT Power Relay v1.2

Relay Mounting STL here: https://www.printables.com/model/647656-btt-relay-v12-frame-mount-box-case-4020-bigtreetec

See the install instructions for this product on the BTT Github!

However….

This link is far more helpful!

Then you will need to set your instance to be able to control your Pi’s GPIO pins as mentioned previously in this document. Then you need to choose which 2 GPIO pins on your Rpi to use to control the relay, connect the Printer Power GPIO pin along with a single ground pin to the PSon plug on the relay board. You have to then connect the Pi's Reset Power GPIO pin to the reset pin on the relay board, leave the 5v pin next to it empty.

Then add your physical momentary switch to a 3rd Gpio pin & another ground pin. Then mount it somewhere of your choice on your printer.

Then you need to SSH into your pi & run:

sudo nano /boot/config.txt

Then near the bottom of the file at the end of the first section & in the space BEFORE the start of the [CM4] section paste in:

# Example GPIO pin, choose a GPIO pin to control power device’s PSon pin
gpio=16=op,dh

Then use the commands at the bottom of the screen to exit & save the file.

This will make sure that the GPIO pin you will use for the relay’s PSon pin is automatically pulled “high” when the Pi is first turned on at the beginning of the host boot sequence. This in turn should keep your relay from automatically opening & shutting the printer down while the Pi is booting. It does this at boot because the power relay is not seeing the ‘keep switched on’ signal from the Pi, & it needs that signal. Trust me it is very annoying if you don’t do this!

You will then need to modify your Moonraker.conf file by adding these…

[button PowerUp]
type: gpio
pin: ^gpio21 # Example GPIO pin, you can choose your own here
minimum_event_time: .05
on_press:
  {% do call_method("machine.device_power.post_device", device="Reset Power", action="on") %}
  {% do call_method("machine.device_power.post_device", device="Printer Power", action="on") %}

[power Printer Power]
type:gpio
pin:gpio16 # Example GPIO pin, you can choose your own here
on_when_job_queued: True
initial_state:on
off_when_shutdown: True
locked_while_printing: False
restart_klipper_when_powered: False
# restart_delay: 2
bound_services:

[power Reset Power]
type:gpio
pin:gpio12 # Example GPIO pin, you can choose your own here
on_when_job_queued: True
locked_while_printing: True
initial_state:off
restart_klipper_when_powered: True
restart_delay: 2
Timer:2

You need these two pins as the BTT relay firmware requires a reset command while the PSon pin is high. If this is not the case & the PSon pin is low (off) & you hit reset the relay power up but trip out again after 8 seconds. This is normal. The PSon pin must be high (on) when the reset is pressed. The PowerUp physical button will activate both GPIO pins together when pushed meaning you only need a single push of the physical button to control both pins & re-power the printer instanly.

Lastly to auto shutdown the printer after a print has finished add this to your macros.cfg file & call M81 in your Print_End macro.

[gcode_macro M81]
gcode:
 {action_call_remote_method("set_device_power",device="Printer Power",state="off")}

Extra Bonus...

As an added bonus you can add a second physical button to a 4th GPIO pin to use as a physical Emergency Stop button!

[button estop]
type: gpio
pin: gpio26 # Example GPIO pin, you can choose your own here
on_press:
  {% do call_method("printer.emergency_stop") %}

kofi_s_tag_dark

About

How to add a one push Moonraker controlled physical power button to your Klipper instance

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published