Need Plugin for Smart Filament runout sensor

Ahh didn't see the "configurable GPIO pins" in the plugin description. Even better.

Yeah, I fixed that screenshot link on the plugin repo last night...

1 Like

Hello, I have the BTT smart sensor and I can't get it to work with octoprint. Did anyone watch teaching tech's guide on it? The first comment shows a possible fix for octoprint as well but the information is really vague. Should the sensor be connected to the board, TFT or the pi? If it is the pi, which pins? Can someone please help me out it's been a month and I still can't get it to work with octoprint

1 Like

Pretty sure the plugin requires it to be installed on the Pi because it has settings for GPIO pins.

@jneilliii do you know how to connect the sensor to the Pi?

I do not. I don't have one. I assume it's a 3 wire device, 1 signal 1 power and 1 ground. Looking at the readme it says to use 3.3v pin for power and any GPIO pin for the signal.

Hey bud, I hooked this sensor up to my ender 3v2 not too long ago and seem to have everything working as expected. It is wired to the printer, and I had to tweak the firmware to support. You need to make sure HOST_ACTION_COMMANDS and HOST_PROMPT_SUPPORT are enabled, along with m600. When a runout is detected I get a prompt in octoprint, and am able to resume printing from there as well.

I see you have the ender 3... Not sure if that supports hooking this sensor right to the board or not... But wanted to chip in and say this is working with the sensor wired to the printer. Would be glad to answer any questions if you have them.

Hey, I have the SKR mini e3 V2, it has it's own filament runout sensor port. So if I connect the printer to the mainboard, and enable host commands, this will work through octoprint?

It is certainly working for me at least. Just need to make sure everything is set up correctly in your firmware config. There are a couple small tweaks I had to make to the octoprint settings as well, I can post what that is when I get home to double check it.

I am having some trouble with M600 after pausing... The rest of the layer it paused on does not go down well at all... But I haven't been able to track down where the issue might lay with that just yet.

I got around to testing this out finally and I'm not sure if my BTT Smart Filament sensor is working or not.
I'm hooked up to GPIO24 (set to BCM) but I keep getting timeouts on distance mode, no matter if the sensor is rolling or not.
What is a good place/log to take a look at to see what's coming through the GPIO, if anything?
EDIT: OK found the debug log for the sensor and looks like things are logging (remaining distance etc.).
Will have to do more digging on this as it's not behaving as expected. Probably something I've done.
EDIT2: The pause event seems to be related to the "remaining distance" in the logs and as soon as that counts down to zero or negative values, the pause/change is triggered.

