Last week the ‘pick a hobby’ part of my brain returned to 3d printing. I’ve had a 3d printer for about 6 years now and every few months I’ll decide I want to use it to print…something. So I’ll fire it up, then realise that actually it would be so much better with some additional bits. A new hotend. New Mains powered heated bed. Enclosure. Closed loop steppers, auto power-on…. the list goes on. Then I’ll print one thing and turn it off for the next few months.
Anyway, Last week I decided to get interested in multi-coloured printing. I had one of those amazing strokes of luck on ebay and picked up a ‘mosaic palette pro 2’, a piece of kit which still sells for £500 for the princely sum of £49. It looks something like this under its snazzy magnetic cover:
In essence you feed 4 filaments into the bottom along with the G-code for your model and it cuts and splices them together into a single strand that presents the right colours at the right time for your model. Great right? Well, like anything with 3D printing getting multi-colour / multi material printing right is more art than science and the mosaic palette 2 in particular had a reputation for being very hit and miss. But for £49 you can’t go wrong….right?
The box duly arrived after a few days and, on opening it I was pleasantly surprised to find a canvas hub in there as well. This is a £30 add-on consisting of a raspberry pi zero and a custom board to break out USB and power. It runs Octoprint with some plugins to make it work with Mosaic’s ‘canvas’ software.
Ah yes canvas…. see, because your model needs to have additional information about different colours, you can’t use your normal 3d print workflow. I think there are ways to get some slicers to work with this, setting up extra toolsheads and so on, but Mosiac also provide an online slicer / colouring software called ‘Canvas’. This can connect to a canvas hub or an existing instance of octoprint with some plugins and print straight to your device. With 4 colours!
Unfortunately, mosaic seem to have let the software side of things lapse a bit. I couldn’t get the canvas hub to work at all at first…. and then when I did manage to connect to it the raspberry pi zero (the first generation) is so underpowered and frustratingly slow it’s not worth the effort and the canvas plugin didn’t seem to work at all.
So I decided to use my existing instance of Octoprint. I added the plugins (using the ‘add from url option’) and the links provided by mosaic:
Palette 2 plugin: https://gitlab.com/mosaic-mfg/palette-2-plugin/-/archive/3.0.1/palette-2-plugin-3.0.1.zip
Canvas plugin: https://gitlab.com/mosaic-mfg/canvas-plugin/-/archive/3.0.3/canvas-plugin-3.0.3.zip
Unfortunately….neither of those plugins would install on my up to date Octoprint 1.9.3. A quick scan of the documentation revealed that the plugins were only validated on Octoprint 1.7.3 or previous. Great.
So, I dutifully installed Octoprint 1.7.3 using docker, fired it up (marvelling at my journey into the halycon days of 2022) and installed the plugins again and……this looks more promising!
Unfortunately, we’re not quite there yet. According to the Documentation there’s supposed to be a button under that text to allow connection to Canvas. So what’s going on here? Lets have a look at the logs…..
Ah ha! It seems the plugin assumes that ‘ping’ is present on the system. In most cases that would be a fair assumption, but in the case of the Octoprint docker container it is not. Luckily the container does include a package management system (apt) so we can just login to the container (exec -ti CONTAINERNAME /bin/bash) and do a quick ‘apt-get install ping’ (this gives 2 canidates, just pick one and install it) and on a restart of the container……
Amazing, progress!
Now, click the ‘get activation code’ button and you should get a 4 letter code. Go into ‘Devices’ in canvas, click ‘add device’, enter the 4 letter code on the right in the hard to see boxes and……You get taken to a 404 page. But fear not, if you then click on devices you should see this:
And octoprint should show this:
Don’t rejoice too hard just yet though, because that device in Canvas stubbornly refuses to show ‘online’ despite multiple reboots. Let’s go back to the logs and see what’s going on.
So first off, it seems the Canvas plugin uses MQTT to stay in sync with Canvas which is interesting from a geeky standpoint….but of more interest is that error message: ‘missing 1 required positional argument: ‘callback_api_version’ in the MQTT module. Googling that error message brought me here where I discovered that the MQTT client library the plugin uses introduced a breaking change in 2014 which was apparently causing this problem.
To fix it, I logged into the container again, installed nano (although if you like pain you could install Emacs or Vi or something) using apt-get, then edited the file ‘/octoprint/plugins/lib/python3.8/site-packages/octoprint_canvas/MQTT.py’.
Line 75 in that file looks like this:
self._mqtt = mqtt.Client(client_id=self.client_id, clean_session=self.clean_session)
Add the required parameter so it looks like this:
self._mqtt = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1,client_id=self.client_id, clean_session=self.clean_session)
restart Octoprint, go back to Canvas and you should see…..
You’re goddamn right we’re ready…..
And just to test it’s actually working, double click on the device and, as long as you have a printer connected to octoprint, you should be able to control it from Canvas:
Now I just need to buy another 3 differently coloured filaments and I can start trying to actually print…..