Simple Optical Filament Runout Sensor

by Raptorfx, published

Simple Optical Filament Runout Sensor by Raptorfx Jun 26, 2016
3 Share
Download All Files

Thing Apps Enabled

Order This Printed View All Apps


Design Tools


Liked By

View All

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag


Thing Statistics

22979Views 1405Downloads Found in 3D Printer Accessories


This is the result of a weekend project. It uses a no-name optical endstop (like this one http://www.geeetech.com/images/v/Geeetech_IMG_5412.jpg) switch and just "guides" the filament threw it.
Endstop is connected to a Rasperry Pi running Octoprint, which is handing the correct parking and resuming by using the Filament Sensor Plugin http://plugins.octoprint.org/plugins/filament_sensor .
Works with all 1.75 mm filament (you should be able to drill it up to work with 3mm), except transparent ones.

I maybe design another one with a mechanical enstop in the future.

Print Settings


Prusa I3









More from 3D Printer Accessories

view more

All Apps

3D Print your file with 3D Hubs, the world’s largest online marketplace for 3D printing services.

App Info Launch App

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

App Info Launch App

Quickly Scale, Mirror or Cut your 3D Models

App Info Launch App

I drilled it out for 3mm filament, but then found that the clearance between the posts of the optical sensor is only barely enough. The tight fit (at least when printed with a 0.5 mm nozzle) for insertion of the sensor bends the posts just enough so that the filament won't go through easily.

You should be able to also drill out the optical sensors. That should give you a max of 0.5mm more per wall, so just enough to make it easier. Just dont drill away more then 0.5 ;-) And make sure that there is nothing blocking the light path after drilling.

I wonder...have you tested the transparent ones yet? Depending on the sensor type, it might even work with those! Have you tested it yet?

I have tested with transparent ones, yes. All of the clear transparent filament I have is not working with mine, but I think that has to do with the sensitivity, as I see that the indicator LED is getting dimmer. Might work with different sensor types or a sensor where you can adjust the sensitivity.

Anyone here hooked it up to a tevo tarantula? I'm not sure about the wiring.
Would appreciate any help.

I have downloaded the Reloaded version of your plugin below. I think the difference is just the settings GUI.


I prefer phsyical endstop switch instead of optic sensor because I am printing with clear filaments. I went for the endstop below, I have connected to PIN3, Ground and 5v power. Couldn't make it work. Any idea will be great. Many thanks in advance.


I think it might have something to do with if the switch is normal-open or normal closed. Means if it pull high to 5V when the switch is opened or if it pulls down to ground if it is opened. I have read somewhere that you can change if it should be high or low in the settings of the plugin, but for that you have to reach out to the maintainer on github or so, as I do not know how to do that.

I downloaded the plugin.
Where can I do the step that requires "the following need to be added to the config.yaml:"
Where can I find the Config.yaml

Should be somewhere in ~/.octoprint

I have no idea where that is. Sorry, Where I am at is that I have downloaded octopi onto an SD card.
Have Octopi able to run a print.
I added the plug in from the octopi.local settings.

Not sure if I still have to use the other files that are above. Guess I have too because it is still not working.

You have to ssh into the Pi and use the comandline to do that. I am not running the latest version, but I think I read somewhere that you should be able to do that changes also from the Octoprint Webinterface. I also just saw that there is a fork from another person that can be configured via the Webinterface https://github.com/kontakt/Octoprint-Filament-Reloaded if you are not that familiar with the linux comandline.

Feb 13, 2017 - Modified Feb 13, 2017

It is reading my sensor correct in my Pi 3 but prints are not pausing. Thoughts?

Does anyone have a video to set this up? Im running into to some issues

Just normal endstop cable? Anymore info how to connect this? just connect to ramps like an other endstop? Thanks!

This is intended to work with Octoprint, so conneting it directly to the Raspberry Pi. Details on that can be found in the plugin description. In theory it should also work with the ramps, but additional hardware may be needed.

i just noticed that marlin has now support for filament sensor, so in theory it should work even if connected to ramps (with marlin, of course). wiring should be straight forward, can even use one of the unused xyz endstop pins...

Sep 24, 2016 - Modified Sep 24, 2016

Can you explain how to utilize the API to get the status?

I am not sure on this. You may have to ask moonshinesg (you can also ask on github) on that.

Loving this idea I have my sensor on its way.

I am thinking about trying to integrate a buzzer and activation switch. So I can get an audible alarm so I know I need to do something. And a switch to disable the buzzer whilst changing filament.

Do you think this is something that could work?

Should work, depending on your buzzer you may have to use a transistor or relay to get more power to it if the sensor is not putting out enough. But there may be some electronics involved in getting it working ;-)

Sep 7, 2016 - Modified Sep 7, 2016

Any chance we can have this with some type of mounting option (Will be putting this somewhere where I can use the top spool mount of my Wanhao Duplicator i3)? Or if someone has put this on theirs how did you do it? Thank you

You can checkout this remix here http://www.thingiverse.com/thing:1719311 which should allow you to mount it easier. Let me know.

Support pour capteur optique de fin de bobine pour Dagoma D200

Thank you, I'll see if I can make it work.

any guides on setting this up?

The Software or Hardware part?
Regarding software check http://plugins.octoprint.org/plugins/filament_sensor .
Regarding hardware, connect the ground from the sensor to ground of the pi, Vin from the Sensor to 3,3V (or 5V) of the Pi and the Signal to the GPIO pin. Thats all.

I see what your saying. You use gnd 5v and a gpio pin.. so like pin 2 6 and 12 and i should be good then change my xx value to 12 since thats my gpio pin. Ty ty.

