Sparkfun I2C GPIO expanders 2



  • [0_1576345075178_Qwiic_GPIO.brd](Uploading 100%) This goes with an earlier post on Sparkfun I2C GPIO expanders. A 2nd Sparkfun device is the Qwiic GPIO, SPX-14716, which uses a TCA9534 I2C chip. An advantage is that Qwiic connectors are already mounted on this device. This was an experimental board and is not directly available any more. However, Chris at the Sparkfun help desk gave me the Eagle file for the board. He will allow me to distribute it, but I don't see how to uploae it here. At https://oshpark.com/, I was able to obtain 6 of these boards for $12.00 and the ICs from Digikey: PART: 296-47827-1-ND MFG : Texas Instruments (VA) / TCA9534DWR. Hand soldered the components an they all worked fine. Some are shown (the darker boards) in this pic:
    0_1576345370604_20191129_115741B.jpg .
    Python code for accessing them is here:

    # adapted from <https://github.com/topherCantrell/pi-io-expander/find/master>
    
    from OmegaExpansion import onionI2C #need >>opkg install python-light pyOnionI2C
    import time
    
    CHIP_A = 0x27 # I2C address for chip A, cut jumpers for other addresses
    
    TC_RegDataIn =  0x00 # default 0xxx
    TC_RegDataOut = 0x01 # default 0xFF
    TC_RegPolInv =  0x02 # default 0x00; polarity invert
    TC_RegConf =    0x03 # default 0xFF, 1 = input; 0 = output; configuration
    
    bus = onionI2C.OnionI2C()
    
    bus.writeByte(CHIP_A, TC_RegConf, 0xFF-0x04)  # set bit 2 as output; e.g. 1111 1011    
    
    while True:
    	
    	bus.writeByte(CHIP_A, TC_RegDataOut, 4) #bit 2 on
    	a = bus.readBytes(CHIP_A, TC_RegDataIn, 1)
    #	print(a)
    	print a[0] # a is a list even though it's only one byte
    	time.sleep(0.2)
    
    	bus.writeByte(CHIP_A, TC_RegDataOut, 0) # all off
    	a = bus.readBytes(CHIP_A, TC_RegDataIn, 1)
    	print a[0]
    	time.sleep(0.2)
    	print

Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.