I have a filament sensor connected to the pi. The switch is wired as normally closed, filament is present, so when the filament runs out the switch opens. I have tested it for continuity and it is good. I have test the voltage across the the Pi GPIO pins and that operates properly also. If I set the plugin for normally closed Octoprint ignores the state of the switch. While printing I can open and close the circuit continually and it keeps on printing. If I set the plugin for normally open and keep the circuit open it will print. If I close it during print it will pause. Also if the switch is closed I can't start a print either. This does not make sense. Why will it work in normally open mode but not normally closed mode?
How did you wired up the switch? From the GPIO pin to ground? Then keep in mind, that you have to activate the pull up resistor.
BTW: What plugin do you use for this on the Pi?
Filament Sensor NG. GPIO to ground. I assumed that as part of the plugin install that the pull up would be activated. I have a Pi 3b and remember reading that the pull up resistors are activated by default.
I have just read from the raspberry pi forum that upon boot up the first 8 GPIO pins are automatically set with pull up resistors enabled and the rest with pull down enabled. This is new information for me. I have been connecting to pins 10 and up. Now I will have to try 1-8 later and see what happens.
Still having problems getting this to work.I have tried Filament sensor, filament sensor reloaded and filament sensor NG plugins. None of them will work. I check the API for the filament sensor and it always state filament present weather the switch is open or closed and doesn't seem to matter which pin I assign it. I am also running the PSU Control plugin and I'm wondering if that is interfering with the operation of the filament sensor being properly read.
I also have this same issue on all three of the filament plugins. I checked the voltage at the pin an it is already at 3.5 volts with nothing attached to it. I already killed one Pi trying to figure this out so I am switching to using the smoothieware option and having it pause it for me. If anyone has any helpful help I rather use the pi VS the printer BD
I will try to help. I was able to get Filament Sensor NG to respond to my filament sensor. You need to know how your sensor works, the pins you will connect to and the proper set up of the plugin. My sensor works with a snap switch with a roller on it. These switches generally have three terminals. One is a common, you need a wire attached to this terminal. Of the other two, one is normally open and the other is normally closed. I would suggest using the normally closed part as this will give proof your circuit is complete. If you have a broken wire or bad connection you will get a no filament indication. If you use a normally open contact and have a broken circuit you will not get a no filament indication. I have my sensor switch connected to ground and BCM(8) physical pin #24.
The plugin settings for me PIN 8, Poll time 250ms, Event Confirmation 1, Switch Type NC, Board Pin Type BCM mode. Make sure the box on the bottom, Pause print when filament is out, is checked. This should electrically work and should be read by Octoprint. Also check the Debug box. You will need to add GCODE to the GCODE scripts section under the printer heading. You will find a section to tell your printer what to do "After print job is paused" and "Before print job is removed". These are something you have to figure out as there are slight variations between printers. Search the internet and you will find a lot of examples, you have to find what works for you. You will probable need to experiment with this.
If you installed multiple filament plugins you may have to edit the Octoprint configuration file, config.yaml, in order to get it to work.