Enclosure Temperature / Fan / Light Control / Filament - Octoprint Plugin

Excellent! That is exactly what I needed. Thank you for adding this. I will give it a try tonight. What is the best way to update it?

Octoprint should detect a new version available under the software update.

For some reason Octoprint was not detecting the update. I downloaded the .zip from github and manually installed it.

I’m not having much luck with the filament sensor. If I enable it, it continually thinks the filament sensor is tripped regardless of whether filament exists, and the active low setting. To clarify, when filament runs out of my current sensor, it sends GND the the pin. When filament is in the tube, the pin is not high or low (nothing).

With the Filament Sensor Reloaded plugin that works, it pulls the pin high, and when my sensor puts it low it triggers a pause. It works flawlessly so I know the sensor is good.

I just tested on my rPI and it is working… we may need to trouble shoot your setup. Are you using BOARD or BCM pin numbers? I’m thinking that my changes to use BOARD pin numbers were not perfect…

could you remove other plugins that use GPIO, including the enclosure plugin, install it again and use BCM pin numbers? I’m also pulling the pin HIGH when the event is not detected, so it is fine for your sensor keep the signal floating.

After you re-install everything, do the following: log on your raspberry pi (ssh) and stop the service with:

sudo service octoprint stop

Then start it with:

/home/pi/oprint/bin/octoprint

Enable the debug under the settings, you will be able to see all the logs, and we can try to figure it out what is wrong.

I have made a clone of my Octoprint Server for testing this. I do not have a printer or temp sensor connected. I only have my filament sensor connected on Pin# 7(BOARD) / GPIO 4 (BCM).

I have removed all plugins using GPIO from Octoprint and reinstalled only your Enclosure plugin 1.6. Regardless of what scenario I try using variations of the Active Low checkbox, Board type checkbox, and 4/7 pin number, I can not get it to work. A couple things I’d like to confirm.

I log in through my terminal, stop and restart Octoprint so I can see the boot-up sequence and debug info. In your Enclosure Plugin debug mode, should I see a debug message when the sensor is tripped and the printer is paused? Is it obvious? This is what I am using for reference when troubleshooting.

I believe the correct Enclosure plugin settings for my sensor wiring should be:

Pin Number: 4
Active Low: Checked
Use Board Pin: Unchecked

When I use these settings, I can use “gpio -g readall” and see my pin is pulled high (reads 1), and that removing the filament reads 0.

Here is the log at start if it helps:

