0

ADS1115 recognized by RPi, but getting errr121
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

ADS1115 recognized by RPi, but getting errr121

by blueshorts on Sat Feb 16, 2019 7:18 pm

Hello all,

I'm attempting to measure temperature using the ADS1115 and some thermistors. I installed the requisite library's for the ADS1115 and the ADS1115 is found by running "sudo i2cdetect -y 1":

0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --



When I try to run simpletest.py as an initial setup I get:

Code: Select all | TOGGLE FULL SIZE
import time
import board
import busio
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn

# Create the I2C bus
i2c = busio.I2C(board.SCL, board.SDA)

# Create the ADC object using the I2C bus
ads = ADS.ADS1115(i2c)

# Create single-ended input on channel 0
chan = AnalogIn(ads, ADS.P0)

# Create differential input between channel 0 and 1
#chan = AnalogIn(ads, ADS.P0, ADS.P1)

print("{:>5}\t{:>5}".format('raw', 'v'))

while True:
    print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
    time.sleep(0.5)


Traceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/adafruit_bus_device/i2c_device.py", line 68, in __init__
i2c.writeto(device_address, b'')
File "/home/pi/.local/lib/python3.5/site-packagetess/busio.py", line 65, in writeto
return self._i2c.writeto(address, buffer, stop=stop)
File "/home/pi/.local/lib/python3.5/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 38, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
File "/home/pi/.local/lib/python3.5/site-packages/Adafruit_PureIO/smbus.py", line 244, in write_bytes
self._device.write(buf)
OSError: [Errno 121] Remote I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/adafruit_bus_device/i2c_device.py", line 74, in __init__
i2c.readfrom_into(device_address, result)
File "/home/pi/.local/lib/python3.5/site-packages/busio.py", line 55, in readfrom_into
return self._i2c.readfrom_into(address, buffer, stop=stop)
File "/home/pi/.local/lib/python3.5/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 44, in readfrom_into
readin = self._i2c_bus.read_bytes(address, end-start)
File "/home/pi/.local/lib/python3.5/site-packages/Adafruit_PureIO/smbus.py", line 155, in read_bytes
return self._device.read(number)
OSError: [Errno 121] Remote I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/pi/Desktop/ADS1115 2-16-2019.py", line 11, in <module>
ads = ADS.ADS1115(i2c)
File "/home/pi/.local/lib/python3.5/site-packages/adafruit_ads1x15/ads1x15.py", line 75, in __init__
self.i2c_device = I2CDevice(i2c, address)
File "/home/pi/.local/lib/python3.5/site-packages/adafruit_bus_device/i2c_device.py", line 76, in __init__
raise ValueError("No I2C device at address: %x" % device_address)
ValueError: No I2C device at address: 48


The failure occurs at this step: ads = ADS.ADS1115(i2c)

Any ideas why this is happening? I've made a lot with arduino, but this is my first time using a raspberry pi. My job is data science, so I know a little coding.

Thank you for your time.

blueshorts
 
Posts: 2
Joined: Wed Jul 31, 2013 6:57 pm

Re: ADS1115 recognized by RPi, but getting errr121

by adafruit_support_mike on Sun Feb 17, 2019 2:19 am

That's usually a permissions problem. Are you sure your login account is a member of the 'gpio' group?

adafruit_support_mike
 
Posts: 57106
Joined: Thu Feb 11, 2010 2:51 pm

Re: ADS1115 recognized by RPi, but getting errr121

by blueshorts on Sun Feb 17, 2019 1:52 pm

Thank you for the reply, I think I found a way to see if I am a member of the 'gpio' group:

When I type in
Code: Select all | TOGGLE FULL SIZE
groups pi
to the terminal I get:
"
pi@raspberrypi:~ $ groups pi
pi : pi adm dialout cdrom sudo audio video plugdev games users input netdev spi i2c gpio
"
I think this means that I am a member of the gpio group.

On a side note, the code is working now, but I have no idea why. This is what happened between then and now:

I logged in as startx to see if that would help my issue (it didn't).
I rebooted the pi and was presented with a login page (I never get this).
I typed in the correct password and pressed enter, but the screen when straight back to the login page and this happened every time I entered the correct password.
While on the login page I pressed "ctrl alt f2" to get to the terminal and was able to log in that way.
I ran the code "sudo chown pi:pi .Xauthority" as per this https://raspberrypi.stackexchange.com/questions/45914/raspbian-graphical-login-screen-stuck-cant-login
Then I rebooted the pi
Then the login issue was fixed and I went straight to desktop without having a login prompt.
Then I ran simpletest.py and it worked!

Great news, but I am absolutely baffled as to what happened here.

Thank you for your assistance and for reading.

blueshorts
 
Posts: 2
Joined: Wed Jul 31, 2013 6:57 pm

Re: ADS1115 recognized by RPi, but getting errr121

by adafruit_support_mike on Mon Feb 18, 2019 12:43 am

It sounds like something got mixed up in the OS configuration.

That happens sometimes. The OS might have updated something, or there might have been a lingering side effect from some other program. Operating systems are complicated, and sometimes they just have to start over from scratch.

I'm glad to hear things are working now. Happy hacking!

adafruit_support_mike
 
Posts: 57106
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.