2020-11-28 13:43:04,041 - octoprint.plugins.smartfilamentsensor - DEBUG - Sensor enabled: True
2020-11-28 13:43:04,043 - octoprint.plugins.smartfilamentsensor - DEBUG - GPIO mode: BCM Mode
2020-11-28 13:43:04,055 - octoprint.plugins.smartfilamentsensor - DEBUG - GPIO pin: 24
2020-11-28 13:43:04,059 - octoprint.plugins.smartfilamentsensor - INFO - Motion sensor started: Distance detection
2020-11-28 13:43:04,062 - octoprint.plugins.smartfilamentsensor - DEBUG - Detection Mode: Distance detection
2020-11-28 13:43:04,067 - octoprint.plugins.smartfilamentsensor - DEBUG - Distance: 15
2020-11-28 13:43:04,083 - octoprint.plugins.smartfilamentsensor - DEBUG - LastE: 15.0; CurrentE: 15.0
2020-11-28 13:43:04,099 - octoprint.plugins.smartfilamentsensor - DEBUG - Remaining Distance: 22.0
2020-11-28 13:43:04,103 - octoprint.plugins.smartfilamentsensor - DEBUG - Delta Distance: 0.0
2020-11-28 13:43:04,106 - octoprint.plugins.smartfilamentsensor - DEBUG - E: 15
2020-11-28 13:43:07,688 - octoprint.plugins.smartfilamentsensor - DEBUG - LastE: 15.0; CurrentE: 30.0
...
2020-11-28 13:43:50,887 - octoprint.plugins.smartfilamentsensor - DEBUG - LastE: 16.70269; CurrentE: 16.73332
2020-11-28 13:43:50,888 - octoprint.plugins.smartfilamentsensor - DEBUG - Remaining Distance: 0.29731
2020-11-28 13:43:50,890 - octoprint.plugins.smartfilamentsensor - DEBUG - Delta Distance: 0.03063
2020-11-28 13:43:50,891 - octoprint.plugins.smartfilamentsensor - DEBUG - E: 16.73332
2020-11-28 13:43:50,933 - octoprint.plugins.smartfilamentsensor - DEBUG - LastE: 16.73332; CurrentE: 16.76394
2020-11-28 13:43:50,934 - octoprint.plugins.smartfilamentsensor - DEBUG - Remaining Distance: 0.26668
2020-11-28 13:43:50,936 - octoprint.plugins.smartfilamentsensor - DEBUG - Delta Distance: 0.03062
2020-11-28 13:43:50,937 - octoprint.plugins.smartfilamentsensor - DEBUG - E: 16.76394
2020-11-28 13:43:50,981 - octoprint.plugins.smartfilamentsensor - DEBUG - LastE: 16.76394; CurrentE: 16.79455
2020-11-28 13:43:50,982 - octoprint.plugins.smartfilamentsensor - DEBUG - Remaining Distance: 0.23606
2020-11-28 13:43:50,984 - octoprint.plugins.smartfilamentsensor - DEBUG - Delta Distance: 0.03061
2020-11-28 13:43:50,986 - octoprint.plugins.smartfilamentsensor - DEBUG - E: 16.79455
2020-11-28 13:43:51,029 - octoprint.plugins.smartfilamentsensor - DEBUG - LastE: 16.79455; CurrentE: 16.8252
2020-11-28 13:43:51,031 - octoprint.plugins.smartfilamentsensor - DEBUG - Remaining Distance: 0.20545
2020-11-28 13:43:51,033 - octoprint.plugins.smartfilamentsensor - DEBUG - Delta Distance: 0.03065
2020-11-28 13:43:51,034 - octoprint.plugins.smartfilamentsensor - DEBUG - E: 16.8252
2020-11-28 13:43:51,078 - octoprint.plugins.smartfilamentsensor - DEBUG - LastE: 16.8252; CurrentE: 16.8558
2020-11-28 13:43:51,079 - octoprint.plugins.smartfilamentsensor - DEBUG - Remaining Distance: 0.1748
2020-11-28 13:43:51,082 - octoprint.plugins.smartfilamentsensor - DEBUG - Delta Distance: 0.0306
2020-11-28 13:43:51,084 - octoprint.plugins.smartfilamentsensor - DEBUG - E: 16.8558
2020-11-28 13:43:51,109 - octoprint.plugins.smartfilamentsensor - DEBUG - LastE: 16.8558; CurrentE: 16.87482
2020-11-28 13:43:51,110 - octoprint.plugins.smartfilamentsensor - DEBUG - Remaining Distance: 0.1442
2020-11-28 13:43:51,113 - octoprint.plugins.smartfilamentsensor - DEBUG - Delta Distance: 0.01902
2020-11-28 13:43:51,114 - octoprint.plugins.smartfilamentsensor - DEBUG - E: 16.87482
2020-11-28 13:43:51,157 - octoprint.plugins.smartfilamentsensor - DEBUG - LastE: 16.87482; CurrentE: 16.8859
2020-11-28 13:43:51,158 - octoprint.plugins.smartfilamentsensor - DEBUG - Remaining Distance: 0.12518
2020-11-28 13:43:51,160 - octoprint.plugins.smartfilamentsensor - DEBUG - Delta Distance: 0.01108
2020-11-28 13:43:51,162 - octoprint.plugins.smartfilamentsensor - DEBUG - E: 16.8859
2020-11-28 13:43:51,204 - octoprint.plugins.smartfilamentsensor - DEBUG - LastE: 16.8859; CurrentE: 16.89541
2020-11-28 13:43:51,206 - octoprint.plugins.smartfilamentsensor - DEBUG - Remaining Distance: 0.1141
2020-11-28 13:43:51,209 - octoprint.plugins.smartfilamentsensor - DEBUG - Delta Distance: 0.00951
2020-11-28 13:43:51,210 - octoprint.plugins.smartfilamentsensor - DEBUG - E: 16.89541
2020-11-28 13:43:51,253 - octoprint.plugins.smartfilamentsensor - DEBUG - LastE: 16.89541; CurrentE: 19.02829
2020-11-28 13:43:51,254 - octoprint.plugins.smartfilamentsensor - DEBUG - Remaining Distance: 0.10459
2020-11-28 13:43:51,256 - octoprint.plugins.smartfilamentsensor - DEBUG - Delta Distance: 2.13288
2020-11-28 13:43:51,258 - octoprint.plugins.smartfilamentsensor - DEBUG - E: 19.02829
2020-11-28 13:43:51,301 - octoprint.plugins.smartfilamentsensor - DEBUG - LastE: 19.02829; CurrentE: 19.05041
2020-11-28 13:43:51,302 - octoprint.plugins.smartfilamentsensor - DEBUG - Remaining Distance: -2.02829
2020-11-28 13:43:51,304 - octoprint.plugins.smartfilamentsensor - DEBUG - Motion sensor detected no movement
2020-11-28 13:43:51,306 - octoprint.plugins.smartfilamentsensor - INFO - Pause command: M600
2020-11-28 13:43:51,309 - octoprint.plugins.smartfilamentsensor - DEBUG - E: 19.05041
2020-11-28 13:43:51,349 - octoprint.plugins.smartfilamentsensor - DEBUG - LastE: 19.05041; CurrentE: 19.08106
2020-11-28 13:43:51,349 - octoprint.plugins.smartfilamentsensor - DEBUG - Remaining Distance: -2.02829

