I used a APC BackUPS Pro 550, which seems to be about the minimum spec I can get away with, on my printer this gives me approximately 5 minutes of print time without power, or 40 minutes of the printer powered but idle, other UPS's would work but APC is the only type tested with these instructions
Test this throughly and make sure you have enough runtime to cool the head before the batteries are exhausted, the only way to do this properly is to set up a test print and pull the power.
Once you have installed the power leads to and from the UPS and got the printer powered through it (not forgetting the Rpi or whatever you have running octoprint also needs power...mine is powered via the printer PSU) You need to install acpupsd, it's in the default repo for raspian so just install it with apt.

sudo apt-get install apcupsd

Now we need to tweak apcupsd's configuration a bit. Edit the apcupsd configuration as follows, you can find it at /etc/apcupsd/apcupsd.conf, just use your favourite editor. Find and change the following lines.

You might need to tweak BATTERYLEVEL and MINUTES for your printer and UPS. this is the percentage of power left before the shutdown will trigger or the minutes of runtime, whichever one happens first
Remember this is minutes as calculated whilst the printer is still running. Once the print is stopped the runtime will be longer as the heaters will be off, so setting 5 minutes here would in my case give me
20 minutes of runtime once the print has aborted for the hot-end to cool
Plug the USB cable from the UPS into a spare port on the Rpi
Now activate the service by editing /etc/default/apcupsd and changing the following line

ISCONFIGURED=yes

Now start the service, it will start by itself on the next boot

sudo service apcupsd start

If all is well typing apcaccess status at the prompt should get you some stats from the UPS, battery level etc If that's all good then apcupsd is configured, now for the script that aborts your print First go into the octoprint settings from the web interface, make sure API access is turned on and record the API key carefully Back on the rpi go to the home directory

cd ~

Now download this custom shutdown script with wget (if so for some reason link below is dead contents of the script are Here)

Don't be tempted to rename the file, leave it as this name Now edit the script and change the variable at the top API_KEY to the API key you got from your copy of octoprint earlier That should be it, the script does 3 things when the power fails and the battery goes below one of the trigger points. it Prints a warning on the printer's LCD screen Records the current printer status and print file position to a file in /home/pi, so that maybe you can work out how to slice the reminder of the model and save the print then it Aborts the print.

Changing the color of filament mid-way through a print
This was a little trickier than I first thought it would be, I read various forums and such to see how others proceeded to change the filament part way through a print and the best method is to insert a specific set of commands into the gcode file. First slice your print then use the preview feature to figure out at what specific layer you'll want to change the filament. Open the gcode file in notepad and use the find function to find that layer change. For this example let's say its 'layer 16' find layer 16 in the gcode file and simply cut and paste the code below into the file just below where the 'Layer 16' starts

When your print arrives at the gcode you inserted it will pause the print, lower the bed 40mm and lock the stepper motors until you resume the print. During this pause the Hot-end and Heated bed will stay on, you need to swap the filament and use the controls on your printer to advance the new filament far enough that your old color is completely gone. Now resume the print taking care to pull any residual filament from the extruder/hot-end. Assuming eveything went correctly it should resume exactly where it paused and start printing the new color of filament.

All of the pictures and information contained within the www.biline.ca website are the property of Jeff Mathurin please do NOT use any of the contents of this website without consent. If you would like to contact me for any reason then feel free to use the contact form by clicking Here