OctoPi 0.18 - Multi Printers & Cameras On 1 Pi - Chris's Basement

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
there's a new octoprint version out and octopi is now at a stable 0.18 release so let's check them out hello 3d printing people chris here and yes today we are going to be taking a look at octopi 0.18 and doing a multiple instance and multiple camera install so you can use multiple octa prints on one raspberry pi and use multiple cameras and i've done a lot of videos like this where i take some software and hack it to meet my own needs just for entertainment value and i don't want this to take away from the efforts that gina and guy have done with octoprint and the octopi image you should always use it as they intend for you to use it and don't seek support for these crazy installs like i do here again just for entertainment value but it is kind of fun to me to make the software do things that it probably wasn't supposed to do in the first place i just wanted to get that out there and now we're gonna do a ton of screen share getting all this set up and hopefully get everything working with multiple printers and multiple cameras so let's jump right into it so today for this video i am going to be using a raspberry pi 3b plus because i have a few of them i'm using an 8 gig card it is a number 10 card so it's a little quicker than maybe the average card that is recommended and i'm using two logitech c270 cameras now the cameras you use on multi installs that's somewhat important when you buy one preferably you use ones that have serial numbers and i can't really give you a list of the ones that do i do know that c270s have them there's also a pretty interesting hack you can do on these cameras with some 3d printed parts where you can focus them a lot better so if you can get devices that have serial numbers that makes it a whole lot easier to tell the software how to tell them apart when you're using multiples that's the same way with the printers as well if you have a main board that has a serial it's going to be a lot easier to use but you'll see more of that as we go around the video and i am also assuming that you have octoprint already installed on your sd card we're not going to run through that because the octopi install really hasn't changed much when you're using that image to create an sd card i have a video for that link in the description also i'm just going to grab a couple of different printers when we get to the multiple printer section just to show you how it all works it really doesn't matter which printer you use but remember if it has a serial that's going to be better also if they're not the same type it's going to be a little easier to use two under threes they don't have serial numbers that's going to be a bit tricky i'll show you the tips that i know how to get them to work but it's really not all that consistent but we'll go through all that so let's boot up and get into putty and check things out so here we go here's our fresh octoprint instance the web interface remember the install video will show you how to get all this stuff done including how to use octopi.local but you will need the ip for some of the steps that we're going to be doing today a lot of this work is going to be done ssh i like to use the putty tool there's a lot of great ssh tools out there but i'm most comfortable with putty so that's what i'm going to be using we're going to do a lot of line command stuff today i also will have scripts that you can run that do all of this for you if you wish but you might want to go line by line just to make sure you know how it's installed and how it works so we're going to log in ssh to this instance default username is pi and default password is raspberry so we're first going to tackle a multi-instance install and i'm going to do two instances and two cameras for this video now the scripts actually do four instances but i'll show you how to enable and disable those if you'd like to go that route so let's just take a look at our home directory we're just going to do an ls we're looking for a dot octoprint directory that's where all our configurations are and you can't see that because it's a hidden directory so if you do ls-als that'll show you everything and give you all the details this is the directory we're looking for right here and to make multi-octoprint instances we're just going to copy this directory again we're only going to do two for this video you can probably do as many as you want i've personally never done more than five multiple cameras i usually like to stop at three that's just a reference go ahead and do whatever you want if you can get away with it also this same install will work on the pi 4 octopi 0.18 seems to work on pretty much any pi now they've corrected a lot of issues so whichever one you want to use go for it so we're going to copy this octoprint instance don't use sudo on this one we're just going to do a cp r that gets all the directories and sub directories everything in them and we're going to use a fully qualified path just to make sure we're going to do forward slash home forward slash pi that's the user dot octoprint and we're just going to make a copy in the same directory forward slash home forward slash pi dot octoprint with the number two on the end so now we've got our second octoprint instance copied i did want to mention also a lot of times i will do update and upgrade for these linux install raspbian installs before we get started you shouldn't have to with this current version they're pretty up to date but it never hurts anything if that's what you like to do also you can upgrade your octoprint version this is 1.5.2 there is a new one out 1.5.3 but again this install isn't going to impact it as this is a pretty new version already so let's continue on let's go ahead and take another look now that we have this copy made ls-als we have octoprint 2 and it is owned by pi and it's in the group pi but it never hurts to go through and set it that way just to make sure all the files and directories underneath it are set you want everything to be owned by pi in the group pi so we're going to do sudo ch own dash r that gets everything all the directories all the files we'll do pi colon pi and then our location forward slash home forward slash pi forward slash dot octoprint two just to be sure all the permissions are correct anything sudo you have to have your suit a password and that is also raspberry if you haven't changed it so we're good there we've created all the files we need now let's jump to etc for slash etc forward slash system d forward slash system we can do an ls in here and what we're doing now is creating another service for our new octoprint entry this is the one that we have right now the default one that you install we're going to make a copy of that one so we can run two you can highlight on the screen and then right click to paste but we're just going to copy this one sudo cp for copy paste that in there we'll paste it in again only this time we're going to call it octoprint 2.service now we're going to edit some things in that octoprint 2.service so we'll do sudo nano octoprint 2 dot service so we just need to make it a little bit different than the first one we're going to use a different port so that you can run multiples you also have to run a new base directory so for host i'm going to take this one down to 0.0.0.0 rather than the localhost at 127.001 it just works better if you set these to zero and have the base one at one two seven the base port for the initial instance is five thousand we're going to run 5001 for the second one if you run multiples just increment it whatever port you'd like to use and then down here on execute start out here to the right we're going to do dash dash base dir equals then we're going to tell it our new base directory the one that we just created over there in the home folder so forward slash home forward slash pi forward slash dot octoprint two and that should be all we have to do in this file ctrl x y and enter to save and that's pretty much it as far as getting the second instance started again the more you make the more you can start we do have to enable it with system contil so that it will start on reboot so we're gonna do sudo system ctl enable octoprint 2 it's created our link so now it'll start on reboot and then you can just go ahead and start it just take out the enable and do start now if you head back to your browser this is our initial entry at the main ip it's on port 5000 forwarding to 80. we can just duplicate this tab and then after your ip you can enter the 5001 the new port that we put it on and then you can log in to your second instance it's going to be the same as the first one you created if you've been to the wizard already if not you'll have to go through the wizard and now we have two octoprint instances up and running now we want to configure two printers to work on separate octoprint instances and it's a bit of a process but don't worry we'll walk through it so back to putty now let's head to etc forward slash udev forward slash rules dot d we can take a look in here we are going to create a new rules file so we'll do sudo nano 99-usb dot rules this is where you can name the different devices that you plug in usb to your pi or any linux instance to something that you know something that's easier to refer to it by and this is how you tell them apart so you can assign them to different instances so i just pasted this line in here because it's rather long winded but we'll go through how it works the sub system is tty that's how we'll interact with the printers the cameras will be a little different story so you fill in these different attributes based on the printer that you're using and the main board it has and some of these other attributes are to help you if you have multiple printers but let's walk through that just a bit so i've got my prussian mark 3 right here i'm going to go ahead and plug it into my pi usb it is powered up and then we're going to take a look at the log to see what happens when the pi negotiates with that printer so we'll go ahead and save this file for now because we have to gather a little bit more information so control x y enter to save and let's take a look at what's in our messages log so we're going to do cat to read it forward slash var forward slash log forward slash messages and there's a bunch of errors in here it's trying the webcam over and over it tries to start it no matter what in case you plug one in later but what we're interested in is this section right here where we plugged in the printer now on some printer boards they're going to tell you the manufacturer of the printer this line right here as well as the serial number of that board right here that makes it a lot easier to use this setup because you have these attributes to tell the printers apart not every manufacturer is going to do this also a lot of main boards have the same id vendor up here as well as the same id product and if they're all the same it's really hard to tell them apart and divide them up like this but the producer machines it's really easy so now that we can scroll back and see this information let's go back into our rules file sudo nano 99 usb dot rules and we're going to fill out some of this info because we just found it in the log so my prusa's id vendor will scroll back it is 2c99 my id product is 0002. so right here we're going to do 2c99 id product 0002 and as long as you don't have any other printers with that id vendor and id product you wouldn't have to fill out anything else just to be extra safe we can go ahead and add in the cereal with this attributes cereal so we'll scroll back and grab that that's this right here look for the line that says serial number not this one up here that has an equals on it that's not going to work this is the one you want it should have a line all by itself so we'll grab that back to our file and we'll paste it in right there now we're absolutely sure we're not going to have a different printer on that different instance we'll know which one it is and the sim link over here is the name you want to use so let's call it prusa mk3 for mark 3. these are case sensitive so whatever you use here you're going to have to use it in your other configuration options and you notice right here i pasted in this attribute called dev path now devpath is the usb number that you can use of that device while it's plugged in to a certain port but if you change it to another port and even sometimes on reboot these are going to change only use this if you have to this is only in the case that you have multiple printers that are the same machine they all have the same id vendor id product or they don't have a serial number that's this is a last resort setting that you would use and if you want to use it you can scroll back this is the dev path number so you can usually just leave the first number and hyphen off you would just go with a 1.2 you have to look these up in the log because they're going to be different for every port but if you wanted to use dev path say you have a bunch of ender threes come back to your file the one you just plugged into that port just put in 1.2 like that you plug in the next one it's going to be something like 1 4 or 1 3 and so on but remember if you have to do this you can't swap around plugs probably you can't even shut the machines off things might change this is a last ditch effort just keep that in mind we're not going to use this for anything else in this video we're just going to go ahead and delete that attribute and if you use my script delete any attributes that you're not using it just keeps things simpler and it might help troubleshooting down the road if something isn't working correctly so we're good on this one now i want to add a second printer so i'm going to plug in my prusa mark ii so it's cabled up usb i'm going to go ahead and save this file i'm going to display messages one more time you can see we plugged in the mark ii you can see it's a mark ii right there we're going to repeat this process we'll go to the rules file i'm just going to copy this whole line because a lot of these attributes are going to be the same but they will have different serials we'll paste it right below scroll back and take a look it is to charlie 99 its id product is one we'll go ahead and grab the serial back to our file id product change that to 1. we'll paste in our new serial and we're going to call this one prusa mk2 for mark 2. and that's everything you need to do for the printers so control x y enter to save and let's go ahead and reboot now that we have that information in there sudo reboot when the reboot is complete we're going to go back to the web ui for both our instances we've got the first one here and then the one over on 5001 over here we need to add those port names that we just created with that sim link command in that rules file so if you go to settings on the serial connection tab over here on the left additional serial ports put in forward slash dev and then forward slash whatever you called it with that sim link name the first one we added was our mark iii so remember it was caps prusa mk3 and we'll save it and then let's go to the second instance we'll update it the same way settings serial connection tab forward slash dev forward slash prusa mk2 for our mark ii and we'll hit save now we can reload just hit the reload on your browser for both of these both our printers are plugged in so up here in the serial port connection for your first instance because that's where we just added it you're going to have a prusa mark 3 if your printer is plugged in which it is we can go ahead and connect and we are connected you can pop that connection open back again it's grayed out we're connected at eleven five two hundred so we're good on that one we'll jump back to our second instance we'll do the same thing you should now have your port our mark ii port right there just hit connect and we're connected up all set receiving information and you can now use these independently your plugins will be shared but your g-code files will be independent there is one setting i suggest you tweak when you're using multiple instance and you only need to do it on the alternate ones not the main one go into settings go into server and update your octoprint service name so you're allowed to restart them individually the only thing you need to tweak is restart octoprint just add the two here or whatever instance you created whatever you called it when you created that service update it here so you can use them this gives you options in the power button to restart octoprint as well as when you run things like plug-ins that need to restart it it's going to use this command so save that also back into settings if you take a look at folders it should go ahead and add that octoprint to to all these folders that you've added so it separates them out but if you want to use the same folder you can direct different things right here so for instance if you want to use the same folder for all your time lapses or uploads for some reason you can change whichever folder that goes into directories just some side tips also if you want to update octoprint like we have an update out there for 1.5.3 you have to do them all individually the easiest way to do it is to just come into software update for each one and hit the update again plugins will be shared so if you install one it's going to be on all of your instances just some side notes but effectively now these printers are ready to go you can use them side by side simultaneously they're separated well with serial numbers and those attributes so they shouldn't get crossed sometimes the serial will get clogged and it picks the wrong one but if you have all the right attributes like i showed you and you have serial numbers and they are definitely different printers it's not going to grab the wrong one on reboots or if you unplug a printer it's going to work just like this i would suggest that you avoid doing the auto connect at server startup because sometimes when they're starting up it can grab the wrong one if one hasn't come in correctly so just go through and connect them after you've started it up to make sure they're on the right port so there's multiple printers and in my opinion from the past installs that i've done it's a lot easier now than it used to be also i will have a dock in the description below with a link to a script that you can run that will install four instances for you and you can turn those off if you don't want to use all four so they don't use resources so let me show you to do that real quick so say you've ran that script you have four instances but you only want to use two printers for now i just install four by default because that's how many usb ports i had you can just turn them off with that sysq option so we're back in let's do sudo system ctl and before we did enable this time we're going to do disable and we'll just do octoprint 2. now has removed it from the startup so now it won't start on reboot so if you have four and you only want two printers for example just do disable on octoprint three and octoprint four that way it won't use the resources that's the easiest way to be able to use the script without having to run all four if you don't want to for now i'm going to go ahead and enable octoprint 2 to carry on with this video now that we've got the two printers up and running and you know how to control the different instances turning them off and on and such now we need a camera for each one of these and here's where the real hacking and tweaking comes in we have to change a lot to get this to work and i actually don't use the configuration with the cameras i just use the multiple printers but it is possible and i have been able to make it really consistent now so let's jump into that piece so the first thing we're going to do is let's take a look at the current webcam d service that's the service that you use when you plug in a camera to octoprint normally so let's do sudo system ctl we'll do status webcam d we don't have a webcam plugged in you can see it's exited right here but this gives us information about that service so we can build an additional one and it is located in the same spot that we were in when we did the octoprint service we're going to pretty much do the same thing only with the webcam d with a few added tweaks so let's head to etc systemd system we're just going to do cd paste that in there we'll take another look just like we did before here are two octa print services that we created here's the webcam d service so let's just make a copy of that sudo cp webcam d service we'll paste in again webcam d2.service and let's make some edits sudo nano webcam d2 dot service so both of these are going to run out of root bin the working directory we don't have to change that i do want to point them at different log files for the standard output and the errors they both go to the same log we're just going to change it from webcam d to webcam d2.log to dot log just so we can troubleshoot if we need to also we're going to start it out of another root bin file we're going to create another webcam d file so we'll just call that two as well so that's all we need to do for the service we can control x y enter to save and now we need to go create that root band service so let's jump over there cd forward slash root forward slash bin we can take a look there is the webcam d file that we're after let's just make a copy of it you probably want to save some of these as well in case you mess up you don't want to have to reload the whole octa print just to because you messed up one file so let's just save a copy real quick to be safe let's do sudo cp webcam d and we'll make a copy of it webcam d dot old so this is the original one that will have in case something bad happens now let's make a copy of it into webcam d2 now there are a couple things that we're going to have to change in both of these files and i almost kind of feel bad because they've done a really good job helping you use your cameras with these webcamd services it does a lot of things in there to try to keep you straight using multiple video options that you have it's just how linux works now with different attributes with the cameras and the streams that you can use it's kind of all over the place but again this is a hack job only for your entertainment so let's take a look at the original one sudo nano webcam d so the fastest way to get you up and running in multiple camera mode all of this for the initial instance is fine in the other installs we would have edited these and you can see right here it says do not edit this well for the most part you don't want to edit this you can use even multiple boot octopi text files you can see one up here to configure multiple instances if you want but because of some of the smarts that they've put in this file it's not going to meet what we need it to do down in here it actually tries to figure out what your video number is and if you look in that forward slash dev you can see video 0 through like video 13. so octoprint is trying to tell which one you're using so it's going to scan through all of them and if you've declared one in your config file it'll go for that if not it will pick the first one available again there's a lot of smarts built into this file they've done a great job but i'm pretty much going to circumvent all of this so in octopi 0.18 in this webcam d file i'm going to line 167 and for the device name video 0 i'm going to change that to the device that i'm going to call my camera i'm going to do cam mk3 that's the camera that's going to be pointed at my prusa we're going to set that up in our rules file in a moment and if you keep scrolling down this is all the logic right here that tries to help you decide which camera you have plugged in and how it's going to use it i'm circumventing this again so i'm on line 265 again octopi 0.18 so it's going to try to start the video device that device that i changed up top where it says cam mk3 that's a variable so i'm just going to take video off and i'm just going to call the device directly so pretty much everything that helps you decide in between here and there has been jumped over i'm just calling that device the one we manually entered so i'm going to control x y enter to save because we're done with this one then let's jump to webcam d2 there's a few more things we need to do inside here the biggest one being the port number because we can't use the same port for both cameras so here on line 49 i'm just going to add in a dash p inside these quotes space and a port number 80 81 because the default camera uses 8080 and then add a space so that will let us use multiple cameras different ports they all have to have their own and then we're going to scroll down and make the same changes we did on the first file so line 167 we're going to call this one cam mk2 for our mark ii camera and then back down to line 265 we're just going to take the video underscore off and call the device directly control x y enter to save and last but not least we need to enable our new webcam d2 service just like we did for the printer we'll do sudo system ctl enable webcam d2 and then we can go ahead and start it but it will now start on every boot we can take a look at it with status it's up and listening on port 8081 if you do have errors with webcams remember they do have their own specific log files out in var let's just take a look real quick ls forward slash var forward slash log here's your webcam 2 log webcam log all this information like here in the service display will be in these log files in case you need to do some troubleshooting this is where it's going to be so basically i've jumped over a whole lot of the logic that they've tried to put in here to try to make this whole thing easier to use and i don't necessarily want to do that but again this is a hacking and tweaking section this isn't something i expect everyone to do it's just if you want to get adventurous and try to mix this up a bit and use multiple cameras so now we're going to get the cameras plugged in try to tell them apart so we can use them on different printers so let's do this one at a time i've got my c270 here and my mark iii with a purple benchy on it let's just plug that in usb along with our two printers now we only have one port open now that we have our first camera plugged in let's take a look at the messages file just to see what happened let's do cat forward slash var forward slash log forward slash messages and you can see right here where we plugged in the camera the dev path is 1.5 you can use these just like we did with the printers these are the attributes you need and my c270 has a serial number right here again makes it very easy to use compared to ones that don't so we're going to go to our usb rules file so we'll change directory over to forward slash etc forward slash udev forward slash rules dot d we'll take a look we're going to edit that 99 usb rules that we had before sudo nano 99-usb rules and here we have our two printer configurations now we need to configure a couple of cameras and again we'll walk through this step by step on what all these attributes do but it's pretty much the same thing as the printer so we have id vendor id product if they're different on your cameras you're going to have a lot better luck or if you have a serial number notice this is a video for linux rather than a tty so you can scroll back get your id vendor right here 046 d we'll also need our id product which is zero eight two five id vendor id product zero eight two five and we can also add that attribute for serial a ttrs curly bracket serial curly bracket equals and in quotes we'll put our serial number and that's right here and we'll paste it in and make sure after every attribute you add you have to have a comma you can also use devpath here if you don't have serial numbers for your cameras again you have to try to keep them in the same ports don't move them around it actually doesn't work all that well but it's about your last alternative remember that is a t t r s curly bracket dev path curly bracket two equals and then in quotes you can put in that dev path number for this one it would be 1.5 all that's in your messages file so it would look like this but we're not going to use that because we're fortunate enough that we have cameras with serial numbers so we'll take that out for now there is one more attribute you need to add and you have to add this because multiple streams can be done by a single device as far as linux is concerned we're only interested in the first one for both of these cameras so we're going to do attr curly bracket index then curly bracket equals equals and then in quotes zero don't forget your comma that way we tell it we want the default stream don't try to search for another one this one only has one and then in your sim leak we need to call it what we called it in the camera files that we created those webcam d files and our first one for our mark iii we called it cam mk3 remember it's case sensitive so we're good here now we're going to add our second camera for our mark ii so let's just copy this line i will plug in my mark ii cam to my usb port the only port i have remaining then we can control x y enter to save to save this file for now let's spill out the messages file one more time cat var log messages here's the information for that new camera that we plugged in both of these are 270s so it's going to be very similar as far as id vendor and id product we're just going to have a different serial number so we'll grab that we'll head back in to our 99 rules file all this is going to be the same except for the serial we'll update that serial number we are setting it an index of zero because we want the zero stream for both of these it's both both are going to be zero don't let that confuse you and we call this one cam mk2 for our mark ii and that's all you should have to do in this file to get those separated out and working independently so let's control x y enter to save and let's do a reboot to pull everything in sudo reboot and you could probably wait on that reboot if you wanted to until we made this last edit but i am going to edit one more thing so that we can use the interfaces for the cameras so i'm going to log back in restart session and we need to update our h a proxy configuration that's what tells it where to go when you enter a certain url on your web gui so we're going to do cd forward slash etc forward slash h a proxy and then we're going to do sudo nano h a dot cfg to edit the configuration this is also one that you might want to go ahead and make a copy of so in case you messed something up you can revert back to this one before we edit let's go ahead and do that you just do cp haproxy.cfg let's just call it haproxy.old now we have a copy for safekeeping now let's edit our happy.cfg so we need to update the front end this is what tells it when you access a certain file path on the url bar which back-end to use this is the one for the standard webcam we don't need to make any changes to that but we're going to put in one for the other back end the second webcam and you'd have to have multiples of these if you had four or five so on but we'll paste that in there and we'll just make the updates so use backend we're going to use backend webcam 2 we're going to create the back end below and then the path to access that back end webcam 2. then we need to create that back end so we'll scroll down you can see back in webcam right here we're going to just copy this whole block just highlight we'll go down underneath and add a space and paste it in right click we'll rename this one back in webcam 2 we're going to do slash webcam 2 to get into it keep the server webcam 1 keep that the same name it's going to be the same server name but we're going to go to a different port the new cam as you saw before is on port 8081 that's dictated in that webcam d2 file from root bin but that's all the changes you need to make in here ctrl x y enter to save one more reboot and we should be in good shape sudo reboot after the reboot's complete we can jump back to our web ui we'll go ahead and reload these our first instance right here we are connected to our mark iii you can verify that with connection that's our port and it's using the standard camera on port 8080 the default one so if you go to control here's your camera this is the c270 that we plugged in and set on our mark iii it's pointed at a purple benchy no updates are needed in the configuration to use this because it is the default camera it's using that default port the configuration should work just fine for this one now to add multiples onto other instances we do need to make some updates so let's go over to the second instance you'll notice in control it has the default information here with the original webcam so it's not working so we need to go into settings go to webcam time lapse and we need to make some updates so we're going to have to direct it to the ip of this raspberry pi so you will need to know that like i said at the beginning of the video so we need to do http colon forward slash forward slash the ip of this pi which is mine is 192.168.1.254 and then we're going to update webcam to webcam 2 like we saw in the h a proxy file down here for the snapshot url that port 8080 we just need to update that to 8081. so it knows what port to get that snapshot from that local address right here should be fine that should be the only update and now if you hit test you'll see our camera although it's not positioned all that well for our mark ii with our blue benchy and time lapse recording snapshot you can hit test there it is again so we know both cams are working go ahead and hit save now you should be able to see your cameras on both instances from the control tab and they're assigned correctly so there it is multiple 3d printers multiple cameras running on a single raspberry pi and you're able to control them all with different instances of octoprint and we used octopi image 0.18 and this configuration works a lot better than the previous versions this was a bit of a revisit video but i've switched around all the usb plugs rebooted the pi multiple times and it always comes back as i expect it to no problems at all and remember we did hack and tweak our way through this octoprint isn't intended to be used this way but if you're more of an adventurous octoprint user it might be fun for you to give it a try hopefully you found this interesting that is it for today and i'll see you very soon on the next one
Info
Channel: Chris Riley
Views: 30,958
Rating: undefined out of 5
Keywords: 3D, printer, Printing, 3D Printing, 3D Printer, ChrisBasement, ChrissBasement, Chris'sBasement, Chris Basement, Chriss Basement, Chris's Basement, ChrisRiley, Chris Riley, benchy, 3dbenchy, 3d, Octopi, octoprint, raspberry Pi, 0.18, Multiple Printers, Multiple Cameras
Id: FIPbiImixZM
Channel Id: undefined
Length: 40min 37sec (2437 seconds)
Published: Wed Feb 17 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.