I2C-MP-USB EB - USB to I2C board
USB-I2C-Adapter board

I2C-MP-USB EB board
€ 24,90
incl. 19% VAT excl. € 4 shipping
Order I2C-MP-USB EB now!

Buy on Amazon.de!
(€ 24,90 incl. 19% VAT excl. shipping)
Shipping to all EU countries!
English, Deutsch, Nederlands,
Polski, Türkçe, Čeština

I2C-MP-USB - USB to I2C Interface

I2C-MP-USB is a interface to connect I²C devices via USB to a host system. It aims to easily control I2C slaves with highly portable code.

Contents

Software

A Python library is available for easy and rapid development on different operating systems. Alternatively a kernel driver can be used under Linux.

Python library "pyI2C_MP_USB" (Windows, MacOS, Linux)

pyI2C_MP_USB is a Python library for the I2C-MP-USB adapter which allows easy, platform-independent access to I²C slaves. The API is mostly identical to the SMBus package, porting of the control source code to other hardware is therefore possible without much effort.

Installation

The easiest way to install the library is using pip:
pip install git+https://github.com/EmbedME/pyI2C_MP_USB

Drivers

The library uses libusb. On Linux and MacOS X no kernel driver is needed. Please use following tool for Windows to install the "WinUSB" driver:
Windows driver installation for I2C-MP-USB
Depending on the application, under Windows a libusb-1.0.dll is required. These can be found for various architectures on the libusb project homepage under "Download -> Windows Binaries". Please place the DLL in the application folder.

Example

Write one byte to an EEPROM 24C02 at address 0x10; then read it back:
from i2c_mp_usb import I2C_MP_USB as SMBus
import time

bus = SMBus()
bus.write_byte_data(0x50, 0x10, 0xA5)   # Write byte to EEPROM
time.sleep(0.1)                         # Give EEPROM time to flash
data = bus.read_byte_data(0x50, 0x10)   # Read byte from EEPROM
print(data)

Throughput

A block read of 1000 bytes at 400kHz clock speed takes about 32ms on my test system (Ubuntu 16.04@ThinkPad X201). That means a transfer rate of 31.25 kBytes/s.

Kernel driver "i2c-tiny-usb" (Linux)

For Linux there is an alternative to the library: The driver "i2c-tiny-usb" is part of the official Linux kernel and is included in most distributions. When the adapter is plugged in, it is automatically detected and registered:
$ dmesg | tail

usb 1-1.5.2.3: new full-speed USB device number 10 using ehci-pci
usb 1-1.5.2.3: New USB device found, idVendor=0403, idProduct=c631
usb 1-1.5.2.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.5.2.3: Product: I2C-MP-USB
usb 1-1.5.2.3: Manufacturer: www.fischl.de
usb 1-1.5.2.3: SerialNumber: 131E0000
i2c-tiny-usb 1-1.5.2.3:1.0: version 1.01 found at bus 001 address 010
i2c i2c-7: connected i2c-tiny-usb device
usbcore: registered new interface driver i2c-tiny-usb
Example using i2c-tools with an EEPROM 24C02 connected to the I2C-MP-USB.
  1. Detect devices on the I²C bus:
    $ i2cdetect -y 7
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    70: -- -- -- -- -- -- -- --
  2. Write value 0x5A to EEPROM address 0x10:
    $ i2cset -y 7 0x50 0x10 0x5A
  3. Read value from EEPROM address 0x10:
    $ i2cget -y 7 0x50 0x10
    0x5a
  4. Dump EEPROM content at address range 0x00-0x1F:
    $ i2cdump -y -r 0x00-0x1F 7 0x50 b
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
    00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    10: 5a ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    Z...............
Example using kernel module AT24 to access an EEPROM 24C02 connected to the I2C-MP-USB.
  1. Load AT24 kernel module and register the EEPROM
    $ modprobe at24
    $ echo "24c02 0x50" > /sys/class/i2c-adapter/i2c-7/new_device
  2. Dump the eeprom content
    $ hexdump -C /sys/bus/i2c/drivers/at24/7-0050/eeprom
    00000000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
    00000010  5a ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |Z...............|
    00000020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
    *
    00000100
  3. Unregister the EEPROM
    $ echo "0x50" > /sys/class/i2c-adapter/i2c-7/delete_device

Firmware

Source code and HEX file

The firmware of I2C-MP-USB is available as precompiled HEX file and as C (XC8 compiler) source code.

Precompiled HEX and source code archive:
i2c_mp_usb_firmware_v1.1.zip (2019-07-24) First public version

Firmware update via bootloader

Start the bootloader via software (e.g. start_bootloader.py) or via hardware jumper: short JP1 and plug in I2C-MP-USB - now the bootloader starts. Use a bootloader application (en MPHidFlash) to load the new firmware into I2C-MP-USB:
mphidflash -w i2c_mp_usb_firmware_v1.0.hex

Hardware

Schematic - I2C-MP-USB's circuit diagram

I2C_MP_USB Schematic

Partlist - Build your own I2C-MP-USB!

Here you find a list of all parts needed to build your own I2C-MP-USB board.

PartnumberValue
C1, C24,7u
C3, C4220n
IC1PIC16F1455
IC2MCP1700
LED1blue LED
R1270
R2, R34k7
X15pol 2.54mm
X2USB-B

Troubleshooting

WindowsError: [Error 126] The specified module could not be found

The libusb-DLL is missing. Please copy it into the python script folder. See: Drivers / libusb-1.0.dll

Linux: "Permission denied" when accessing I2C devices

en Setting I2C permissions for non-root users

Linux: "LIBUSB_ERROR_BUSY" when using the Python library

If you use the Python library under Linux, deactivate the "i2c-tiny-usb" module, e.g. with
$ rmmod i2c-tiny-usb
Please tell me about your I2C-MP-USB project!

I2C-MP-USB reading magnetic field from SI7210
   Read out the magnetic field strength from a SI7210.
Post in the Mikrocontroller.net forum: I2C USB Interface with SI7210 (python script).

by Rainer Wolf (09/2019)
I2C-MP-USB connected to Grove LCD RGB
   Display text on a Grove - LCD RGB Backlight.
Example Python script: grove_lcd_rgb.py

by Thomas Fischl (10/2019)

Other I²C interface projects/products

en i2c-tiny-usb by Till Harbaum
de ELV USB-I2C-Interface
en IO-Warrior28 USB-I2C Dongle
en USB-I2C - USB to I2C Communications Module