I'm not sure (considering all the way through the log to the point the M600 is sent there seems to be movement detected) why this is being triggered or how the 'remaining distance' is measured or if it should be refreshing considering the delta distance looks about right for what's going on.
Any clues appreciated! Thanks in advance.

Seem to have it under control with some different settings (detection at 25mm). The remaining distance seems to be resetting ok after changing, and the M600 was triggered when I snipped the filament.
On looking at the debug log, it's an interesting pattern on how the measurements are done, which is not to say I completely understand the triggering, but it looks as though 25mm will do the trick as the remaining distance is not getting below 20 most times, but on a few occasions does reach 7.
Thanks very much to the dev for the plugin.

EDIT - spoke too soon - got 2 thirds though a print and got the filament runout again, multiple times.
Still have debugging on if the author wants a copy.
Might increase to 35mm next time I can afford time to muck around with failed prints.

I was having some inconsistent behavior with mine too - I got frustrated and decided to take it apart. What I found was enlightening.

Basically there is a rubber ring around the encoder wheel that spins via contact with a metal (stainless?) wheel. My rubber wheel had accumulated a bit of dust on it, and created a dead zone where the metal wheel was much more likely to slip if the right kind of retractions occurred on it.

So I would suggest trying to disassemble and clean it!

Thanks for the tip. I've already disassembled and considering it's pretty much only printed 25m of filament through it it's spotless and everything seems to move ok when doing some drag tests.
When I get a chance I'm going to run that python script on the wiki to check readings and see what's happening, but I've turned the sensor off for the time being as the M600 is troublesome enough on the CR10S Pro V2 with Tinymachines 6.2 FW on Octopi, I need to get some models out before I go back to diagnosis again.

What you could possibly try (I was actually going to do this before I found the dust) is maybe put a small strip of electrical tape around the encoder wheel to try to increase the tension between the 2 wheels. Just an idea!

Will definitely keep that in mind. I do think it's spinning ok though (can see it through the window/hole) and the tension on the filament from the wheels is pretty tight.
What would be interesting is to know (from the debug log) where the LastE (assuming extrusion), CurrentE and E: are coming from. Is that a measurement from the BTT Smart Sensor directly, or a calculation from Octoprint on approximate extrusions?

I realize it's very subjective but how much friction is the BTT device imparting compared with the stock microswitch run out?

I ask because I've found that even the small resistance from my stock run out detector is enough to adversely effect print quality. Although I suspect increasing the tension of the idler in the extruder would overcome that, the machine runs so well at the moment that I'm loath to introduce yet another variable.

So I narrowed where my problem was, thanks to the filament_motion_sensor_connection_check.py program.
What I found was the movement was not being detected really at all. Checked connections, still nothing.
Unplugged the BTT sensor (while the code was still running) and saw all sorts of movement in the GPIO, which I can only attribute to 'noise' from my fingers bridging the block connector. That settled down after a few seconds.
Then I plugged the BTT back in and lo and behold, it started picking up movement. Nothing else had changed.
All I can put this down to was a bad connection or possible crosstalk from the wires being wrapped close to the Pi power cable.

This output would be INCREDIBLY helpful within the plugin interface to help diagnose, as I had to jump some hoops to get the RPi GPIO talking (https://raspberrypi.stackexchange.com/questions/60774/importerror-no-module-named-rpi) but at least I have an idea now what's going on and can see clear output.

Back in business - thanks all.

EDIT: Additionally, I've noticed I can't run the python script and the plugin activated at the same time, unfortunately. As soon as I activate the plugin the python script seems to stop picking up the GPIO and has to be unplugged/replugged in to start responding again.
This stops me from keeping a 'live' eye on the sensor as it is running during a print, so my faith in relying on it during a big print is not quite there, yet.

IMO, It causes less drag than the static spool holder that came with my CR10s Pro V2.
I printed a bearing version of the spool holder, but once the filament is through the BTT SFS, there's not much drag to be honest. Each setup would vary.

1 Like

What is the filament runout sensor connected to?

If it is the printer's control board (Marlin) you need to enable HOST_PROMPT_SUPPORT and HOST_ACTION_COMMAND for it to work. That means that the control board will tell OctoPrint to pause/restart properly.

Actually... you mention you have a popup in OctoPrint so maybe you already have that there. In which case either OctoPrint is not getting rid of the notification like it should, or the firmware is not telling it to get rid of it.

Sorry, charlie, I retracted my post in favor of one on Reddit before I saw your response. Thank you for you help.
Filament sensor is connected to octopi and using this plugin. Those settings are enabled in Marlin. Should I disable them and then I won't get anything on the TFT anymore? Yeah, it seems like hitting the button in octoprint should get rid of the one on the TFT but that isn't happening. Or, if I could configure it so I get the messages only one place and not both, that would be good too.