DEV Community

Cover image for Enable Buzzer in Klipper For Creality Boards 4.2.2 4.2.7
WallClocks
WallClocks

Posted on

Enable Buzzer in Klipper For Creality Boards 4.2.2 4.2.7

creality_board_screenshot
I have an Ender 3 with a 4.2.7 Board running Klipper firmware and wanted to enable the Buzzer. After some looking around I found the sample-macros.cfg and PDF schematics for both 4.2.2 and 4.2.7. Using these two things I was able to make the M300 gcode command trigger the Buzzer in the LCD panel.

######################################################################
# Beeper
######################################################################
# M300 : Play tone. Beeper support, as commonly found on usual LCD
# displays (i.e. RepRapDiscount 2004 Smart Controller, RepRapDiscount
# 12864 Full Graphic). This defines a custom I/O pin and a custom
# GCODE macro.  Usage:
#   M300 [P<ms>] [S<Hz>]
#   P is the tone duration, S the tone frequency.
# The frequency won't be pitch perfect.
[output_pin BEEPER_pin]
pin: PC6
#   Beeper pin. This parameter must be provided.
#   ar37 is the default RAMPS/MKS pin.
pwm: True
#   A piezo beeper needs a PWM signal, a DC buzzer doesn't.
value: 0
#   Silent at power on, set to 1 if active low.
shutdown_value: 0
#   Disable at emergency shutdown (no PWM would be available anyway).
cycle_time: 0.001
#   Default PWM frequency : 0.001 = 1ms will give a tone of 1kHz
#   Although not pitch perfect.
[gcode_macro M300]
gcode:
    # Use a default 1kHz tone if S is omitted.
    {% set S = params.S|default(1000)|int %}
    # Use a 10ms duration is P is omitted.
    {% set P = params.P|default(100)|int %}
    SET_PIN PIN=BEEPER_pin VALUE=0.5 CYCLE_TIME={ 1.0/S if S > 0 else 1 }
    G4 P{P}
    SET_PIN PIN=BEEPER_pin VALUE=0
Enter fullscreen mode Exit fullscreen mode

To check that it is working, send M300 S440 P200 to your printer and it should beep. You can learn more here.

The only thing you need to change from the sample-macros.cfg section is the pin. Under [output_pin BEEPER_pin] you set pin:PC6. That is it.
Seems simple but I couldn't find anything online about it so I thought I would share. Hope this helps someone or me in the future at least.

Top comments (2)

Collapse
 
kevinkhill profile image
Kevin Hill

PC6 did not work for me.

Following the schematic and traces, I had success with PB13 that leads to Beep on the LCD Port.

I can only get a singular tone from it though. It doesn't seem to be doing pwm correctly, or the beeper cannot do pwm at all.

Collapse
 
devilxxmaster profile image
devilxxmaster

Thanks!!!

Era justo lo que estaba buscando. Me he registrado porque te tenia que dar las gracias SI o SI. :)

It was just what I was looking for. I have registered because I had to thank you YES or YES. :)