2017-03-02 16:38:34,139 - octoprint.server - INFO - Starting OctoPrint 1.3.1 (master branch)
2017-03-02 16:38:34,263 - octoprint.plugin.core - INFO - Loading plugins from /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.1-py2.7.egg/octoprint/plugins, /home/pi/.octoprint/plugins and installed plugin packages...
2017-03-02 16:38:36,638 - octoprint.plugin.core - INFO - Found 9 plugin(s) providing 9 mixin implementations, 6 hook handlers
2017-03-02 16:38:36,686 - octoprint.plugin.core - INFO - Loading plugins from /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.1-py2.7.egg/octoprint/plugins, /home/pi/.octoprint/plugins and installed plugin packages...
2017-03-02 16:38:37,105 - octoprint.plugin.core - INFO - Found 9 plugin(s) providing 9 mixin implementations, 6 hook handlers
2017-03-02 16:38:37,116 - octoprint.filemanager.storage - INFO - Initializing the file metadata for /home/pi/.octoprint/uploads...
2017-03-02 16:38:37,593 - octoprint.filemanager.storage - INFO - ... file metadata for /home/pi/.octoprint/uploads initialized successfully.
2017-03-02 16:38:37,777 - octoprint.plugins.softwareupdate - INFO - Loaded version cache from disk
2017-03-02 16:38:40,668 - octoprint.util.pip - INFO - Using "/home/pi/oprint/bin/python -m pip" as command to invoke pip
2017-03-02 16:38:43,582 - octoprint.util.pip - INFO - Version of pip is 8.1.1
2017-03-02 16:38:43,585 - octoprint.util.pip - INFO - pip installs to /home/pi/oprint/lib/python2.7/site-packages, --user flag needed => no, virtual env => yes
2017-03-02 16:38:43,591 - octoprint.plugin.core - INFO - Initialized 9 plugin implementation(s)
2017-03-02 16:38:43,604 - octoprint.plugin.core - INFO - 9 plugin(s) registered with the system:
|  Announcement Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.1-py2.7.egg/octoprint/plugins/announcements
|  Core Wizard (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.1-py2.7.egg/octoprint/plugins/corewizard
|  CuraEngine (<= 15.04) (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.1-py2.7.egg/octoprint/plugins/cura
|  Discovery (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.1-py2.7.egg/octoprint/plugins/discovery
|  Enclosure Plugin (1.6) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_enclosure
|  Fullscreen Plugin (0.0.1) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_fullscreen
|  Plugin Manager (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.1-py2.7.egg/octoprint/plugins/pluginmanager
|  Software Update (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.1-py2.7.egg/octoprint/plugins/softwareupdate
|  Virtual Printer (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.1-py2.7.egg/octoprint/plugins/virtual_printer
2017-03-02 16:38:43,610 - octoprint.filemanager - INFO - Adding backlog items from all storage types to analysis queue...
2017-03-02 16:38:43,633 - octoprint.filemanager - INFO - Added 0 items from storage type "local" to analysis queue
2017-03-02 16:38:43,639 - octoprint.server - INFO - Reset webasset folder /home/pi/.octoprint/generated/webassets...
2017-03-02 16:38:43,665 - octoprint.server - INFO - Reset webasset folder /home/pi/.octoprint/generated/.webassets-cache...
2017-03-02 16:38:44,377 - octoprint.plugins.discovery - INFO - Registered OctoPrint instance on octopi for _http._tcp
2017-03-02 16:38:44,398 - octoprint.plugins.discovery - INFO - Registered OctoPrint instance on octopi for _octoprint._tcp
2017-03-02 16:38:44,404 - octoprint.plugins.discovery - INFO - Registered OctoPrint instance on octopi for SSDP
2017-03-02 16:38:44,436 - octoprint.plugins.pluginmanager - INFO - Loaded plugin repository data from disk, was still valid
2017-03-02 16:38:44,477 - octoprint.server - INFO - Listening on http://0.0.0.0:5000
2017-03-02 16:38:44,811 - octoprint.server - INFO - Preemptively caching / (ui _default) for {'query_string': 'l10n=en', 'path': '/', 'base_url': 'http://192.168.254.153/'}
2017-03-02 16:38:59,059 - octoprint.server - INFO - Preemptively caching / (ui _default) for {'query_string': 'l10n=en', 'path': '/', 'base_url': 'http://192.168.0.26/'}
2017-03-02 16:39:04,880 - octoprint.server - INFO - Preemptively caching / (ui _default) for {'query_string': 'l10n=en', 'path': '/', 'base_url': 'http://192.168.254.155/'}
Traceback (most recent call last):
  File "/home/pi/.octoprint/plugins/OctoPrint-Enclosure/extras/GetHumidity.py", line 23, in <module>
    temperature = temperature * 9/5.0 + 32
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
2017-03-02 16:39:08,232 - octoprint.server.util.sockjs - INFO - New connection from client: 192.168.0.54
Traceback (most recent call last):
  File "/home/pi/.octoprint/plugins/OctoPrint-Enclosure/extras/GetTemperature.py", line 23, in <module>
    temperature = temperature * 9/5.0 + 32
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
2017-03-02 16:39:22,965 - octoprint.plugins.enclosure - INFO - DEBUG -> Reading temperature stdout: <open file '<fdopen>', mode 'rb' at 0x71ffc1d8>
2017-03-02 16:39:22,968 - octoprint.plugins.enclosure - INFO - Failed to read Temperature

From what you are getting it looks that the sensor is working fine.
My sensor routine should only get “engaged” after you start a print job.

What happens after you start a print? Will it automatically pause?

Ah, ok. I am at the office right now and only have a the Pi and Sensor here. I will try it tonight when I get home.

Another question… When the filament sensor is triggered, what specifically does it do? ie does it run an M600 command? Does it only Pause the print?

Thanks Vitor

Now I’m only pausing… I can improve that and use the M600 command. Let’s figure it out first if it is acutally working on a different setup than mine and we can change to use M600.

Here are my troubleshooting results…

Pin: 4 / Active Low: Checked / Use Board#: Unchecked
The printer goes into “Detected end of filament” completely randomly. The last time I tried, the print ran for 5 minutes, and then went into “Detected end of filament” while there was still filament in the sensor. My assumption was it was either looking at the wrong pin, or it didn’t like the floating pin from my sensor. I pulled up my #4 pin to 3.3V with a 10k resistor and tried it again. Still completely interment. Do you think it is looking at the wrong pin?

Pin: 4 / Active Low: Checked / Use Board#: Checked
Printer ran continuously regardless of filament sensor (ignored it)

Pin: 7 / Active Low: Checked / Use Board#: Unchecked
Printer ran continuously regardless of filament sensor (ignored it)

Pin: 7 / Active Low: Checked / Use Board#: Checked
Printer ran continuously regardless of filament sensor (ignored it)

Pin: 27 / Active Low: Checked / Use Board#: Unchecked <- Tried a different Pin
Same as first one - The printer goes into “Detected end of filament” completely randomly. Many times before leveling even starts.

Ok, so let’s first clarify something, on the attached picture they are the pins inside the round circle. BCM numbers are the numbers from the processor, they have names like “GPIO14”. For example GPIO4 is the Board pin number 7. When you say pin 4, do you mean GPIO4?


Never the less I think there was an issue when changing between BOARD numbers and BCM numbers, making switching between the two not possible. I was also setting up pins not being used, so if you had the same GPIO multiple times on the configuration it would cause issues. And I THINK I could reproduce your error and finally fixed.

Another thing is don’t use GPIO4. It is “locked” to be used on the temperature sensor. I guess I need to document this ( :confused: )

Sorry for the confusion. I have been using Pin# 7(BOARD) / GPIO 4(BCM) - for no other reason than it was the one I initially used with the “Filament Sensor Reloaded” plugin.

In regards to using the pin in multiple spots in the configuration, I assumed this much. I use pin 24 for my temperature sensor and when I tried pin 27, I changed IO4 to a different number. I never had the same pin number in 2 spots.

I’ll try the new updates and report back - fingers crossed!

You got it! I was prepared to do an hour or more of troubleshooting and it worked right off the bat, nice job Vitor!

Settings that worked: GPIO 27 / Active Low: Checked / Use Board#: Unchecked

I want to run a couple prints to confirm that the everything is working and it is not a pin floating in my favor, but I am 99% sure you resolved the issue!

UPDATE:
One thing I noticed, is that with “Filament Sensor Reloaded” It would use my Pause Script under Settings->Gcode Scripts->After print job is paused

my gcode Pause Script:

M300 S400 P250
M300 S500 P250
M300 S600 P250
M600

I have 3 obnoxious beeps programmed in there, and for some reason your plugin doesn’t seem to use those beeps. Is your plugin supposed to use that script? Ie are you sending a gcode pause to printer or a python command to Octopront to pause?

Finally! :unamused:

_That is weird, I’m using the same pause command as the filament reloaded:

https://github.com/kontakt/Octoprint-Filament-Reloaded/blob/master/octoprint_filamentreload/init.py#L59

https://github.com/vitormhenrique/OctoPrint-Enclosure/blob/master/octoprint_enclosure/init.py#L173

we are both sending self.printer.toggle_pause_print().

But I like your idea of implementing custom gcode, with M600. I never used it, so I want to test it before implementing… What happens when you send the M600 command? do I need to send with a Z height? like M600 Z50? Does it work for lulzbot taz 5 / 6/ and mini?

Implementing custom GCODE I can enable and disable beep on the configuration screen.

I love the idea of replacing the pause with a custom code option. That would allow quite a bit of versatility, even outside a filament sensor.

The M600 works awesome for me; the problem is using pause to trigger it. Using pause requires me to press Resume in the Octoprint GUI which is redundant and potentially effects the print quality if there is any ooze. M600 requires me to push the button on the printer to ‘Resume’ so there is no need to Resume a second time in Octoprint. I’d like the printer head to immediately go back to printing without delay. I have a TAZ 6 - I’m not sure about the TAZ 5.

Maybe a small text area where we can interject several lines of gcode we want on a filament sensor trigger (that doesn’t use pause). This would also allow others who can’t use M600 to write any custom code they want for when there printer runs out of filament.

What happens when you send the M600 command?

It does everything… Moves the Z Axis, moves to the front corner of the printer, empties (retracts rapidly) the filament, and pauses the machine. Then after you put the new filament in and press the button, it moves back to print.

Does it “prime” the new filament? should you push the new filament all the way inside, do a small extrusion manually ? I have a Taz 5 and one Taz 6. I can test on both tonight.

Does it “prime” the new filament? should you push the new filament all the way inside, do a small extrusion manually ? I have a Taz 5 and one Taz 6. I can test on both tonight.

It does not prime it, I typically push the filament in until I see a teeny-tiny bit of plastic come out of the nozzle.

I made the necessary changes to allow custom GCODE when filament end detection is triggered but I don’t have either my raspberry pi or printers now… I’ll test tonight before pushing the changes to the master branch.

If you want to give a test you can manually install using the dev branch:

https://github.com/vitormhenrique/OctoPrint-Enclosure/archive/dev.zip

I also made some changes to avoid reading temperatures when there is no sensor attached. Do you guys feel like the plugin grew to much and I should change the name for something else?

Awesome! I’ll try it soon as I get home!

I am using it for an enclosure, so it has the perfect name for me, however, some people may not look past the Enclosure title. It is capable of much more than what the current name implies. I just posted your plugin’s link for someone the other day on Thingiverse who wanted to be able to remotely turn their printer power on and off.

Maybe something like: Relay Controller & Sensor Monitor or Temperature / Filament Monitor & Relay Controller
. Then in the plugin’s description list all the various ways it can be used?

2.1 Dev version is installed, but I do not see any area for gcode under the plugin settings. Is it somewhere else?

It should be on the bottom of the settings screen…

Maybe tour browser is caching the page? Try refreshing and cleaning the cache.