Note: I had originally planned on posting this one after I had assembled my 3D printer but as it appears it’s going to be a while (FedEx has been waiting for it to be dropped off for a week in Hong Kong, don’t think it’s gonna make it to the US by it’s scheduled delivery Monday)
One of the things I wanted to do right away with my 3D printer is to make it a little bit smarter which is where OctoPrint comes in which is a nice piece of software that gives your 3D printer a web interface for management. With Raspberry Pi’s as cheap as they are it makes the OctoPi version a no-brainer.
In addition to a web-cam via the Raspberry Pi Camera Module the Pi’s GPIO pins for a filament run-out sensor and a relay to cut the power to be able to cut power to the printer through the Pi, even remotely.
For the filament sensor I found an inexpensive optical endstop sensor (can be found many places, just included Amazon link as an example) and then printed a housing for it. I went with this one as it includes mounts for my printer, but this one is much simpler if you don’t need a mount or want to design your own mount.
OctoPrint has an plugin called Filament Sensor which has instructions for configuring it. The sensor I got came with three pins labeled V, S, and G and absolutely no documentation so I guessed that G was ground, S was signal, and V voltage in. With that highly scientific deduction done I plugged V into one of the 3.3v pins, G into one of the ground points, and S to one of the GPIO pins. I chose GPIO24 as it was near both a 3.3v pin and a ground. Some testing found this appears to work so now I just need the printer so I can print the housing… and use it.
I got a dual relay board (getting the module instead of just two relays for cleaner wiring and mounting. One relay is for turning power on and off to the printer power supply and the other will be used later as a switch for some lighting for the print bed. I used this as a guide for wiring up the relays and configuring them in OctoPrint.
For wiring there were two sets of pins on my relay board. I relied on the internet on this one as I didn’t fully understand it but it seems to work. On the left side was JD-VCC which I wired to 5V, VCC which was wired to 3.3V and GND to ground. The other set of pins had GND (which had a trace to other GND so we don’t need to bother with it), IN1 which I wired to GPIO17, IN2 wired to GPIO18, and finally VCC I wired to another 5V pin.
I’ll defer to this documentation on configuring OctoPrint to have options to flip these relays. Make sure you change /etc/init.d/octoprint and ~/.octoprint/config.yaml. Also make sure you use a relay that can handle the power as for this purpose I’ll be running straight mains power through it.
So I got it all working and even wired up an RGB LED that I have some ideas for future work but it’s kind of a mess and if anything gets unplugged it’s gonna be a hassle to make sure I have the right pins. What I need is a hat… no seriously that’s what they are called (no I don’t know why). Basically it’s a board that can stack on a Raspberry Pi and provider an expanded interface for the GPIO pins. I picked a cheap one that came with support standoffs (I got this one) and wired it up so it was a little easier to hookup and disconnect as needed. I used some multicolored jumper wires to create cables for each of my purposes and used coloring to make sure I know where things plug in later.
Now all I need is a printer to finish this stuff off!