OctoPrint is the first piece of software that comes to mind in the topic of 3D printing interfaces, primarily known for being extremely user-friendly to install and operate, even for users who don’t consider themselves technically knowledgeable.
On the other hand, even though it’s pretty simple to use, OctoPrint is also possibly the most feature-packed 3D printing interface available right now, especially with the vast amount of community-made plugins that augment it in various ways.
In today’s article, we will be leaning more towards the fun side of things, where we will learn how to control a LED light strip with the OctoPrint software to spice up the 3D printing process with some colored lights that will make the whole thing more aesthetically pleasing.
So, how to control a LED strip with OctoPrint?
It’s possible to control a LED strip with OctoPrint by using the OctoPrint GPIO RGB Controller plugin, which requires you to connect the LED strip to the Raspberry Pi through the GPIO interface.
The GPIO RGB Controller plugin adds a color picker to the OctoPrint dashboard, allowing you to control your LED strip through a graphical interface.
Next up, we will discuss the process of controlling a LED strip with OctoPrint in more detail, find out how to use G-code commands to control the LED strip, and finally, look at the practical use-case of tracking the printing progress with a LED strip.
How to Control a LED Strip with OctoPrint?
While there are plenty of different ways to control a LED strip wired to a Raspberry Pi, doing so with OctoPrint is a fantastic way to integrate the LED lights into the 3D printing process and make the process of controlling the lights a lot more convenient.
Below, we have prepared a step-by-step guide you can follow to control a LED strip with OctoPrint, which involves all the steps required to get the LED strip up and running from scratch.
- Download and install the OctoPrint-GpioRgbController plugin. While the most convenient way to install an OctoPrint plugin is to search for the plugin in the built-in repository browser, you can also copy the URL we have provided into OctoPrint’s Plugin Manager.
- Wire the LED strip to the Raspberry Pi. If you aren’t familiar with wiring a LED strip to the Raspberry Pi’s GPIO interface, we recommend following this diagram that is pretty self-explanatory.
- Navigate to OctoPrint Settings, and select the GPIO RGB Controller tab from the left pane. This action should bring up the settings for the GPIO RGB Controller plugin, which will allow us to perform the necessary configuration for the plugin to work.
- Input the appropriate pin numbers for red, green, and blue according to the wiring. If you have used the diagram we have provided for the wiring process – the pin numbers should be 20, 25, and 5 for red, green, and blue, respectively. On the other hand, if you are unsure about the pin numbers you have used, you can refer to this diagram that shows all the GPIO pins of the Pi.
- Navigate back to the OctoPrint dashboard. You should notice the GPIO RGB Controller section in the sidebar, which features a color picker and two buttons for turning the LED strip on and off.
- Choose the color you would like to assign to your LED strip from the color picker. Whenever you make a modification in the color picker, the LED strip should react to this change and switch colors.
After completing all of these steps, you can control the LED strip through the color picker without any issues whenever you wish to, provided that you don’t change the wiring or the settings.
How to Use G-Code Commands to Control a LED Strip with OctoPrint?
Aside from controlling the LED strip directly through the OctoPrint interface, it’s also possible to use G-code to trigger changes in the color and the intensity of the LED lights, which is a handy feature for programmatically controlling the LED strip throughout the printing process.
To control a LED strip with OctoPrint by using G-code commands, you can follow the step-by-step guide below:
- Set the OctoPrint-GpioRgbController plugin up. Skip this step if you have previously configured the plugin, or refer to the previous section for a guide to setting the plugin up from the start to the end.
- Navigate to the OctoPrint settings, and select the GPIO RGB Controller tab.
- Check the Enable M150 command box under the GCODE Commands section.
This process will allow the M150 (Set RGB Color) G-code to communicate with the LED strip you have connected to OctoPrint via the Raspberry Pi, meaning that the LED strip will change color whenever you issue the M150 G-code to the printer.
If you are unsure how to send G-code commands to the printer, here are some methods you can use:
- Use the GCodeBar plugin for OctoPrint. Installing this plugin adds an input to the OctoPrint sidebar that allows you to issue G-code commands to the printer directly, which you can use to execute the M150 command.
- Use Repetier-Host. Repetier offers a manual control section, making it possible to send G-code to the 3D printer directly.
- Use the gcode-sender Chrome plugin.
- Save the G-Code to an SD card and transfer it to the printer.
Using a LED Strip and OctoPrint to Track Progress
A fun and practical use case for controlling a LED strip with OctoPrint is tracking the progress of the 3D printing process, where you can assign distinct colors to parts of the entire G-code to have a rough idea of how long the print will take.
In a nutshell, the idea here is to insert M150 G-code commands with different color codes to various sections of the G-code file you have obtained from the slicer software, which will trigger a LED color change whenever the printer reaches those sections.
Since slicer software allows you to simulate each line of the G-code file it produces, you can choose the sections you would like to use as checkpoints for color changes, which will allow you to have a decent estimate of the print progress through the color changes.
While controlling a LED strip with OctoPrint doesn’t directly benefit the 3D printing process, it’s a convenient way to use LED lights to improve the user-experience side of things and have some fun by making your 3D printing station look more visually appealing.
To quickly recap, you can control your LED strip with OctoPrint by installing the OctoPrint GPIO RGB Controller plugin, which adds a color picker interface to the Control tab of your OctoPrint dashboard.
On that note, it’s vital to remember that for the GPIO RGB Controller plugin to work – you will need to connect the LED strip to the Raspberry Pi through the GPIO interface.