What Information Do I Need to Identify and Write to an I2C Slave Device?

Question from the Customer:

I am learning to use the Aardvark I2C/SPI Host Adapter with the Aardvark Software API aai2c_file example. One of the arguments this method requires is the slave address. How can I discover the I2C slave address?

Here is a diagram of my setup – the Aardvark adapter is the master device.

Diagram of Aardvark adapter connected to PCE-E Transposer

Response from Technical Support:         

Thanks for your question! We will start with an overview of the aai2c_file function, and then  discuss how to discover the I2C slave address.

 About the aai2c_file API Example

Here is an overview of calling the aai2c_file and its parameters

The callout:

  • aai2c_file PORT SLAVE_ADDR filename

The parameters:

  • PORT is the port number for the Aardvark adapter. You can acquire this information by running the function py with the Aardvark adapter connected to your PC.
  • SLAVE_ADDR is the I2C slave address of the slave device that you are attempting to write to.
  • filename is the data to write to the I2C slave device. The file should be in binary format, which could look like 670f08c3010000ca00880246.

Configure and Identify Slave Addresses

Each slave device has a unique address to identify it on the bus. These addresses are pre-defined and are normally provided in the datasheet of the device. To identify multiple devices on the same bus, you can set the least significant bits.

In standard I2C, the slave address is 7-bits.  The extended 10-bit address is also supported. For more information about I2C addresses, please refer to the article 7-bit, 8-bit, and 10-bit I2C Slave Addressing.

Recommended Information

We recommend going through our Knowledge Base article Performing random reads with an I2C slave. This article uses the Control Center Serial Software to show examples of performing random reads via the GUI interface and using Batch Mode. The same concepts can be applied to API functions.

This article also provides an example of discovering the necessary information from a datasheet.

We hope this answers your questions. Additional resources that you may find helpful include the following:

If you have other questions about our host adapters or other Total Phase products, feel free to email us at sales@totalphase.com. You can also request a demo that is specific for your application.

Request a Demo