Setting up Filament Runout Sensor

Hi,

I'm having a hard time setting up the filament runout sensor of my printer with octoprint. I'm running otopi 0.15.1 and octoprint 1.3.10 on raspberry pi zero W. The sensor I'm using is this one:

I have double checked the wiring and connections. If I don't have installed or if I disable the "Filament Sensor Reloaded" Plugin the printer works fine and everything is ok. If I enable this plugin the printer start jittering during printing and filament sensor does not work when running out of filament. The plugin is set as pin number 7, normally open and board mode.

Why it's behaving like this?

I assume that there are two pins involved, pin 7 and another for ground. One of the classic problems could be the two (or more) designations of pins: "board" or "bcm".

When I choose a pair, I usually go for a pin I can use that's next to a ground pin.

BCM 7: board pin 26 and board pin 25, for example
BCM 4: board pin 7 and board pin 9, for example

So if you say "pin 7" that could mean two different things. And of course, if you're not using the printed numbers on the Pi since they're too small, make sure that you're counting correctly from the correct end of the 40-pin header and from the top side of the board.

I'm pretty sure there's more than one filament runout plugin so it would be better to know which one you chose.

And yet, I see that the connector side of that has three wires (normally-closed, ground, normally-open). In a case like this, you'd want to decide for example that having filament present closes the normally-open side of this switch. I would use a multimeter on the resistance setting to see which side is a short to ground when filament is inserted. Let's assume that this is the red/green pair of wires. Then you'd want to make sure that the connector adjacent to the red wire is connected to whichever one of these is supposed to be pin 7. Then the connector associated with green should be connected as well to a ground pin on the Raspberry.

I setup mine without issue, actually works really well!

Use a digital multimeter and check to make sure the switch inside is properly working. If you can open it up, verify its soldered, and the switch isn't broke. Also are you feeding the direction it states? I have no clue why it would matter, as they should have used a roller type limit switch for bi directional operation.

They, thanks for your answer. When I say pin number 7 I refer to the Board Mode pins not BCM. So pin 7 in Board mode stands for GPIO4 and next to it there is pin 9 board mode witch stand for GND.
This switch has 3 pins. Black goes to Vcc that is 3.3V on pin 1 board mode, green is GND and goes to pin 9 board mode and red is signal and goes to pin 7 board mode. As you see, I have choose signal and gnd pin one next to the other and i was carefull not to switch them.

So the connections are all good but well... this is not working. What s weird is everytime I enable this plugin and start printing, the printer is jittering and not printing well. When I disable it all gets back to normal. So how this plugin can have an influence on printing quality.
I ll make a test tmr and i ll enable the plugin but I won t connect the pins from the sensors to raspberry. This will give me a clue if the problem is from bad wiring (witch i don t think couse i checked them 10 times) or not.

I have more than one sensor so yes I switch 3 of them to be sure that one is not broken. But I see the sensors are good since when the filaments is present the blue led inside the sensor is light up and when I remove the filament the blue light is off.

What kind of raspberry do you use? What pins do you use from the board mode? What s the version of Octopi and what s the version of octoprint? Since you have the same type of sensor do you run it normally close or open in the plugin?

This is what I'm hearing you say.

And here is what I'm seeing for the connectors (noting that I can't see the hidden one):

09%20AM

And we still need to know which of the filament runout plugins you are using.

Exactly. This is exactly how I wired everything. Don t worry about the 3wire connector from the picture, i have cut it and solder the wires directly on the raspberry pi zero w board.
As I said in my topic the plugin that i m using is "Filament Sensor Reloaded"

What do you get if you run this?

http://octopi.local/plugin/filamentreload/status

For what it's worth, I'm not convinced that the author of this plugin wanted you to include 3.3V to anything. The average SPDT (single-pole, double-throw) switch has a common ground in the center and two options. If you rock the switch one way, it will be connected from red/green in your case. Rock the switch in the opposite way and it will be connected from black/green.

I'd guess that just using the red/green connectors from your switch on board pins 7 & 9 will be all that's necessary. It's possible that the black wire connecting to 3.3V is then shorting the data logic 3.3V on your Pi to ground whenever there isn't filament inserted. The likely effect would be to put your Raspi into an undervoltage condition but I'm just guessing. It's also possible to fry your Raspberry but I'm not sure what the internal workings of the GPIO pins are.

1 Like

So I did what you said and i have disconnected the 3.3V pin of the Filament sensor from the raspberry and now the sensor is working. When I run out of filament the printer pause.

BUT

After it goes to pause position a big message appear and says SERVER IS OFFLINE. Attempt to reconnect. And also I don't now why enabliong this plugin makes the printer jittering. It's not printing as it should do at all.

I guess at this point, create an issue on the plugin author's repository and ask for advice there.

Don't forget to run http://octopi.local/plugin/filamentreload/status both with and without the filament installed to verify that it changes state as you expect.

I can't believe this. I lost 3 days with this. All because of a bad wire. During my testings I have changed only the sensor not the wires also. And then I have checked with a multimeter the "bad wire". And the multimeter said It was good. But It was not. Because today I had the ideea to change everything the wire and the sensor. And It worked. I can't believe this. I have checked with the multimeter. Maybe during movements it change in a position where it's introducing bad noise on raspberry.

1 Like

Connections are only as good as their weakest point.

"I have not failed. I have only found 10,000 ways that won't work."
~ Thomas Edison

A good technique that I employ is to use alligator clips to my multimeter and have that set on the beep=continuity setting. With everything plugged in, I would wiggle the filament, wiggle the connections on both ends of all the wires. This is how you find intermittent connections and—in the case of soldered components—something called "cold solder joints".

Yeah and printers move a lot so that would explain things in your case.

This thing becomes weird. So when I was testing new sensor with new cable everything was ok. Then I mounted all the setup on the printer. I was carefull not to tight too much with zips the cable to not struggle it. Furthermore, I directly soldered the sensor cables to the raspberry pi board in order to eliminate bad connections. I have experience on soldering I trile check not to make a cold joint.

I give it another shot and gues what. The sensor is working but the printer in jittering. It's like raspberry do not send commands in real time to the printer board. I looked up in terminal and I saw commands like "communication timeout" and "printer goes from printing to pause state" -that moment printer was paused. If i hit resume, same behavior for 2 3 minutes and again, it goes to pause position. So it's a kind of mixture of false detection and raspberry having a hard time sending in real time commands to printer board. I also increase Debounce Time to 1000 ms but nothing. now I'm thinking it is the raspberry pi board itself.

If I dasable this plugin, everything back to normal, the printer is printing amaizing. As soon as I enable it, problems starts. So maybe it's not the raspberry board.

Maybe you want to try one of the other filament sensor plugins...

Or minimally, review the existing one's Issues page to see if others are seeing this, too.

If there s a plugin problem, why did it worked when I had the filament outside? I have tried with Sebsor filament, Sensor filament Reloaded and Filament Sensor NG plugins and it behaved the same. Maybe it s the pi itself. I ll change the pi to see what will haplend.

Another option I was thinking is maybe I have some interference problem. Sensor cable is wrapped with wires from extruder, fans etc.

It's entirely possible that it's your filament switch itself.

If you have one, just rig up a simple rocker switch and fake it. Pretend to be the filament switch. See if OctoPrint continues without stuttering. If so, then it's that switch you bought. If OctoPrint still stutters, then it's possible that the plugins all have problems, that your Raspberry Pi is underpowered or that you possibly fried the Pi earlier.

I hate it and I m sick of it. I have changed the pi board and also put a new cable with new sensor. This time I did not mount the cable and sensor on the printer and the printer did not jitter on printing. This makes me think it's a real problem of interference.
But now the problem is the next one. I mimic the out of filament from sensor, i insert again the filament and when I press resume octopi return " Server is offline". And everything goes down. Ok, I understand the problem with interferences but what is this now? Why do octopi restart?

I feel for you. There are days when you really bang your head on the table, it's that frustrating.

Simple SPDT switches only connect (short) two pins together and it doesn't switch that fast nor have enough power behind it to cause electromagnetic noise to get in the way of anything else. (Your printer's stepper drivers/motors do but that's a different story. That's why a good serial cable has either internal metallic shielding or a ferrite core around it.)

So I don't think this is a case of electrical interference as caused by a filament switch.

Any plugin has the ability to otherwise interfere with OctoPrint's normal functioning, though. This is especially the case if it hooks into the gcode streaming and adds delays to the process (or doesn't return program control at all).

Things we know

  • You changed the sensor with a new one
  • You changed the sensor cable
  • You likely now have paid more attention to any connections/connectors which were intermittently-connected, especially when the printer is printing
  • You've tried more than one filament runout sensor plugin
  • For the Sensor Filament Reloaded plugin, you've used the http://octopi.local/plugin/filamentreload/status page to return the status of the switch, confirming that it's behaving
  • You know the difference between BOARD and BCM numbering schemes
  • You have a multimeter and know how to use it
  • By NOT mounting the cable to the chassis of the printer, it's happier (but this suggests that it still could be the cable ends as well, if they're being slightly disconnected somehow or if vibrations during a printout can make/break those connections)

I mimic the out of filament from sensor, i insert again the filament and when I press resume octopi return " Server is offline".

I'm not sure if I follow you here. Have you replaced the sensor with a rocker switch?