jimbobbennett/AgroHack

Having issues while running app.py

BrahmaFarmsLLC opened this issue · 10 comments

error#
Traceback (most recent call last):
File "app.py", line 15, in
bus = smbus2.SMBus(bme_pin)
File "/home/pi/EnvironmentMonitor/.venv/lib/python3.7/site-packages/smbus2/smbus2.py", line 279, in init
self.open(bus)
File "/home/pi/EnvironmentMonitor/.venv/lib/python3.7/site-packages/smbus2/smbus2.py", line 308, in open
self.fd = os.open(filepath, os.O_RDWR)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'

Code snippet --

Configuration parameters

bme_pin = 1
bme_address = 0x76
moisture_pin = 2
led_pin = 16

Create the sensors

bus = smbus2.SMBus(bme_pin)
calibration_params = bme280.load_calibration_params(bus, bme_address)

moisture_sensor = GroveMoistureSensor(moisture_pin)

Are you running the latest version of Raspbian Buster? Are you use the same hardware?

I get the issue if I2C is turned off. Turning it on and the problem goes away.

Are you definitely turning it on using raspi-config?

you are correct, just turned it on seems to resolve one issue
this worked -- bus = smbus2.SMBus(bme_pin)

now having issues with the below module
calibration_params = bme280.load_calibration_params(bus, bme_address)

Traceback (most recent call last):
File "app.py", line 16, in
calibration_params = bme280.load_calibration_params(bus, bme_address)
File "/home/pi/EnvironmentMonitor/.venv/lib/python3.7/site-packages/bme280/init.py", line 153, in load_calibration_params
compensation_params.dig_T1 = read.unsigned_short(0x88)
File "/home/pi/EnvironmentMonitor/.venv/lib/python3.7/site-packages/bme280/reader.py", line 40, in unsigned_short
return self._bus.read_word_data(self._address, register) & 0xffff
File "/home/pi/EnvironmentMonitor/.venv/lib/python3.7/site-packages/smbus2/smbus2.py", line 453, in read_word_data
ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 121] Remote I/O error

Have you plugged the sensor into the correct socket?

Just to double check - it's a Grove BME280 Temperature/Pressure/Humidity sensor, plugged in to the bottom left I2C socket. Bottom left being the I2C sockets are on the bottom, so it's the first socket.

Are the cables in firmly on both sides?

Traceback (most recent call last):
File "SoilTemperatureSensor.py", line 1, in
from sensors.BaseSensor import BaseSensor
ModuleNotFoundError: No module named 'sensors'

How to resolve this?

The code is here.

@anurag-0-1-a - that code is in a different project. Wouldn't it be better to raise an issue there?