Skip to content

Remote error when running as script #4

Closed
@robiwano

Description

@robiwano

I've installed all prerequisites, and I get the following when running my script read_sensor.py:

pi@raspberrypi:~/hum_temp_server $ ./read_sensor.py
Traceback (most recent call last):
  File "./read_sensor.py", line 13, in <module>
    print("\nTemperature: %0.1f C" % sensor.temperature)
  File "/usr/local/lib/python3.5/dist-packages/adafruit_htu21d.py", line 121, in temperature
    self.measurement(TEMPERATURE)
  File "/usr/local/lib/python3.5/dist-packages/adafruit_htu21d.py", line 140, in measurement
    self._command(what)
  File "/usr/local/lib/python3.5/dist-packages/adafruit_htu21d.py", line 93, in _command
    i2c.write(struct.pack('B', command))
  File "/usr/local/lib/python3.5/dist-packages/adafruit_bus_device/i2c_device.py", line 115, in write
    self.i2c.writeto(self.device_address, buf, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/busio.py", line 65, in writeto
    return self._i2c.writeto(address, buffer, stop=stop)
  File "/usr/local/lib/python3.5/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 38, in writeto
    self._i2c_bus.write_bytes(address, buffer[start:end])
  File "/usr/local/lib/python3.5/dist-packages/Adafruit_PureIO/smbus.py", line 244, in write_bytes
    self._device.write(buf)
OSError: [Errno 121] Remote I/O error

However, entering all the commands in a python3 shell works just fine... (?). Content of read_sensor.py is:

#!/usr/bin/python3
import time
import board
import busio
from adafruit_htu21d import HTU21D

# Create library object using our Bus I2C port
i2c = busio.I2C(board.SCL, board.SDA)
sensor = HTU21D(i2c)

while True:
    print("\nTemperature: %0.1f C" % sensor.temperature)
    print("Humidity: %0.1f %%" % sensor.relative_humidity)
    time.sleep(2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions