Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6814

MicroPython • Can't connect Pico to ADS1115 ADC board

$
0
0
Hi All,
I've been wrestling with this for a while, and am now stuck.
I have connected an ADS1115 to my pico using i2c, but have so far not been able to get it to work.
I have tried connecting the pico to another i2c device, an RTC, and it works fine.
I have tried two different ADS1115 boards, and both fail with the same error.
When I connect the board and do an i2c.scan() it returns the address of the board (72) so the Pico seems to be able to talk to the board. However if I try any other instruction, such as a writeto_mem or readfrom_mem instruction to read or write the config register, I get the dreaded "Errno 5 EIO" message. Almost every post I've read about this message suggests it is a wiring problem, but I can successfully do a scan() and retrieve the board address, which would seem to suggest that the wiring is okay. Needless to say I've checked it a dozen times anyway, and tried different scl/sda pins on the Pico, but nothing so far has made a difference.

This is the code I've been testing with.

Code:

from machine import I2Cfrom time import sleepconfig_reg_addr = 0x01config_reg_reset_val = 0x8583dev_address = 0x48result = 'nothing'i2c = I2C(0, sda=16, scl=17, freq=400_000)    result = i2c.scan()print('address = ', result)sleep(1)try:    i2c.writeto_mem(dev_address, config_reg_addr, bytearray(config_reg_reset_val))except OSError as o:    print('writeto_mem', o)sleep(1)try:    regVal = i2c.readfrom_mem(dev_address, config_reg_addr, 2)    result = bytesToInt(regVal)except OSError as o:    print('readfrom_mem', o) 
This is the output

Code:

>>> %Run -c $EDITOR_CONTENTMPY: soft rebootaddress =  [72]writeto_mem [Errno 5] EIOreadfrom_mem [Errno 5] EIO>>> 
All advice gratefully received.

Statistics: Posted by mogplus8 — Sat Jul 27, 2024 4:25 am — Replies 1 — Views 47



Viewing all articles
Browse latest Browse all 6814

Trending Articles