I2C error with ADS1115 (read_i2c_block_data)

2.4k views Asked by At

i have a trouble with an ads1115 (under raspberry pi). Here is my python code

import smbus
bus = smbus.SMBus(1)
address = 0x49
print bus.read_byte(address)
print bus.read_i2c_block_data(address, 0x00, 2)

and the follwing issue:

17
Traceback (most recent call last):
  File "test.py", line 8, in <module>
    data = bus.read_i2c_block_data(address, 0x00, 2)
IOError: [Errno 121] Remote I/O error

Therefore, i guess the I2C module is ok while i have a answer of "bus.read_byte" (here 17). Especially, the i2cdetec -y 1 works at all (and the output is the address 49.

The issue is still there if i use another address of the ads1115 (with another wiring as it is said in the example of adafruit).

Update: the module ADS1115 works with an Arduino (and the Adafruit librairy) and gives good measurements.

Have you got an idea?

2

There are 2 answers

0
Eman Jayme On

Solution: Ground the ADDR-Pin (ADS1115) to your RaspberryPi Ground (i use PIN9)

Details of the Issue:
I had the same issue. But there is much more... 
I noticed when i run the python code, 
then run i2cdetect -y 1, my device changes address it becomes 48, 49, 4a, 4b (random) 

I really hope this helps to some, as it took me a few days to know whats the issue. Btw it is also a best practice to Ground all the unused channels.

0
Mevlut OZTURK On

this is my sample code while reading ads1115 on windows 10 iot and raspbery pi, i think helpfull for you

var i2CSettings1 = new I2cConnectionSettings(0x48)
            {
                BusSpeed = I2cBusSpeed.FastMode,
                SharingMode = I2cSharingMode.Shared
            };



var i2C1 = I2cDevice.GetDeviceSelector("I2C1");
                var devices = await DeviceInformation.FindAllAsync(i2C1);
                var gpio = GpioController.GetDefault();

// here is important, setup i2c device firstly

 _converter1 = await I2cDevice.FromIdAsync(devices[0].Id, i2CSettings1);
                _converter1.Write(new byte[] { 0x01, 0xc4, 0x60 });
                _converter1.Write(new byte[] { 0x02, 0x00, 0x00 }); //rate
                _converter1.Write(new byte[] { 0x03, 0xff, 0xff });

// you must send this bytes. this must be send just one time

// and now we are reading data, you can read data in a loop but best way use alert pin. ads1115 has an alert pin and send and alert when ready for read, you can read alert pin with a digital input trigger by this code

_converter1.WriteRead(new byte[] { 0x0 }, bytearray1);
                            if (BitConverter.IsLittleEndian)
                                Array.Reverse(bytearray1);
                            var value1 = BitConverter.ToInt16(bytearray1, 0);