Getting started with the ATTiny85 and the AVR USB ISP MkII

It doesn’t take long to want to move from Arduino to more embedded uses for the Atmel MCU’s.  I got an ATTiny85 the other day and a AVR USB ISP MkII as well. Time to see if I can get the leds blinking?!

First off I had to get the Arduino IDE ready for ATTiny’s..

Installing ATtiny support in Arduino

  • Download: ATtiny (from this GitHub repository)
  • Locate your Arduino sketchbook folder ( ~/sktechbook/)
  • Create a new sub-folder called “hardware” (if it doesn’t exist already!) in the sketchbook folder.
  • Copy the attiny folder from inside the .zip to the hardware folder.
  • Restart the Arduino development environment.
  • You should see ATtiny entries in the Tools > Board menu.

Now time to wire up the ISP.. Remembering that Rst (pin 1 on the Tiny85) has to be held high via a 4K7 resister, and the ATTiny85 needs to get power from somewhere.  The ISP won’t power the circuit. No KiCAD today, just pen cad!

Pin-outs for the ISP and ATTiny85

Pin-outs for the ISP and ATTiny85

I has a RGB LED lying around so I hooked it up to the ATTiny.  Red to PWM0 (pin 5) and green to PWW1 (pin 6).

AVR USB ISP MkII connected to a ATTiny85

AVR USB ISP MkII connected to a ATTiny85

Easy and quick.. there is something very cool about a two colour pulsing LED, or is it just me?

i2c 8 channel IO board with relays

With all these MCU’s needing to connect to real world stuff.. electric valves, heaters, motors and the like. I need a versatile IO board that I can hook up to an Arduino, Raspberry PI, Beaglebone or Carambola.  All of which have an i2c bus. So armed with a MCP23017, I’ve come up with this IO board.

  • 8 Relay outputs ( relays are spec’ed at 240V 5A )
  • 8 Digital inputs ( switched input, closing to ground )
  • Selectable i2c address ( up to 8 of these on the one i2c bus )
  • All running from +5V ( relays can be powered from an alternative power supply if 5V coils are not to hand )
  • Single layer, through hole construction ( old skool! )
i2c Relay Board - schematic

i2c Relay Board – schematic

I’m loving KiCAD… Over the last few schematic captures I now have a handle on libraries, this time I got my head around modules as I couldn’t find the pads for the relays I wanted to use.  Even better, I managed to layout the board on a single sided PCB! Here it is:

i2c Relay Board - PCB

i2c Relay Board – PCB.

All the files are here: i2cRelayBoard

Now I’ve got to get all the clobber to make my own PCB’s… It’s been a while since I’ve had to do that…!

Interfacing the Carambola (1-Wire and I2C)

Got my Carambola just after New Years day.. Thought it was about time to see what I could do with it!

Wanted to look at the i2c bus and 1-wire to see if I could get the heating control project ported from the BeagleBone over to the Carambola. The module came with a stock OpenWRT install from what I could make out.  Neither I2C, GPIO or 1-Wire worked so followed the Wiki over at, downloaded the source and got building.

I’m on my fifth or sixth recompile/build! But I guess it goes with embedded territory, every module has to be build and a new image installed. At the moment I can’t figure out how to get the repositories for opkt working to install packages on the live system. The system build tools work out of the box and are easy to get to grips with. The only thing that slows one down is finding the correct options in the “make menuconfig”. But once again the Wiki has good instructions. On my current build for this test I have i2c, gpio and 1-wire installed.  Here are the links for the three steps:

1) i2c can be found in the PCF8575 example.
2) GPIO can be found in the Simple GPIO control, but watch out the gpioctl program is no longer available so you have to do everything using the /sys filesystem!
3) 1-Wire stuff can be found in the 8devices forum. (I’ve included the patch, which works fine on the latest kernel, in the resources zip file at the bottom.)

KiCAD time (all the KiCAD files for this are in the resource ZIP file at the end of this post).

Carambola electrical test schematic

Carambola electrical test schematic

Soldering some 0.1inch headers on to the Carambola helps!

Carambola GPIO headers

Time to bread-board the circuit up:

Carambola electrical test setup on the breadboard

Carambola electrical test setup on the breadboard

The upper few rows of the breadboard are for the 1-Wire, the rest is the I2C MCP23017.

So lets see if the MCP23017 is on the i2c bus..

root@OpenWrt:~# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- 24 -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

Yep, at 0x24, cool.. For this test I’m just going to make all of port A outputs and all of port B inputs (you can do much more with the registers inside the MCP23017, but lets keep it simple!). First thing to do is adjust the MCP’s registers to suit:

root@OpenWrt:~# i2cset -y 0 0x24 0x00 0x00
root@OpenWrt:~# i2cset -y 0 0x24 0x16 0xff

The first line sets port A as an output port, the second enables the internal pull-ups (100K) on port B, which is input by default.

Switching on any of the three LEDs is easy, just write the bit pattern to register 0x09 (GPIOA).. so for the first LED we’d need to do this:

root@OpenWrt:~# i2cset -y 0 0x24 0x09 0x01

For the second:

root@OpenWrt:~# i2cset -y 0 0x24 0x09 0x02

I’m sure you see where this is going…

To read the bit pattern on port B is easy.  We just need to read register 0x19 (GPIOB).

root@OpenWrt:~# i2cget -y 0 0x24 0x19
0xff    <- if switch is open
0xfe    <- if switch on pin GPB0 is closed

The 1-Wire is as easy as always under Linux, just look in the /sys/devices/w1_bus_master1 and you should see a folder for each of the 1-Wire DS18B20’s you have connected to the bus.

All the stuff you should need for this is here: Carambola_test (zip file).  In the zip file you’ll find the KiCAD schematic and library of the Carambola header, MCP23017 and the DS18B20.

My KiCAD version of USBtinyISP

I’m looking to make a USB AVR ISP, Eagle files are easy to find, so I thought I’d do a KiCAD version. The circuit is the same used by Ladyada, although the board is not designed to fit into the same box! I’m loving KiCAD, this took about two hours to do schematic capture and PCB layout.

USB AVR ISP - Schematic

USB AVR ISP – Schematic

PCB layout…USB AVR ISP - PCBAll the files needed are here: USB_AVR_ISP. Time to get making!