onion omega2 and onion-i2c

I've been programming for a while but I'm new to Python and a true neophyte with i2c and sensor devices.

I'm using an Onion Omega adapter to connect to the sensor but can't even to get the device to respond to its Read Device Identification command.

I've trimmed the onion-i2c. python script to:

from OmegaExpansion import onionI2C
import time
import sys

print 'Starting: onionI2C module testing...'

i2c     = onionI2C.OnionI2C()

# set the verbosity
i2c.setVerbosity(1)

devAddr = 0x2a


# perform series of writes
addr     = 0x00
value    = [42, 146, 106, 2, 0, 0, 0, 0, 254]
print 'Writing to device 0x%02x, address: 0x%02x'%(devAddr, addr)
val     = i2c.writeBytes(devAddr, addr, value)
print '   writeBytes returned: ', val


addr     = 0x2a
value    = [146, 106, 2, 0, 0, 0, 0, 254]
print 'Writing to device 0x%02x, address: 0x%02x'%(devAddr, addr)
val     = i2c.writeBytes(devAddr, addr, value)
print '   writeBytes returned: ', val

addr     = 0x92
value    = [106, 2, 0, 0, 0, 0, 254]
print 'Writing to device 0x%02x, address: 0x%02x'%(devAddr, addr)
val     = i2c.writeBytes(devAddr, addr, value)
print '   writeBytes returned: ', val

print 'Done!'
 

but all I get is:

Starting: onionI2C module testing...
Writing to device 0x2a, address: 0x00
   writeBytes returned:  None
Writing to device 0x2a, address: 0x2a
   writeBytes returned:  None
Writing to device 0x2a, address: 0x92
   writeBytes returned:  None
Done!
 

Can anyone help?

 

Target Product: 
I2CCMAC115A_DLCT03C20
B

try to run i2cdetect command and it should respond with an address.

once it responds with 0x2A( no address jumper installed) please use this code.

 

from OmegaExpansion import onionI2C
import time
import sys
print 'Starting: onionI2C module testing...'
i2c     = onionI2C.OnionI2C(0)
# set the verbosity
i2c.setVerbosity(1)
command2 = [0x6A, 0x02, 0x00, 0x00, 0x00, 0x00, 0xFE]
#while True:
#print ""
#ret = raw_input('  Ready to read?')
data = i2c.writeBytes(0x2A,0x92,command2)
#print '   Read returned: ', data
print ' write bytes: ', command2
# Convert the data to 14-bits
time.sleep(0.5)
data = i2c.readBytes(0x2A, 0x55, 3)
typeOfSensor = data[0]
maxCurrent = data[1]
noOfChannel = data[2]
# Output data to screen
print "Type of Sensor : %d" %typeOfSensor
print "Maximum Current : %d A" %maxCurrent
print "No. of Channels : %d" %noOfChannel


while True:
        command1 = [0x6A, 0x01, 0x01, 0x06, 0x00, 0x00, 0x04]

        data2 = i2c.writeBytes(0x2A,0x92,command1)
        print ' write bytes: ', command1
        time.sleep(0.5)
        data1 = i2c.readBytes(0x2A, 0x55, noOfChannel * 3)
        # Convert the data
        #while True:
        for i in range(0, noOfChannel) :
                msb1 = data1[i * 3]
                #print ' msb1: ', msb1
                msb = data1[1 + i * 3]
                #print ' msb: ', msb
                lsb = data1[2 + i * 3]
                #print ' lsb: ', lsb
                #print ' i: ', i
                # Convert the data to ampere
                current = (msb1 * 65536 + msb * 256 + lsb) / 1000.0
                # Output data to screen
                print "Channel no : %d " %(i + 1)
                print "Current Value : %.3f A" %current
                time.sleep(5)
                print "\n"
                print "New Updated Current Values are: "

 

Tom Stiller's picture

I may have a problem withthe board.

i2cdetect returns:

 i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: 30 31 32 33 34 35 36 37 -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --  

 

No device 0x2a

B

how you are connecting the onion omega adapter with your board.

if you have a particle photon board and want to connect it with onion omega i2c shield then you will need this adapter

https://www.controleverything.com/content/Adapters?sku=SI

because your onion omega has an I2C out port and so does the current monit board.

so you will need this SI adapter to install an I2C in port.

Thanks

 

Tom Stiller's picture

Thank you very much. I thought I only needed the Omega adapter board but I either got the wrong sensor board or just misunderstood the specs.

Thanks again.

B

Hi Tom,

if you want to use this current sensor directly with onion omega then you will need an onion omega I2C adapter ( i guess the one you have is onion omega I2C shield).

like this one.

https://www.controleverything.com/content/I2C-Master?sku=OC

this adapter will plug into the particle electron board and then you can plug onion omega into it.

so if i were you and wanted to build an onion omega  resistive current monit board I will get these two boards

1. https://www.controleverything.com/content/Current?sku=PECMAC210A_DLCT03C20

2. https://www.controleverything.com/content/I2C-Master?sku=OC

Thank You, Tom.

 

 

Tom Stiller's picture

If I understand correctly, I can use the board I have marked:

PR26-7 -- SCCMAC 210A -- DLCT03C20

but substituting adapter PR32-3 (OC ) for the one I have PR32-2 (OB), is that correct?

 

B

please, can you tell me few things? without power up the board.

 

1. can you plug the OB adapter in your board? ( the onion omega adapter will have some extra pins, don't worry about them).

2. does it fit properly? 

3. if it doesn't then please plug your onion omega in it. 

after doing this please post a picture here.

Thank You, Tom.

 

Tom Stiller's picture

Thanks for staying with this.  Yes, the OB will plug into the sensor; that's the configuration I was using at the start of this thresd.

Tech Support at ControlEverything says I have the wrong boards for what I want to do and advise exchanging them for:

https://www.controleverything.com/content/Current?sku=PECMAC210A_DLCT03C20

and https://www.controleverything.com/content/I2C-Master?sku=OC

Thanks again for all your help.