AnyI2C I2C Communications Quick Start Guide

AnyI2C is a open-source software application used to communicate to NCD I2C devices for the purposes of learning and testing basic functionality.  AnyI2C works in combination a low-cost USB to I2C converter that we designed, which focuses on compatibility with just about any I2C chip ever created.  AnyI2C is frequently used to test just about every device in the NCD IoT Devices category prior to shipment to our customer.

AnyI2C Software Usage:

The screenshot above shows the AnyI2C interface console, which is used to talk to many different types of I2C chips.  In this example, we will be controlling a I2C Buzzer (PCA9536_I2CBZ).  The I2C Buzzer mini module uses the PCA9536 chipset. This is important because you will need to match the chipset printed on the board with the chipset in the I2C software.

Follow these steps to turn the buzzer on and off (see RED numbers on the screenshot above):

  1. First, plug in the USB to I2C adapter (PR33-17) and run AnyI2C software.  Your computer will assign a COM port to the USB to I2C converter.  Open the COM port that matches your controller.
  2. Scroll until you find the I2CBZ_PCA9536 in the device listing or choose the chipset for your controller.
    Your controller will be marked with chipset that is used on the circuit board in white lettering.
  3. The command set window will change and you need to click on the Top line item “Configure all pins as outputs…”
  4. Click the “Set Beep High” and “Set Beep Low”.  You should hear the buzzer turn on and off.
  5. The I2C start address will be displayed in this area.  You may interact with this interface to choose the start address of any I2C chip.
  6. This portion of the interface allows you to configure data sent to the I2C chip or read data from the I2C chip.
  7. The Log Window is controlled using the “Clear” and “Log Data Type” selector box.  In this case, we are looking at the RAW I2C data going to the chip.   These data do not reflect the actual serial data going to the USB to I2C adapter, this will be done in the screenshot below.

The screenshot below repeats the exact same process as above, but we are now viewing the entire protocol of communications that talks to the USB to I2C adapter.

If you are writing your own software, you will want to use the “API Data Encoded” option (1 above) to view the actual data transmitted to and received from the USB to I2C adapter.

  1. Change the Log Data Type to “API Data Encoded”
  2. Click “Configure all pins as output…”
  3. Click “Set Beep High” and “Set Beep Low” buttons, you should hear the buzzer turn on and off.
  4. The Log window will show all data sent and received to the USB to I2C adapter.

Let’s take a look at these data a little more carefully:

W: 170 7 188 50 3 130 3 0 0 39

W: Indicates this is a Write Operation
170: NCD API Header Byte
7: NCD API Data Indicates 7 Bytes will be sent in the API frame.
188: I2C Command Header (Always use 188 when talking to I2C Devices)
50: Port Number.  50 Indicates Port 0, 51 = Port 1, etc.  This adapter has only one I2C port, so always use 50.
3: Number of Bytes to Send to the I2C Chip
130: I2C Data to Configure I/O Lines as Output (See Datasheet for the PCA9536, as this is a chip command)
3: I2C Data to Configure I/O Lines as Output (See Datasheet for the PCA9536, as this is a chip command)
0: I2C Data to Configure I/O Lines as Output (See Datasheet for the PCA9536, as this is a chip command)
0: Number of Bytes to Read from the I2C Chip (Use 0 for this chip since we don’t need to read any data from the I2C chip)
39: Checksum

Checksum is Calculated like this:

170+7+188+50+3+130+3+0+0+0 = 551

Now we need to Truncate the Checksum to 8-Bits using the mathematical “AND” Function (255 Isolates only the Lower 8-Bits of 551):

Checksum = (551 AND 255) = Lower 8-Bits ONLY of 551 = 39


Related Articles: