What is the problem?
I want to turn light on my printer with octoprint. I use skr mini 3.0
What did you already try to solve it?
I was using chatgpt for solution. And here it is but need to check with you if this is ok?
Hardware Setup: Controlling a 12V LED via GPIO and MOSFET
Components Needed:
12V LED light (2-wire: + and –)
N-channel MOSFET (e.g. IRLZ44N, IRFZ44N, IRF520)
220Ω resistor (between GPIO and MOSFET gate)
10kΩ resistor (pull-down between gate and GND)
Free GPIO pin on SKR Mini E3 V3.0 (e.g. PA7)
12V power source (can be shared with printer PSU)
Wiring Diagram (Textual Description):
+12V → directly to the positive wire of the LED
Negative wire of the LED → to Drain of the MOSFET
Source of the MOSFET → to GND
Gate of the MOSFET → to GPIO pin (e.g. PA7) via 220Ω resistor
10kΩ resistor between Gate and GND (prevents floating gate)
This setup allows the GPIO pin to act as a switch: when the pin goes HIGH, the MOSFET conducts and completes the circuit, turning on the LED.
Marlin Firmware Configuration
In Configuration.h:
C++
#define CASE_LIGHT_PIN PA7
#define CASE_LIGHT_DEFAULT_ON false
// Optional: Enable M42 command support
#define DIRECT_PIN_CONTROL
In Configuration_adv.h:
C++
#define CASE_LIGHT_USE_NEOPIXEL false
#define CASE_LIGHT_MAX_BRIGHTNESS 255
This configures the LED as a case light and allows control via G-code or OctoPrint.
OctoPrint Custom Control Setup
Add this to your config.yaml under controls:
YAML
controls:
- name: LED Light
type: section
children:- name: Turn On
type: command
command: M42 P7 S255 - name: Turn Off
type: command
command: M42 P7 S0
- name: Turn On
Note: P7 refers to pin number 7, which corresponds to PA7. If you're using a different GPIO pin, adjust the number accordingly.
This will add buttons in OctoPrint’s control tab to toggle the LED on and off.