cool...combine it with a filament dust filter

Thats a good idea for V2, maybe a filament oiler?

Has anyone been able to make this work? I have installed the optical sensor and hooked it up to my Raspberry Pi 3 and it appears to sense the filament since the LED light on the board illuminates when the filament is missing. I have hooked the sensor wire to pin 21. It doesn't appear that my Octopi is sensing the the filament. I have also tried the API and it doesn't appear to be working either. Any suggestions would be helpful.

Check the octoprint logs when running. I think they are located at /home/pi/.octoprint/logs, just "tail -f ..." the logfile. You should see the plugin starting up and it will enable it when you start printing. It is not logging anything if the printer is idle.

what pin should the sensor be connected on Ramps 1.4 .. i see that d4 is configured in marlin ..

I am not sure where to connect it on the ramps, as I use it on the raspberry Pi together with octoprint.

What size are the screws? I tried M3 (too narrow) and M4 (too wide). Thanks.

The holes are 3.3mm in the stl, which results in a perfect fit on all the printers I am printing on for M3 Screws.
Whats the diameter of the holes on your print? Let me know and I can create one with smaller holes.

Thanks. I ended up filling the holes with epoxy to fit M3s. My printer printed the holes pretty close to the stl which was too loose for 3mm M3 screws.

Hi, when you say "pin: XX", XX is the PIN or the GPIO number ? Example the GPIO 21 is on the PIN 40....So I must configure pin: 40

No, you configure Pin 21. 40 relates to the total number of pins, the 21 is only for the GPIOs (I think).

so that's why the spike in the interested for the plugin .... :D

I have a few of these lying around somewhere... Is the size of the filament enough to trigger the switch ?

First question, how do I wire this to a raspberry pi?

You can also connect it to 3,3V and GND, your sensor should work at that voltage. If not, as moonshinesg mentioned, connect it to 5V. You can checkout the pinout for the Pi2 here for example, https://ms-iot.github.io/content/images/PinMappings/RP2_Pinout.png, otherwise just google the pinout for the Pi1, Zero or Pi3.

Wire the optical end stop to 5V, GND and a GPIO of your choosing - which you will then configure in the plugin settings.

Yes, didn't thought it will cause such a spike ;-) Will get back to you with the uname response as soon as I am back home.
Size is enough to trigger it without any issues, even if it is "cureved" from the spool.

I've linked back from the OctoPrint plugin and it's pending inclusion in the "official" list.
Payback time! :D

:D I really hope that it gets approved for the offical list. Cross fingers :-)

How do i wire up 2 of these for dual extruders? i tried wiring all 3 to each other (blue to blue, red to red, black to black)
that didn't work (light never went out when filament tripped sensor) so i thought each needed their own power, so i left the blues hooked up, but put each sensor power/ground on on it's own pin. same thing.. so i disconnected the blues and the light went on /off again when the filament was put in and out.. so it seems i can't wire the 2 data wires together? how can i make this work with 2 extruders?

at this moment the plugin doesn't support dual extruder.

Dec 3, 2016 - Modified Dec 3, 2016
fiveangle - in reply to moonshinesg

Does your plug-in even care which extruder is active during the print ? And even if it did, do you have access to the G code stream so you would know which one was active ? ( only an active extruder can trigger a filament sensor). Could someone simply wire two mechanical switches in parallel to pull down the GPIO pin if either NO switch triggers, then you just handle stopping the print accordingly, and restarting once the user indicates they are ready ? I don't know how your plug-in is written, but it would seem you might not need to make any changes ?

there is no actual support for 2 extrudes, meaning that the plugin doesn't care and doesn't check which is the active tool.

if you hook 2 switches to act as one (parallel if NO, series if NC) then everything should be fine. You might need to play with the settings, to get the right behaviour, but it should work fine. Try the "devel" branch, which has more options...

Afaik the plugin pauses via octoprint directly, so it should not care about what extruder it is.
Linking multiple together in parallel should theoretically work, but may require some more electronics (I am not an expert on that ;-) )

Very nice! congratulations :D

you mean... "good luck with the support" ? :D

Anyway, in case you need help with something feel free to ask me for help :D

Do you think it will be that much? I can image that there will be a few cases where you write a FAQ about it and thats it. There is not that much that can go wrong ... I assume ;-)

probably not that much. the code is fairly simple. after ironing a few details it should be ok...
I have another more complicated plugin that will sure cause headache.. but thats a dif story....

great. I'll give it a try tomorrow... (it's "good nite" in Singapore) :D

Nice. Let me know tomorrow then how it worked out :D

Jun 28, 2016 - Modified Jun 28, 2016
moonshinesg - in reply to Raptorfx

My mac decided to give up on me, so no printing for me for a while (fix or replaced :( )
But I did test the switch with a piece of filament and it works. Just needs to be fairly precisely positioned.

Yes, position is very relevant. Had the best results in my tests with the filament (the center of it) being located 2,5mm from the top of the sensor.

Aug 24, 2016 - Modified Aug 24, 2016
brotherchris - in reply to Raptorfx

If I wanted to do a manual switch, I should be able to plug one side in 3.3v PWR and the other in a GPIO port correct? Or would I use ground, I guess ground would make more since.

It doesn't really matter if you use 3.3V or Ground.
First, you shoud connect a ~200 Ohm resistor between the switch and the GPIO pin, just for protection.
Then, if you use 3.3V, you have to use a ~10K Ohm Pull Down resistor between the 200 Ohm resistor and the switch. If you use Ground then this will be a Pull Up resistor. Otherwise you will have a undefined state on the GPIO input.

I think the optical switches are active low, means they pull down to ground when closed.