Sensor Si7021 not working #471

Open
opened 2022-01-18 16:23:08 +00:00 by Dexter0007 · 5 comments
Dexter0007 commented 2022-01-18 16:23:08 +00:00 (Migrated from github.com)

Hi, I have a problem with temperature sensor.
The sensor was detected on 0x40 address but enclosure plugin showing only 0.
image
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

Hi, I have a problem with temperature sensor. The sensor was detected on 0x40 address but enclosure plugin showing only 0. ![image](https://user-images.githubusercontent.com/45919536/149976382-97193f5b-a368-4a27-801a-692915529794.png) 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
stirlsilver commented 2022-01-19 11:45:11 +00:00 (Migrated from github.com)

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.

I had the same issue, I actually opened an issue a few posts earlier on how upgrading to Python 3 broke the sensor [here](https://github.com/vitormhenrique/OctoPrint-Enclosure/issues/466). Unfortunately I've not had any responses yet.
grahamwoan commented 2022-03-11 20:56:16 +00:00 (Migrated from github.com)

yes, same for me

yes, same for me
ghost commented 2022-05-27 06:12:12 +01:00 (Migrated from github.com)

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
Screenshot 2022-05-27 001119
Screenshot 2022-05-27 001134

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 <img width="960" alt="Screenshot 2022-05-27 001119" src="https://user-images.githubusercontent.com/80727455/170633686-950c6250-14d7-4c50-97a5-9e2c6f239e9d.png"> <img width="960" alt="Screenshot 2022-05-27 001134" src="https://user-images.githubusercontent.com/80727455/170633688-a22ea787-a2c8-489d-a392-efda451f88db.png">
jx2014 commented 2022-06-30 19:04:10 +01:00 (Migrated from github.com)

I had the same problem, and I have a temporary solution.

The log file shows the temp sensor reading tracebacks.
~/.octoprint/logs/octoprint.log

From the trace back, it appears sensor[] variable is missing a key value for temp_sensor_i2cbus

2022-06-21 15:27:11,691 - octoprint.plugins.enclosure - WARNING - An exception of type KeyError occurred on log_error. Arguments:
('temp_sensor_i2cbus',)
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/__init__.py", line 996, in get_sensor_data
    temp, hum = self.read_si7021_temp(sensor['temp_sensor_address'], sensor['temp_sensor_i2cbus'])
KeyError: 'temp_sensor_i2cbus'

2022-06-21 15:27:11,692 - octoprint.plugins.enclosure - WARNING - An exception of type TypeError occurred on log_error. Arguments:
('cannot unpack non-iterable NoneType object',)
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/__init__.py", line 811, in check_enclosure_temp
    temp, hum = self.get_sensor_data(sensor)
TypeError: cannot unpack non-iterable NoneType object

2022-06-21 15:27:12,352 - octoprint.plugins.tracking - INFO - Sent tracking event pong, payload: {'version': '1.8.1', 'os': 'linux', 'bits': 32, 'python': '3.7.3', 'pip': '21.3.1', 'cores': 4, 'freq': 1200.0, 'ram': 915714048, 'pi_model': 'Raspberry Pi 3 Model B Rev 1.2', 'octopi_version': '0.17.0', 'plugins': 'obico:2.0.1,firmwareupdater:1.13.3,enclosure:4.13.2,filamentsensorsimplified:0.3.1,ender3v2tempfix:0.0.4,bedlevelvisualizer:1.1.1'}

2022-06-21 15:27:21,693 - octoprint.plugins.enclosure - WARNING - An exception of type KeyError occurred on log_error. Arguments:
('temp_sensor_i2cbus',)
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/__init__.py", line 996, in get_sensor_data
    temp, hum = self.read_si7021_temp(sensor['temp_sensor_address'], sensor['temp_sensor_i2cbus'])
KeyError: 'temp_sensor_i2cbus'

2022-06-21 15:27:21,694 - octoprint.plugins.enclosure - WARNING - An exception of type TypeError occurred on log_error. Arguments:
('cannot unpack non-iterable NoneType object',)
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/__init__.py", line 811, in check_enclosure_temp
    temp, hum = self.get_sensor_data(sensor)
TypeError: cannot unpack non-iterable NoneType object

There is a temporary solution.
But first, make sure the sensor is working by manually running the sensor script:

pi@octopi:~/oprint/lib/python3.7/site-packages/octoprint_enclosure $ python3 SI7021.py 40 1
41.0 | 28.2

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.

I had the same problem, and I have a temporary solution. The log file shows the temp sensor reading tracebacks. `~/.octoprint/logs/octoprint.log` From the trace back, it appears sensor[] variable is missing a key value for **temp_sensor_i2cbus** ``` 2022-06-21 15:27:11,691 - octoprint.plugins.enclosure - WARNING - An exception of type KeyError occurred on log_error. Arguments: ('temp_sensor_i2cbus',) Traceback (most recent call last): File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/__init__.py", line 996, in get_sensor_data temp, hum = self.read_si7021_temp(sensor['temp_sensor_address'], sensor['temp_sensor_i2cbus']) KeyError: 'temp_sensor_i2cbus' 2022-06-21 15:27:11,692 - octoprint.plugins.enclosure - WARNING - An exception of type TypeError occurred on log_error. Arguments: ('cannot unpack non-iterable NoneType object',) Traceback (most recent call last): File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/__init__.py", line 811, in check_enclosure_temp temp, hum = self.get_sensor_data(sensor) TypeError: cannot unpack non-iterable NoneType object 2022-06-21 15:27:12,352 - octoprint.plugins.tracking - INFO - Sent tracking event pong, payload: {'version': '1.8.1', 'os': 'linux', 'bits': 32, 'python': '3.7.3', 'pip': '21.3.1', 'cores': 4, 'freq': 1200.0, 'ram': 915714048, 'pi_model': 'Raspberry Pi 3 Model B Rev 1.2', 'octopi_version': '0.17.0', 'plugins': 'obico:2.0.1,firmwareupdater:1.13.3,enclosure:4.13.2,filamentsensorsimplified:0.3.1,ender3v2tempfix:0.0.4,bedlevelvisualizer:1.1.1'} 2022-06-21 15:27:21,693 - octoprint.plugins.enclosure - WARNING - An exception of type KeyError occurred on log_error. Arguments: ('temp_sensor_i2cbus',) Traceback (most recent call last): File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/__init__.py", line 996, in get_sensor_data temp, hum = self.read_si7021_temp(sensor['temp_sensor_address'], sensor['temp_sensor_i2cbus']) KeyError: 'temp_sensor_i2cbus' 2022-06-21 15:27:21,694 - octoprint.plugins.enclosure - WARNING - An exception of type TypeError occurred on log_error. Arguments: ('cannot unpack non-iterable NoneType object',) Traceback (most recent call last): File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/__init__.py", line 811, in check_enclosure_temp temp, hum = self.get_sensor_data(sensor) TypeError: cannot unpack non-iterable NoneType object ``` There is a temporary solution. But first, make sure the sensor is working by manually running the sensor script: ``` pi@octopi:~/oprint/lib/python3.7/site-packages/octoprint_enclosure $ python3 SI7021.py 40 1 41.0 | 28.2 ``` 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.
stirlsilver commented 2022-07-06 08:47:56 +01:00 (Migrated from github.com)

The approach by jx2014 worked for me. I simply used putty and did:

cd oprint/lib/python3.7/site-packages/octoprint_enclosure
nano __init__.py

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!

The approach by jx2014 worked for me. I simply used putty and did: ``` cd oprint/lib/python3.7/site-packages/octoprint_enclosure nano __init__.py ``` 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!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Gandalf/OctoPrint-Enclosure#471