Raspberry Pi SMBus support combined data transmission?
Question: I am trying to use the ACS764 Hall effect current sensor with Raspberry Pi.
This sensor will sense the current and return its value via the chip built-in
I2C interface. I had connected the circuit according to the specification. On
my Raspberry Pi Python code I can write and read data to/from the sensor
however the data I read alway the same value.

Below is my simple code to read the sensor:

    
    
    import datetime
    import smbus
    import time
    import RPi.GPIO as GPIO
    
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(37, GPIO.OUT) #Connected to the ACS764 Freeze pin
    
    bus=smbus.SMBus(1)
    
    #Freeze the data
    GPIO.output(37, True)
    
    #Read the values
    bus.write_byte(0x60, 0x00) #Simulate the combined data transmission format
    data=bus.read_i2c_block_data(0x60, 0x00)
    print data
    
    #Unfreeze the data
    GPIO.output(37, False)
    
    GPIO.cleanup()
    

However when I run the script the value alway show the same even I had changed
the current to be sensed value.

    
    
    pi@Raspberry:~ $ python i2cAcs764.py 
    [0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0]
    

According to the ACS764 specification, to read the sensor value, I need to use
the "combined data transmission" format. However, I didn't find any function
in the Python SMBus library that allow me to use the combined data
transmission, therefore at the moment I use the "bus.write_byte" function to
simulate the "combined data transmission". Below is the screen capture of the
specification.

[ACS764 Datasheet Snapshoot](http://i.stack.imgur.com/fbno9.png)

My question now is how can I use the Python SMBus I2C library to perform the
"combined data transmission" reading of the ACS764 chip?

Please advise, thank you.


Answer: After google for a few days I finally found a solution to my question above.
The answer is that Raspberry I2C interface does support "combined data
transmission" (aka Repeated Start) but it is not enable by default. You need
to enable the setting by the following command.

    
    
    sudo su -
    echo -n 1 > /sys/module/i2c_bcm2708/parameters/combined
    exit
    

Please refer to [i2c repeated start transactions
](https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=15840&start=25) for
more information.

Base on the smbus specification the function that support the repeated start
is i2c_smbus_read_i2c_block_data(), in Python library it is call
read_i2c_block_data().

Please refer to the [SMBus Protocol
Summary](http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/Documentation/i2c/smbus-
protocol) for more details.

Below is my sample code that read data from ACS764 Hall effect sensor chip
that required repeated start.

    
    
    import datetime
    import smbus
    import time
    
    bus=smbus.SMBus(1)
    
    # Write setting parameter to the chip
    data = [0x02, 0x02, 0x02]
    bus.write_i2c_block_data(0x60, 0x04, data)
    
    # Read the data out of the chip that require Repeated Start
    data=bus.read_i2c_block_data(0x60, 0x00)
    print data
    

I was happy to find the solution and hope that those who face the same issue
can get help from this post. Thank you all!

