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

**URL:** <https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484>\
**Category:** Hardware\
**Created:** [November 17, 2015, 7:03am UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484 "2015-11-17T07:03:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![vitormhenrique](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.lulzbot.com/vitormhenrique/32/9222_2.png) [@vitormhenrique](https://forum.lulzbot.com/u/vitormhenrique)\
**Post date:** [November 17, 2015, 7:03am UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/1 "2015-11-17T07:03:17Z")

</div>

Hello Guys,

For the last week I’ve been working on a plugin for octoprint to control my enclosure.

My goal is to control a light, fans and a small heater inside the enclosure over the internet using octoprint.

I just finished the first version of the plugin.

You can find it on my [github page](https://github.com/vitormhenrique/OctoPrint-Enclosure).

Basically I use the raspberry pi GPIO to control relays and turn on / off whatever I want on my enclosure. There is plenty information on the plugin page on github. For now the plugin only works on raspberry pi.

The heater should turn off when the print is complete. The lights are specially good when you want to check your print while you are not home over the internet.

I’m using a DHT22 sensor to measure temperature and humidity inside the enclosure, a small lasko heater and a usb fan.

Few print-screens and pictures:

 ![Octoprint-Enclosure.png](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/a/adf42d58795f6a19cb38b841151698f7776a36d4.png)  
 ![IMG_1636.JPG](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/3/328aba80142a5dd0e5983c7d1361b27d0a60b94e.jpeg)  
 ![IMG_1635.JPG](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/7/767c5d10aef8d460c6e0c6a1d46afebb6386985a.jpeg)  
 ![IMG_1634.JPG](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/d/d8cb9c3faf66bbeb61b61cc30e73bab09e03111e.jpeg)

---

<div class="post-metadata">

**Author:** ![kcchen\_00](https://avatars.discourse-cdn.com/v4/letter/k/9dc877/32.png) [@kcchen\_00](https://forum.lulzbot.com/u/kcchen_00)\
**Post date:** [November 17, 2015, 10:37pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/2 "2015-11-17T22:37:45Z")

</div>

Nice! That’s is great addition to octoprint!

---

<div class="post-metadata">

**Author:** ![vitormhenrique](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.lulzbot.com/vitormhenrique/32/9222_2.png) [@vitormhenrique](https://forum.lulzbot.com/u/vitormhenrique)\
**Post date:** [November 17, 2015, 10:41pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/3 "2015-11-17T22:41:54Z")

</div>

I just figured it out a way to improve the GPIO handling without needing a root user… It will avoid possible issues.

I’ll implement / test tonight and update the plugin.

---

<div class="post-metadata">

**Author:** ![vitormhenrique](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.lulzbot.com/vitormhenrique/32/9222_2.png) [@vitormhenrique](https://forum.lulzbot.com/u/vitormhenrique)\
**Post date:** [November 18, 2015, 3:55pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/4 "2015-11-18T15:55:43Z")

</div>

Plugin updated, now i’m using wiringPi to access GPIO. So I don’t need to access GPIO pins using sudo command.

Tested the heat stabilization yesterday and could keep my enclosure on a nice 40 C. It took 10 minutes to get to the temperature.

---

<div class="post-metadata">

**Author:** ![Frank\_Furter](https://avatars.discourse-cdn.com/v4/letter/f/ed8c4c/32.png) [@Frank\_Furter](https://forum.lulzbot.com/u/Frank_Furter)\
**Post date:** [April 23, 2016, 4:08am UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/5 "2016-04-23T04:08:20Z")

</div>

> [@vitormhenrique](#):
>
> Hello Guys,
> 
> For the last week I’ve been working on a plugin for octoprint to control my enclosure.
> 
> My goal is to control a light, fans and a small heater inside the enclosure over the internet using octoprint.
> 
> I just finished the first version of the plugin.
> 
> You can find it on my [github page](https://github.com/vitormhenrique/OctoPrint-Enclosure).
> 
> Basically I use the raspberry pi GPIO to control relays and turn on / off whatever I want on my enclosure. There is plenty information on the plugin page on github. For now the plugin only works on raspberry pi.
> 
> The heater should turn off when the print is complete. The lights are specially good when you want to check your print while you are not home over the internet.
> 
> I’m using a DHT22 sensor to measure temperature and humidity inside the enclosure, a small lasko heater and a usb fan.
> 
> Few print-screens and pictures:

I just got OctoPrint running my Taz 5 remotely and am interested in building a similar enclosure with temperature & humidity control. I’m curious, how necessary is the additional heater? Have you found an optimum enclosure temp that is higher than what the heated build plate and nozzle put out?

---

<div class="post-metadata">

**Author:** ![vitormhenrique](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.lulzbot.com/vitormhenrique/32/9222_2.png) [@vitormhenrique](https://forum.lulzbot.com/u/vitormhenrique)\
**Post date:** [April 25, 2016, 3:47am UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/6 "2016-04-25T03:47:29Z")

</div>

> [@Frank Furter](#):
>
> I just got OctoPrint running my Taz 5 remotely and am interested in building a similar enclosure with temperature & humidity control. I’m curious, how necessary is the additional heater? Have you found an optimum enclosure temp that is higher than what the heated build plate and nozzle put out?

If you build a enclosure, setting the hot bed to 110C and the hot end to 240C will only heat your enclosure to about 30C, due to thermal losses, etc…

With a heater and controlling the temperature, I can easily keep the internal temperature to 50C, this help a lot when printing LARGE ABS prints, where warping would be an issue, if you want to only print small ABS or PLA you don’t need a enclosure.

Another thing to consider is that heating the environment can also make it harder to print PLA, that is why I also added a fan to my enclosure, to keep the temperature as low as possible to print PLA.

---

<div class="post-metadata">

**Author:** ![marty6000](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@marty6000](https://forum.lulzbot.com/u/marty6000)\
**Post date:** [December 7, 2016, 9:32pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/7 "2016-12-07T21:32:42Z")

</div>

Good afternoon,

Thank you for posting this code. I am running OctoPi, and was looking for a way to control a fan on an enclosure I am currently building.

I see in you pics that you have a target temperature setting… does it control both the fan and heater, or just the heater?

Thanks  
Martin

---

<div class="post-metadata">

**Author:** ![vitormhenrique](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.lulzbot.com/vitormhenrique/32/9222_2.png) [@vitormhenrique](https://forum.lulzbot.com/u/vitormhenrique)\
**Post date:** [December 7, 2016, 9:45pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/8 "2016-12-07T21:45:02Z")

</div>

It only controls the heater, there is no need to turn the fan to decrease the temperature, there are plenty of heat losses on enclosure that will make the temperature drop really quick once the heater element is off inside the enclosure. Just turning off the heater makes the temperature control very stable.

I only use the FAN to print PLA, and with the enclosure open, to cool the enclosure as I have really bad experience printing PLA on a heated chamber, I get heat creep avery single time.

You can also use the fan as a exhaust fan to remove fumes from your enclosure, but I would add a filter on the exhaust fan If you do that.

I’m about to update the code and add second fan support, because it was requested on github by a few people. I’ve keeping my enclosure at 55 C when printing large ABS prints and no warping what so ever!

Check github page for more info.

---

<div class="post-metadata">

**Author:** ![vitormhenrique](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.lulzbot.com/vitormhenrique/32/9222_2.png) [@vitormhenrique](https://forum.lulzbot.com/u/vitormhenrique)\
**Post date:** [January 4, 2017, 7:23pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/9 "2017-01-04T19:23:21Z")

</div>

I updated the code,

Now the plugin has the ability to pause the printer using a filament sensor, it can control up to 4 different I/Os with configurable names.

You can configure if the I/O should automatically shut off after printing is done.

for example, you can add a solid state relay and turn the entire print off after 30 minutes or so that your print is complete.

---

<div class="post-metadata">

**Author:** ![sajovicd](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@sajovicd](https://forum.lulzbot.com/u/sajovicd)\
**Post date:** [January 22, 2017, 11:57am UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/10 "2017-01-22T11:57:23Z")

</div>

Hello,

First would like to say thank you for you great work, this plugin is exactly what I need.

I would have some suggestion.  
It would be great if we can choose to power on some I/O when print starts if that would be possible. ( I always forgot to turn on LED lights 😊 )  
And it would be nice to have on off button on some more easier accessible place, in a system menu for example.

Well that would be nice to have but even now is a great plugin.

---

<div class="post-metadata">

**Author:** ![vitormhenrique](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.lulzbot.com/vitormhenrique/32/9222_2.png) [@vitormhenrique](https://forum.lulzbot.com/u/vitormhenrique)\
**Post date:** [January 23, 2017, 10:32pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/11 "2017-01-23T22:32:09Z")

</div>

> [@sajovicd](#):
>
> It would be great if we can choose to power on some I/O when print starts if that would be possible. ( I always forgot to turn on LED lights 😊 )

I’m going to implement this… I like the idea…

> [@sajovicd](#):
>
> And it would be nice to have on off button on some more easier accessible place, in a system menu for example.

I don’t understand this one, as it already has on/ off buttons under the enclosure plugin tab…

---

<div class="post-metadata">

**Author:** ![sajovicd](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@sajovicd](https://forum.lulzbot.com/u/sajovicd)\
**Post date:** [January 25, 2017, 5:44am UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/12 "2017-01-25T05:44:50Z")

</div>

Hello,

Sorry for late reply, was away for some time…

> I don’t understand this one, as it already has on/ off buttons under the enclosure plugin tab…

What I mean is that I have this button to show extra tabs and I dont like it.

 ![1.jpg](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/0/000dc7001c39dd6c1e3129bf0c69dfe6315c1f9c.jpeg)  
And I see in some other plugin, buttons for on/off in the system tab under restart option.  
Well that is really not so important, I just ask if it is possible to have on/off buttons somewhere easly accessible.  
 ![2.jpg](https://us1.discourse-cdn.com/flex020/uploads/lulzbot/original/2X/4/49345defbb325833b22d5cc8961bf5a1913e122c.jpeg)

---

<div class="post-metadata">

**Author:** ![Anakin](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@Anakin](https://forum.lulzbot.com/u/Anakin)\
**Post date:** [January 31, 2017, 2:34pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/13 "2017-01-31T14:34:33Z")

</div>

Hello. I have a raspberry pi 2 with octoprint image installed. Then I did the steps to install python as the previous post says Then I connect my DHT22 to the raspberry but it does works. only shows 0 in the octoprint.

This is my Sensor:

![](http://static.cactus.io/img/sensors/temp-humidity/dht22/keyes-am2302-module.jpg)

![](http://www.jameco.com/Jameco/workshop/circuitnotes/raspberry_pi_circuit_note_fig2a.jpg)

I put:  
GND to PIN 6  
VCC to PIN 4  
DAT to PIN 7

Is it correct?

---

<div class="post-metadata">

**Author:** ![vitormhenrique](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.lulzbot.com/vitormhenrique/32/9222_2.png) [@vitormhenrique](https://forum.lulzbot.com/u/vitormhenrique)\
**Post date:** [January 31, 2017, 11:45pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/14 "2017-01-31T23:45:30Z")

</div>

> [@Anakin](#):
>
> Hello. I have a raspberry pi 2 with octoprint image installed. Then I did the steps to install python as the previous post says Then I connect my DHT22 to the raspberry but it does works. only shows 0 in the octoprint.

There are many steps to trouble shoot this issue.

If you did install the adafruit library (as required per instructions on the github page), you can check if your connection is ok.

Follow the instructions on adafruit and test your wiring: [https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/software-install-updated](https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/software-install-updated)

if your wiring is ok, next step, ssh into your raspberry pi, stop octoprint using:

```plaintext
sudo service octoprint stop

```

start octopring manually using

```plaintext
/home/pi/oprint/bin/octoprint

```

take a look on the log, and look for anything that has to do with the enclosure, they will be logged with something like:

```plaintext
octoprint.plugins.enclosure - INFO - Failed to read Humidity

```

---

<div class="post-metadata">

**Author:** ![vitormhenrique](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.lulzbot.com/vitormhenrique/32/9222_2.png) [@vitormhenrique](https://forum.lulzbot.com/u/vitormhenrique)\
**Post date:** [January 31, 2017, 11:48pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/15 "2017-01-31T23:48:07Z")

</div>

> [@sajovicd](#):
>
> And I see in some other plugin, buttons for on/off in the system tab under restart option.  
> Well that is really not so important, I just ask if it is possible to have on/off buttons somewhere easly accessible.

I don’t like including buttons on the shutdown menu. It is possible to inject the html any part of the octoprint, I’ll test putting it on the control tab.

---

<div class="post-metadata">

**Author:** ![Anakin](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@Anakin](https://forum.lulzbot.com/u/Anakin)\
**Post date:** [February 1, 2017, 2:57pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/16 "2017-02-01T14:57:02Z")

</div>

> [@vitormhenrique](#):
>
> > [@Anakin](#):
> >
> > Hello. I have a raspberry pi 2 with octoprint image installed. Then I did the steps to install python as the previous post says Then I connect my DHT22 to the raspberry but it does works. only shows 0 in the octoprint.
> 
> There are many steps to trouble shoot this issue.
> 
> If you did install the adafruit library (as required per instructions on the github page), you can check if your connection is ok.
> 
> Follow the instructions on adafruit and test your wiring: [https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/software-install-updated](https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/software-install-updated)
> 
> if your wiring is ok, next step, ssh into your raspberry pi, stop octoprint using:
> 
> ```plaintext
> sudo service octoprint stop
> 
> ```
> 
> start octopring manually using
> 
> ```plaintext
> /home/pi/oprint/bin/octoprint
> 
> ```
> 
> take a look on the log, and look for anything that has to do with the enclosure, they will be logged with something like:
> 
> ```plaintext
> octoprint.plugins.enclosure - INFO - Failed to read Humidity
> 
> ```

I have this notification:

```plaintext
sudo: /home/pi/.octoprint/plugins/OctoPrint-Enclosure/extras/GetTemperature.py: command not found
2017-02-01 14:44:35,738 - octoprint.plugins.enclosure - INFO - Failed to convert to float
sudo: /home/pi/.octoprint/plugins/OctoPrint-Enclosure/extras/GetHumidity.py: command not found
2017-02-01 14:44:35,808 - octoprint.plugins.enclosure - INFO - Failed to convert to float
2017-02-01 14:44:35,810 - octoprint.plugins.enclosure - INFO - Turning heater off.

```

Doing test with Adafruit links shows that:

```plaintext
pi@octopi:~/Adafruit_Python_DHT/examples $ sudo ./AdafruitDHT.py 2302 4
Failed to get reading. Try again!

```

---

<div class="post-metadata">

**Author:** ![vitormhenrique](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.lulzbot.com/vitormhenrique/32/9222_2.png) [@vitormhenrique](https://forum.lulzbot.com/u/vitormhenrique)\
**Post date:** [February 1, 2017, 3:52pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/17 "2017-02-01T15:52:05Z")

</div>

You have two issues…

You should first the the adafruit code working, it that does not work, the enclosure will never display the temperature, try to use 22 and 11 for the parameters, test multiple times, until you get a reading, by the way I just noticed that you are using 5V on the VCC of the sensor, it should be 3.3V to use on a 3.3 device, **you can fry your raspberry pi using 5V**.

```nohighlight
pi@octopi:~/Adafruit_Python_DHT/examples $ sudo ./AdafruitDHT.py 22 4

```

```nohighlight
pi@octopi:~/Adafruit_Python_DHT/examples $ sudo ./AdafruitDHT.py 11 4

```

After you get this working you can work on the second issue, you are getting.

```nohighlight
sudo: /home/pi/.octoprint/plugins/OctoPrint-Enclosure/extras/GetTemperature.py: command not found

```

That means that you either:

- Did not download the scripts to the proper folder
- Did not gave the scripts permission the execute
- Some other weird Linux permission issue

---

<div class="post-metadata">

**Author:** ![Anakin](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@Anakin](https://forum.lulzbot.com/u/Anakin)\
**Post date:** [February 3, 2017, 6:29pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/18 "2017-02-03T18:29:05Z")

</div>

This is my connection:

GND to PIN 6 (white)  
VCC to PIN 4 (red)  
DAT to PIN 7 (green)

The dht22 module needs to work in 5v. I have other and with Arduino it works with 5v, so this is the way I connect to 5v to Raspberry.

Now I try again and I need to do

```nohighlight
pi@octopi:~ $ cd Adafruit_Python_DHT

```

then

```nohighlight
pi@octopi:~/Adafruit_Python_DHT $ sudo python setup.py install

```

I finally I obtained:

```nohighlight
Installed /usr/local/lib/python2.7/dist-packages/Adafruit_DHT-1.3.1-py2.7-linux-armv7l.egg
Processing dependencies for Adafruit-DHT==1.3.1
Finished processing dependencies for Adafruit-DHT==1.3.1
pi@octopi:~/Adafruit_Python_DHT $ cd examples
pi@octopi:~/Adafruit_Python_DHT/examples $ sudo ./AdafruitDHT.py 2302 4
Temp=22.3* Humidity=67.8%

```

OK. Now it works… FINE!!!

I need to enter in terminal this lines one by one.

```nohighlight
mkdir -p ~/.octoprint/plugins/OctoPrint-Enclosure/extras/
cd ~/.octoprint/plugins/OctoPrint-Enclosure/extras/
wget https://raw.githubusercontent.com/vitormhenrique/OctoPrint-Enclosure/master/extras/GetHumidity.py
wget https://raw.githubusercontent.com/vitormhenrique/OctoPrint-Enclosure/master/extras/GetTemperature.py
chmod +x ~/.octoprint/plugins/OctoPrint-Enclosure/extras/GetTemperature.py
chmod +x ~/.octoprint/plugins/OctoPrint-Enclosure/extras/GetHumidity.py

```

---

<div class="post-metadata">

**Author:** ![vitormhenrique](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.lulzbot.com/vitormhenrique/32/9222_2.png) [@vitormhenrique](https://forum.lulzbot.com/u/vitormhenrique)\
**Post date:** [February 3, 2017, 7:40pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/19 "2017-02-03T19:40:05Z")

</div>

> [@Anakin](#):
>
> The dht22 module needs to work in 5v.

dht22 works fine with 3.3V.

You still need to fix the second issue, because you are getting the

```plaintext
sudo: /home/pi/.octoprint/plugins/OctoPrint-Enclosure/extras/GetTemperature.py: command not found

```

- That means that you either:
- Did not download the scripts to the proper folder
- Did not gave the scripts permission the execute
- Some other weird Linux permission issue

---

<div class="post-metadata">

**Author:** ![Anakin](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@Anakin](https://forum.lulzbot.com/u/Anakin)\
**Post date:** [February 3, 2017, 7:45pm UTC](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484/20 "2017-02-03T19:45:04Z")

</div>

> [@vitormhenrique](#):
>
> > [@Anakin](#):
> >
> > The dht22 module needs to work in 5v.
> 
> dht22 works fine with 3.3V.

OK, but I connected to 5v and works fine. RBP gives 5v too. I don´t know what is better.

> [@vitormhenrique](#):
>
> You still need to fix the second issue, because you are getting the
> 
> ```plaintext
> sudo: /home/pi/.octoprint/plugins/OctoPrint-Enclosure/extras/GetTemperature.py: command not found
> 
> ```
> 
> - That means that you either:
> - Did not download the scripts to the proper folder
> - Did not gave the scripts permission the execute
> - Some other weird Linux permission issue

I did it again and NOW IT WORKS! Thanks a lot for your work!

Now I can buy leds and turn it ON or OFF with this plugin.

It only need other way more friendly.

[Next page](https://forum.lulzbot.com/t/enclosure-temperature-fan-light-control-filament-octoprint-plugin/2484.md?page=2)
