Skip to the content
PCBKitNew board
2 layers44.2 × 29.3 mmI2c tiny usb, the printed circuit board in 3D

Cheap and simple I²C to USB interface

Size
44.2 × 29.3 mm
Copper layers
2
Thickness
1.6 mm
Parts
27
Nets
16
Pads
76
Tracks, vias
199, 1
Pours
2
Routed
Yes
KiCad
KiCad 5 (file 20171130)
Created
11 Jan 2016
Updated
2 Nov 2023

Overview

I2c tiny usb is an open-source printed circuit board by harbaum, from the harbaum/I2C-Tiny-USB repository on GitHub. It is a 2-layer board of 44.2 × 29.3 mm with 27 parts on 16 nets, routed with 199 tracks and 1 via.

It is built around the ATTINY45-20PU, AMS1117-3.3 and BSS138, with the BSS84 among its other parts. Its parts include 8 resistors, 5 capacitors, 3 diodes, 3 transistors and 2 ICs. It belongs with the AVR (ATmega, ATtiny) boards of this library.

Main components

4

README

README.md

i2c-tiny-usb

Update 2022-01-10

The common firmware(-directory) now is also capable to compile firmwares for different tinyusbboard (16MHz/20MHz, atmega8, atmega88p, atmega168p, atmega328p) types.

Introduction

Attach any I2C client chip (thermo sensors, AD converter, displays, relais driver, ...) to your PC via USB ... quick, easy and cheap! Drivers for Linux, Windows and MacOS available.

The i2c-tiny-usb project is an open source/open hardware project. The goal of i2c-tiny-usb is to provide a cheap generic i2c interface to be attached to the usb. It is meant as a replacement for those simple and cheap printer port to i2c adapters. A USB solution has several advantages incl. the built-in power supply and a more future proof interface. Furthermore no cpu intense bitbanging is required on the host side. This USB solution even requires less parts than some printer port solutions.

While the i2c-tiny-usb was developed under and for Linux it also works under Windows and MacOS X. A windows demo driver and demo application is included to get you started immediately.

The i2c-tiny-usb project is based on:

Hardware

The prototype board includingThe final hardware with
a ds1621 temperature sensorthe same sensor added

The hardware of the i2c-tiny-usb interface consists of the Atmel AVR ATtiny45 CPU, a cheap and easy to obtain microcontroller with 4 KBytes flash (of which ~2k are used in this application) and 256 Bytes RAM. The processor is surrounded by few other parts.

The USB interface

The USB interface of the i2c-tiny-usb interface is based on a pure software implementation and uses two pins of the AVR (PB0 and PB2). This software implementation supports low speed USB only which is signalled to the PC by resistor R1.

The I2C interface is implemented using a bitbanging approach. The hardware supported twi interface of the attiny45 is bound to hardware pins at the chip that are required for USB operation and can thus not be used for I2C. The bitbanging I2C interface being used instead may not be fully I2C compatible and thus not every I2C client chip may function correctly at this bus. No incompatibilities have been reported so far. The i2c-tiny-usb provides a software adjustable i2c clock delay allowing to configure the i2c clock. The default delay is 10us. Due to additional delays in the i2c bitbanging code this results in a i2c clock of about 50kHz.

