Sensor Si7021 not working #471
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi, I have a problem with temperature sensor.

The sensor was detected on 0x40 address but enclosure plugin showing only 0.
Disable SUDO not helped, sudo without password.
Octoprint log:
2022-01-18 17:20:20,933 - octoprint.plugins.enclosure - INFO - Failed to execute python scripts, try disabling use SUDO on advanced section of the plugin. 2022-01-18 17:20:20,933 - octoprint.plugins.enclosure - WARNING - An exception of type ValueError occurred on log_error. Arguments: ('not enough values to unpack (expected 2, got 1)',) Traceback (most recent call last): File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/__init__.py", line 1283, in read_si7021_temp temp, hum = stdout.decode("utf-8").split("|") ValueError: not enough values to unpack (expected 2, got 1)OctoPrint 1.7.2 Python 3.7.3 OctoPi 0.18.0
I had the same issue, I actually opened an issue a few posts earlier on how upgrading to Python 3 broke the sensor here. Unfortunately I've not had any responses yet.
yes, same for me
I struggled with this all night but somehow got it to work with a shotgun approach...not sure if the below worked, but I did also at the end try disabling root and then the readings started coming
sudo apt-get install build-essential libi2c-dev i2c-tools python-dev libffi-dev


sudo -H pip install cffi
sudo -H pip install smbus-cffi
sudo -H pip install Si7021
I had the same problem, and I have a temporary solution.
The log file shows the temp sensor reading tracebacks.
~/.octoprint/logs/octoprint.logFrom the trace back, it appears sensor[] variable is missing a key value for temp_sensor_i2cbus
There is a temporary solution.
But first, make sure the sensor is working by manually running the sensor script:
Note the argument: 40 is the i2c address, 1 is the i2c bus.
If you get something like
-1|-1, it means the sensor isn't working. Try a different i2c bus (i2c_address should always be 40, this is set by the sensor IC)Next, open _ _ init _ _ .py and manually hardcode the temp_sensor_address and temp_sensor_i2cbus to line 996
Change from the original:
temp, hum = self.read_si7021_temp(sensor['temp_sensor_address'], sensor['temp_sensor_i2cbus'])to:
temp, hum = self.read_si7021_temp(40, 1)Reboot Octoprint, it should now be able to read the temp and humidity.
The approach by jx2014 worked for me. I simply used putty and did:
edited the line:
temp, hum = self.read_si7021_temp(sensor['temp_sensor_address'], sensor['temp_sensor_i2cbus'])to
temp, hum = self.read_si7021_temp(40, 1)Saved the file, exited nano
sudo reboot and presto, working! Obviously an update to octoprint enclosure will delete the modification, but works for now!