svp
Posts: 6
Joined: Thu Nov 29, 2018 11:05 am

pigpio error : 'I2C write failed' in MAX11617

Sat Dec 08, 2018 10:16 am

Hi there,

I interfaced MAX11617 which is ADC, with RPi 3B+ using i2c protocol. I have written a code to 2 byte data reading from the slave.

while using smbus library it was giving "Error 121: Remote IO error". Then i try to use use pigpio library. Now I am getting the error pigpio.error 'i2c write failed'. How to solve it? Any suggestion, tutorial or video are most welcome.

Thank you in advance.

Code: Select all

import pigpio
from time import sleep

#-----------------------------------------------------#
bus = 1 		#i2c bus number 0 or 1 in RPi
addr_w = 0x6A 		#i2c slave address to write
addr_r = 0x6B		#i2c slave address to read
data_size = 2 		#number of bytes to read
#-----------------------------------------------------#

adc = pigpio.pi() 			#init pigpio
handle_adc = adc.i2c_open(bus,add_w,0) 	#get i2c handle
print "Handle : ",handle 	#print i2c handle

adc.i2c_write_byte_data(handle_adc,0xA2,0)	#setup byte
adc.i2c_write_byte_data(handle_adc,0x61,0)	#configuration byte

try:
	While True:
		#read <data_size> bytes from i2c <handle> and store:  
		#count = number of returned bytes & data = array of byte
		count, data = adc.i2c_read_device(handle_adc, data_size)
		print "Received Bytes : ",count
		#print single bytes
		for i in range(count):
			print "Byte{0} : {1}".format(i+1, data[i])	
		sleep(1)

except:
	print "\nERROR"
	adc.i2c_close(handle_adc) 	#close i2c device association with handle
	adc.stop() 			#stop connection with raspberry GPIO

DirkS
Posts: 9807
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: pigpio error : 'I2C write failed' in MAX11617

Sat Dec 08, 2018 10:18 am

Have you checked with i2cdetect that the device is properly connected and detected on the Pi?

svp
Posts: 6
Joined: Thu Nov 29, 2018 11:05 am

Re: pigpio error : 'I2C write failed' in MAX11617

Sat Dec 08, 2018 11:14 am

Yes, I have checked with i2cdetect -y 1. The snapshot is attached. It may be due to i2c isolator ic ADUM1250 between MAX11617 and RPi!.
Attachments
Capture.JPG
Capture.JPG (75 KiB) Viewed 351 times

Return to “Python”