I2C OSerrors: 5, 116, 16 problem with interfacing to ADS1115

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
tomrogue
Posts: 5
Joined: Mon Jun 29, 2015 11:13 pm

I2C OSerrors: 5, 116, 16 problem with interfacing to ADS1115

Post by tomrogue » Fri Jul 03, 2015 7:19 pm

Hey there,

So I've read all the posts on this forum regarding I2C and OSerrors:5, 116 and 16 with no real insight into why I might be experiencing the issues I am.

Basically, I'll usually be able to write to the ADC with something like:
i2c.mem_write(data, address, config_reg, addr_size=16)
and no exceptions will be thrown. Then, when I try to read a conversion via:
i2c.mem_read(2 , address, convert_reg, addr_size=16)
I'll get an OSError: 5, followed by 116's to infinity (should I try the same operation repeatedly).
I have also tried to use i2c.send(data, address) and i2c.recv(data, address) to accomplish what mem_write/mem_read would do, and in this case I get OSerror: 16 where the ADC or i2c bus stop communication and
i2c.scan() returns : []

So my question is:
Am I missing something in the I2C functions themselves, or is this likely pilot error on my part with not understanding something about my ADC chip (it seems really straight forward). Anyhoo...thanks in advance for any responses :)

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: I2C OSerrors: 5, 116, 16 problem with interfacing to ADS1115

Post by pythoncoder » Sat Jul 04, 2015 6:54 am

If i2c.scan() returns an empty list your hardware isn't being detected. I'd double check the electrical connections.
Peter Hinch
Index to my micropython libraries.

blmorris
Posts: 348
Joined: Fri May 02, 2014 3:43 pm
Location: Massachusetts, USA

Re: I2C OSerrors: 5, 116, 16 problem with interfacing to ADS1115

Post by blmorris » Sat Jul 04, 2015 3:30 pm

I suspect that it isn't an electrical issue, or the mem_write call would have failed because the pyboard would not have received an ACK on each transmitted byte. It is possible that the mem_read call produces an error which causes the I2C bus to hang, so that all subsequent I2S calls generate errors as well. If I am correct in this, reinitializing the I2C bus (i2c.deinit(), i2c.init()) should get the scan call to work.
Are you sure that you need to use 'addr_size=16'? I'm not familiar with the ADS1115, but typically you only need 16-bit addresses for I2C devices with more than 256 registers (like an external memory or a device that uses I2C to load a program to boot up), and sometimes even then you don't need it.

-Bryan

Edit- the ADS1115 is a 16-bit ADC; I would guess that there are only a handful of configuration registers and that addr_size=16 isn't correct.

Post Reply