🇺🇦 We stand with Ukraine! 🇺🇦

New to OctoPrint and missing something basic i think!

Hi all, New to 3D printing and new to Octoprint, have had a couple of great test prints so far but now need to expand the capabilities.
So I'm running on a RPi 4 and want to add a temp sensor for the enclosure. I have attached an AM2302 to the Pi (pins 1,7,9) and followed the install instructions for "Enclosure Plugin (4.13.1)" but I'm stuck at the point you run the setup.
I get the error

Traceback (most recent call last):
File "setup.py", line 1, in
from setuptools import setup, find_packages, Extension
ImportError: No module named setuptools

I think this is because the instructions specifically say " Note: All libraries need to be installed on raspberry pi system python not octoprint virtual environment."

I have no idea how I do this - Help !!!, well detailed instructions would be great :slight_smile:

So if you're doing it in the system rather than OctoPrint's virtual environment you may need to install additional dependencies. This command should install setuptools.

python -m pip install --upgrade pip setuptools wheel

Hello @Ant73!

You need a driver for the AM2302. The enclosure plugin github site gives information on that

Its the installation of said driver Im struggling with :slight_smile:

Not sure, I'm using PuTTY to login to the Pi, but don't know if im in the Octoprint or system environment - how do I tell ?

If you don't go into the /home/pi/oprint/bin folder you are not in the octoprint virtual environment. Not sure if you have to use sudo with that command to truly system level or not.

If you are already running Python 3, you need another driver:

Hi guys!

I'm here struggling with the same problem. Suddenly my two AM2302 stopped working after moving to Octoprint pure Python 3 version. Not sure about what happened, since I'm not a specialist on Linux, even in Python.
I followed all the steps suggested above. I've already reinstalled Octopi from scratch twice, the second one not making the upgrade.
I input the following commands:

cd ~
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo apt-get update
sudo apt-get install build-essential python-dev python-openssl
sudo python setup.py install

When I go to test them, with the following command:

cd examples
sudo ./AdafruitDHT.py 2302 10 (my sensors are on GPIO 10, 11 and 27)

I get the following error:

pi@octopi:~/Adafruit_Python_DHT/examples $ python AdafruitDHT.py 2302 10
Traceback (most recent call last):
  File "AdafruitDHT.py", line 41, in <module>
    humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
  File "/usr/local/lib/python2.7/dist-packages/Adafruit_DHT/common.py", line 94, in read_retry
    humidity, temperature = read(sensor, pin, platform)
  File "/usr/local/lib/python2.7/dist-packages/Adafruit_DHT/common.py", line 81, in read
    return platform.read(sensor, pin)
  File "/usr/local/lib/python2.7/dist-packages/Adafruit_DHT/Beaglebone_Black.py", line 213, in read
    raise RuntimeError('Error accessing GPIO. Make sure program is run as root with sudo!')
RuntimeError: Error accessing GPIO. Make sure program is run as root with sudo!

Any help is welcome.
Thanks and regards

Instead of sudo python setup.py install try sudo python3 setup.py install. That's the command you want to use to install using Pyhon 3. But you you man also have to run:

sudo apt-get install python3-pip
sudo python3 -m pip install --upgrade pip setuptools wheel

according to the libraries github repo. You can then install with:
sudo pip3 install Adafruit_DHT

1 Like

@ryan780 , thank you for your answer. I followed all steps you have indicated but, unfortunately, it didn’t work. Still not able to run it properly neither appearing in Octopi enclosure plug-in.

pi@octopi:~/Adafruit_Python_DHT/examples $ sudo python3 AdafruitDHT.py 2302 10
Traceback (most recent call last):
  File "AdafruitDHT.py", line 41, in <module>
    humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_DHT/common.py", line 94, in read_retry
    humidity, temperature = read(sensor, pin, platform)
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_DHT/common.py", line 80, in read
    platform = get_platform()
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_DHT/common.py", line 60, in get_platform
    from . import Beaglebone_Black
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_DHT/Beaglebone_Black.py", line 24, in <module>
    from . import Beaglebone_Black_Driver as driver
ImportError: cannot import name 'Beaglebone_Black_Driver' from 'Adafruit_DHT' (/usr/local/lib/python3.7/dist-packages/Adafruit_DHT/__init__.py)

As additional information, it's running on a Raspberry Pi 4B 4GB.
The sensors are good because I’ve checked them on a Raspberry Pi 3 with Debian on it. If I cannot manage to make it work on Octopi, I will install full Debian and will later install Octoprint on it. I need the sensors working because I built an enclosure for my printer and a fan is activated based on them in order to control internal temp.

Are you sure that the sensor is connected to Pin 10? Are you using physical number of BCM numbering?

In either case, it seems the adafruit library isn't installing correctly.

Not necessarily. I don't know what this adafruit library does if no sensor is hooked up. I know that the Adafruit libraries for ESP8266 libraries for Arduino will usually cause a hard reset due to a hardware watchdog. I haven't experimented enough with the python libraries to know how "graceful" they are at error recovery. And I know that there is error recovery in the code but I can't say for certain that it works. :slight_smile:

Also, do you have this pin assigned to anything in OctoPrint or anywhere else? Don't want to have a pin definition conflict. If you are going to run the adafruit example script, I would stop the octoprint service to avoid any conflicts.

I got it to work with Python 3 following this page:

It seems to be a different driver from the previous Adafruit. As I previously stated, I'm not an expert on codes. I do it mainly based on trial and error and from some knowledge I got working on other programming languages.

Anyway, nothing is still appearing in the Enclosure plugin, but at least now I can control my fan via python 3 running a program I created in Python and translated to Python 3.
Thanks for the tips.

Are you sure that the sensor is connected to Pin 10?

Yes, I'm! Only using references to GPIO connectors. They were working before. So suddenly stopped after some update. I thought it was after jumping for full Python 3 Octoprint but I'm not sure the exact point where they were lost.

I know you're talking about the GPIO pins. There are two numbering schema for them, the physical (or board) numbering and BCM numbering. As you can see in this picture:


Physical pin 10 and GPIO.10 are NOT the same pin. So, again, I will ask, are you using BCM numbering or physical numbering?

1 Like

Hi, Ryan!
I’m using BCM numbering. I used them before with Enclosure plug-in. Has it changed? Now I’ve started thinking if maybe I could try the board numbers just to check if it works.