i2c-tiny-usb

http://www.harbaum.org/till/i2c_tiny_usb/index.shtml

Usage

When you plug it in, dmesg should report a new device. Here is my ouput of dmesg and lsusb -v.

Usage on the command line

i2cdetect

Get it on Arch Linux:

sudo pacman -S i2c-tools
sudo modprobe i2c-dev

Detect I2C devices:

i2cdetect -l

check detailed capabilities of device 3 ( /dev/i2c-3 ):

sudo i2cdetect -F 3

Till Harbaum's testapp:

sudo rmmod i2c_tiny_usb
cd ~/Downloads/i2c_tiny_usb/testapp
make
sudo ./i2c_usb

returns

--      i2c-tiny-usb test application       --
--         (c) 2006 by Till Harbaum         --
-- http://www.harbaum.org/till/i2c_tiny_usb --
Found i2c_tiny_usb device on bus 001 device 040.
Functionality = 7fff8eff0001
Probing for DS1621 ... failed
Probing for PCF8574 ... failed

philipp@lion:~/Downloads/i2c_tiny_usb/testapp$ sudo ./i2c_usb

--      i2c-tiny-usb test application       --
--         (c) 2006 by Till Harbaum         --
-- http://www.harbaum.org/till/i2c_tiny_usb --
Found i2c_tiny_usb device on bus 001 device 040.
Functionality = 7fff8eff0001
Probing for DS1621 ... failed
Probing for PCF8574 ... failed

Usage with Python

python module smbus from lm-sensors with kernel module i2c_tiny_usb: http://www.wiki.erazor-zone.de/wiki:linux:python:smbus:doc

sudo aptitude install python-smbus

and load module i2c-dev (creates devices /dev/i2c-x):

sudo modprobe i2c_dev

then run as root:

#!/usr/bin/env python
# -*- encoding: UTF8 -*-

from smbus import SMBus
b = SMBus(0) # 0 indicates /dev/i2c-0

b.read_byte(0x20)
b.write_byte(0x20,0xF0)

Programming

Version 2009-02-10: http://www.harbaum.org/till/i2c_tiny_usb/i2c_tiny_usb-2009-02-10.zip

Fuses They need to be set to "external crystal > 8Mhz" and the RESET pin has to be disabled in order to be re-used for application specific purposes. See Makefile-avrusb.tiny45 for more details.

firmware with avrdude use -C stk500hvsp as this sets the high-voltage serial programming mode for the Atmel STK500 (version 2.x firmware only).

use SCKT3400D1 of stk500 to plug in the attiny45 use hvsp (High-voltage Serial Programming) on stk500:

jumpers
OSCSEL on pins 1 and 2, mount jumpers: XTAL1, VTARGET, RESET PB3 pin (pin 4) on PORTB → XT1 pin (pin 7) on PORTE/AUX PB5 pin (pin 6) on PORTB → RST pin (pin 4) on PORTE/AUX PB0 and PB2 pins (pins 4 and 3) on SPROG1 → DATA0 and DATA2 pins (pins 1 and 3) on PROG DATA PB1 pin (pin 1) on SPROG1 → DATA1 pin (pin 2) on PROG DATA

Switch power on and you are ready to program.

cd ~/Downloads
wget http://www.harbaum.org/till/i2c_tiny_usb/i2c_tiny_usb-2009-02-10.zip
unzip i2c_tiny_usb-2009-02-10.zip

adjust Makefile in ~/Downloads/i2c_tiny_usb/firmware/Makefile to the serial port of your stk500, then make the hex and flash:

cd ~/Downloads/i2c_tiny_usb/firmware
make -f Makefile-usbtiny.tiny45 flash

I chose the USBtiny software implementation of the USB low-speed protocol instead of the obdev have a look at http://www.xs4all.nl/~dicks/avr/usbtiny/ → Other USB projects for a comparison.

Resources

Comments