For simplicity reasons all USB transfers are done via the control endpoint. Since the avr usb library does only support low speed devices it cannot use bulk transfers which are specified for high and full speed devices only. Low speed devices support so called interrupt transfers which are limited to a preset bandwidth while control transfers can use any free bandwidth (if there's any at all).

The device therefore uses control transfers for all of its communication. This requires some additional limitation to prevent multiple driver software (e.g. the kernel driver and the libusb based test application) to access the device at the same time. Under Linux this can be achieved by selecting certain access request types. This kind of access control may not be possible under other operating systems.

Power consumption

The whole device is a so called bus powered device. This means that the complete device is powered directly from USB. Therefore the AVR and one or more I2C client chips are powered from the USB VBUS signal.

The adapter itself draws less than 10mA and reports this to the host via its USB descriptors. The device is able to power I2C client chips as well. But since these chips vary in power consumption it is not possible to correctly include their demands into the device descriptors. It's your responsibility to keep an eye on the total power supply and especially to make sure that the entire device does not exceed the total USB limit of 500mA.

It is planned for future firmware versions to make the reported power consumption software configurable so the value can easily be adopted to the real power demands of the entire device.

Kernel driver

The i2c-tiny-usb is meant to be used with Linux. It comes with a Linux kernel driver that bridges between the USB and I2C subsystems in the Linux kernel. The driver then attaches to the USB device and make the i2c bus available to the i2c subsystem. Thus the entire setup is transparent to client applications like the lm_sensors framework and no special client chip drivers are required. Instead the drivers already present in the linux kernel are used with the i2c-tiny-usb as well. With e.g. the ds1621 temperature sensors used in the prototype the output of sensors may e.g. look like this:

ds1621-i2c-2-48 Adapter: i2c-tiny-usb at bus 003 device 017 temp: +21.50°C (low = +15.0°C, high = +10.0°C) ALARM (HIGH)

Schematics and PCB

The zener diodes in the schematic are optional. They may be required since the i2c-tiny-usb is directly powered from the USBs VBUS singnal at 5V. The USB data lines (D+ and D-) are supposed to be operated at 3.3V only. Some PCs encounter problems at 5V and limiting the voltage to at most 3.6V may help. My prototype lacks these diodes since my PC works fine with D+ and D- at 5V.

Resistor R1 is 2k2 instead of 1k5 for the same reason. It is meant to pullup to 3.3V. Since we are pulling up to 5V the higher resistance is required.

Below is the final PCB layout. It consists of the USB and I2C parts only and does not include a I2C client chip. Instead it comes with a solder area for easy prototyping. I do have some of these PCBs left. Just drop me an email if you want to buy one (6 EUR per PCB + 4 EUR shipping). You can easily etch a PCB youself. Since most of the connections are on the bottom side even a single sided PCB will work. You'll just have to add the four missing connections using thin wires.

Part placementTop PCB sideBottom PCB sideThe final PCB

The USB connector space on the PCB provides two additional holes to allow an USB cable to be directly and firmly attached to the device without the use of the USB connector. See the image below for the desired pinout.

Direct cable wiring schema ...... and in reality (with pcf8574 client).

Part list

You can get all parts directly via my i2c-tiny-usb part list at Reichelt. This list includes the following parts:

PartQtyNameReichelt Part No.
D1, D223.6V zener diodeZF 3,6
Q1112Mhz crystal, HC49U package12,0000-HC49U-S
R112.2 kilo ohm resistor1/4W 2,2k
R2, R3268 ohm resistor1/4W 68
R4, R5210 kilo ohm resistor1/4W 10k
C1, C2222pF ceramic capacitor, 2.54mmKERKO 22P
C31100nF capacitor, 5.08mmX7R-5 100N
C6110μF electrolytic capacitorRAD 10/35
--1USB-B print connectorUSB BW
JP114 pin I2C connectorSL 1X36G 2,54
U$11Attiny45 DIP 20MhzATTINY 45-20PU
--1socket for U$1GS 8P

Compiling the firmware

You need the AVR version of the GCC compiler to compile the firmware. Under Ubuntu you can install these with the following command:

sudo apt-get install avr-libc binutils-avr gcc-avr avrdude make

Afterwards you need to clone this repository and update the dependencies:

text
$ git clone https://github.com/harbaum/I2C-Tiny-USB
$ cd I2C-Tiny-USB; git submodule update --init --recursive

Finally change into the firmware directory and trigger a build of the version you need. E.g. for the version running on the ATTiny45:

text
$ cd firmware
$ make -f Makefile-avrusb.tiny45

This will result in the firmware stored the file firmware.hex.

Uploading the firmware

If you are familiar with Atmel programming you probably know what you are doing. The Makefile in i2c-tiny-usb/firmware/Makefile assumes, that you are using the stk500 for programming the attiny45. Since all 6 user configurable pins of the ATtiny45 are required, the so called high voltage serial programming (hvsp) mode of the attiny45 has to be used. E.g. the stk500, the AVR-Doper and the AVR Dragon are supporting this mode.

Two versions of the firmware can be compiled which are based on different USB software implementations for the AVR. If in doubt use the pre-compiled firmware.hex file distributed with the source code.

Troubleshooting

Problem: The device seems to work fine, it is detected correctly by Linux, but i get various error messages when accessing it from the test application.

Solution: First make sure that the kernel driver is not loaded when trying to use the libusb based test application. Since the kernel driver is part of the main kernel line, it may even be already installed on your system. Type rmmod i2c_tiny_usb to remove it. Also make sure that you run the test application as the root user since the standard user may lack the rights to access all aspects of the i2c_tiny_usb hardware.

Problem: The device is not properly detected. Linux reports an error like "device not accepting address" in the system log.

Solution: The USB interface is not working at all. Please make sure that the AVR CPU is correctly flashed and that the fuses are set correctly. Another reason may be that the zener diodes are too slow (see next problem).

Problem: The device is not properly detected. Linux reports an error like "device descriptor read/all, error -71" in the system log.

Solution: The device is working partly and the USB transfers are unreliable. This is often cauesed by "slow" high current zener diodes. On a previous reichelt list i had those wrong zener types. These slow diodes often seem to have thicker wires than the other parts. You can just try to remove the zener diodes and the device will work if your host PC copes with 5V on the USB data lines. Also using a USB hub between a device without zener diodes and the PC may lead to a working setup. Otherwise you need faster diodes as a replacement (reichelt no "zf 3,6" as on the current reichelt list).

Using the device with a Nokia N800

The i2c_tiny_usb works at various hosts. One of the most interesting ones is the Nokia N800. You need to enable USB host mode capabilities on your N800 to make use of the i2c-tiny-usb.

The demo application (contained in the i2c_tiny_usb archive) can easily be installed on the N800 from the harbaum.org repository using the install button below. Once it's installed it can be run from extras menu. The current version comes with a udev rules file granting user access to the i2c-tiny-usb and thus not requiring root rights anymore. Below is a screenshot of my n800 with a ds1621 equipped i2c-tiny-usb.

The i2c_usb demo application currently supports two I2C client chips, a ds1621 temperature sensor and a pcf8574 parallel port driver (with some LEDs attached to it, so you can see what's happening). Further chips can easily be supported, just use the source above ... Happy hacking with the N800!

Links

User contributions


Till Harbaum

http://www.harbaum.org/till

Parts

27
QtyValueFootprintReferences
310kResistor_SMD:R_1206_3216Metric_Pad1.42x1.75mm_HandSolderR4, R6, R7
2100nCapacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolderC4, C5
22.2MountingHole:MountingHole_2.2mm_M2MH1, MH2
222pCapacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolderC1, C2
23V6Diode_THT:D_A-405_P7.62mm_HorizontalD1, D2
268Resistor_SMD:R_1206_3216Metric_Pad1.42x1.75mm_HandSolderR2, R3
2BSS138Package_TO_SOT_SMD:SOT-23Q1, Q2
110KResistor_SMD:R_1206_3216Metric_Pad1.42x1.75mm_HandSolderR5
110uCapacitor_SMD:C_1206_3216Metric_Pad1.42x1.75mm_HandSolderC3
112MhzCrystal:Crystal_SMD_HC49-SDY1
12K2Resistor_SMD:R_1206_3216Metric_Pad1.42x1.75mm_HandSolderR1
1470Resistor_SMD:R_1206_3216Metric_Pad1.42x1.75mm_HandSolderR8
1AMS1117-3.3Package_TO_SOT_SMD:SOT-223-3_TabPin2U2
1ATtiny45-20PUPackage_DIP:DIP-8_W7.62mm_Socket_LongPadsU1
1BSS84Package_TO_SOT_SMD:SOT-323_SC-70Q3
1Conn_01x08_MaleConnector_IDC:IDC-Header_2x04_P2.54mm_HorizontalJ2
1LED_SmallLED_THT:LED_D3.0mmD3
1USB_B_MiniConnector_USB:USB_Mini-B_Lumberg_2486_01_HorizontalJ1

The 26 most common of 27 parts.

Questions

How big is the I2c tiny usb PCB?

It measures 44.2 × 29.3 mm and has 2 copper layers, 1.6 mm thick.

What parts does the I2c tiny usb use?

27 parts, built around the ATTINY45-20PU, AMS1117-3.3, BSS138 and BSS84. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the I2c tiny usb KiCad files?

From the harbaum/I2C-Tiny-USB repository on GitHub, at the commit this page was made from: the board is pcb/i2c-tiny-usb/i2c-tiny-usb.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the I2c tiny usb design in my own project?

Its repository states no licence, so its author keeps all rights: ask harbaum before reusing the design.

More from harbaum/I2C-Tiny-USB

1
  • 2 layers50.8 × 35.6 mmInterface, the printed circuit board in 3D

    Interface

    harbaum/I2C-Tiny-USB

    Cheap and simple I²C to USB interface

    15 parts454

Similar boards

  • 2 layers24 × 57.8 mmWeather station, the printed circuit board in 3D

    Weather station

    mec-kon/weather_station

    A simple weather station hardware (pcb files) for recording temperature, humidity, pressure and airquality.

    73 parts3GPL-3.0
  • 2 layers45 × 58.2 mmOpentama, the printed circuit board in 3D

    Opentama

    Sparkr-tech/opentama

    An open-source reference design for MCUGotchi

    65 parts237
  • 2 layers166 × 105 mmPico synth sandbox, the printed circuit board in 3D

    Pico synth sandbox

    relic-se/PicoSynth_Sandbox-hardware

    Raspberry Pi Pico digital synthesizer board with I2S stereo audio i/o, MEMS microphones, MIDI i/o, a capacitive keybed, 1602 display, 2 rotary encoders, and LiPo battery. Designed for use with CircuitPython and synthio.

    184 parts26GPL-3.0
  • 2 layers98.8 × 55.1 mmH bridge controller, the printed circuit board in 3D

    H bridge controller

    jayanta525/dual-h-bridge

    Dual H-Bridge Controller with IRF3205 and IR2104 MOSFET Driver, and with ATMega328P-AU PWM Controller

    104 parts5MIT
  • 2 layers72 × 47.5 mmPCB avr dx unbricker, the printed circuit board in 3D

    PCB avr dx unbricker

    k-takata/PCB_avr_dx_unbricker

    UPDI High Voltage programmer for AVR Dx/Ex series

    40 parts4
  • 2 layers92 × 76 mmILV2-7-5 Clock, the printed circuit board in 3D

    ILV2-7-5 Clock

    biomurph/ILV2-7-5_VFD_Display

    KiCAD circuit for a VFD Clock using the Popular ILV2-7/5 flat tube segmented nixie

    50 parts3GPL-3.0
  • 2 layers101.6 × 53.3 mmIO Link Shield, the printed circuit board in 3D

    IO Link Shield

    LukasKropf/IO-Link-Shield

    Das IO-Link-Shield für Arduino wurde an der BFH im Rahmen einer Projektarbeit erarbeitet. Dieses Repository enthällt alle wichtigen Daten zum Projekt.

    113 parts3GPL-3.0
  • 4 layers136.5 × 104.3 mmPDU, the printed circuit board in 3D

    PDU

    CASE-Lab/MARV-Hardware-Electrical

    Led driver with integrated eFuse and PWM dimming in a MIDI fuse format. Provides undervoltage cutoff for battery protection and a low standby current of 30 uA.

    196 parts2CC-BY-4.0