Build a cheap, flexible AVR microcontroller programming target board

Programming AVR microcontrollers using ISP is a simple process when the target is on a board exposing a 6 or 10-pin ISP header.  But what if you have different types of AVR chips? Their SPI pins (VCC, GND, MOSI, MISO, SCK) aren’t always in the same locations.

Instead of buying different types of target boards or buying an expensive generic programmer, I built one using a small breadboard, a Universal 28 pin ZIF DIP socket and 6 male-male hookup wires that I connected to my USBtinyISP programmer.

The following steps detail the assembly process:

  • Align the first row of pins on the ZIF socket with the first row of pins on the breadboard: this will make it easier to match the SPI pins on the microcontroller with the ISP connector pins later
  • Make sure that you have room for hookup wires on both sides of the ZIF socket
  • Insert the ZIF socket into the breadboard
  • Ensure that your ISP programmer is disconnected from your computer
  • Insert one end of the hookup wires into the 6-pin cable connector like this:

  • Using the datasheet for the AVR chip you want to program, find the pin numbers of the VCC, GND, MOSI, MISO and SCK pins. For example, the ATtiny85 shown in the picture above has the following pin out:

  • Insert the other end of the hookup wires into the breadboard according to chip’s pin out.
  • Connect your AVR programmer to your computer.
  • Using avrdude, type the following command:  C:\avrdude -c usbtiny -p t85.
  • You should get this output if everything was connected properly:

avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e930b
avrdude: safemode: Fuses OK
avrdude done. Thank you.

I’ve successfully tested this target board with an ATtiny85, ATtiny84 and an ATmega368 / ATmega168:

ATtiny84

C:\avrdude -c usbtiny -p t84
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e930c
avrdude: safemode: Fuses OK
avrdude done.  Thank you.

ATmega328p

C:\avrdude -c usbtiny -p m328p
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.16s
avrdude: Device signature = 0x1e950f
avrdude: safemode: Fuses OK
avrdude done.  Thank you.

So, what happens if  the ISP connector is connected to the wrong pins on the microcontroller?

Not much really: the USB bus on your computer may shut itself down, requiring a computer reboot or avrdude will fail to communicate with the chip. In either case, make sure that the ISP programmer is always disconnected from your computer before switching chip types or changing the position of the hookup wires in the breadboard and triple-check your hook-up wire connections against the datasheet of the target chip!

Happy hacking!

Advertisements

Homemade WiFi-enabled home thermostat

A year ago, we moved into our new home in Redmond and the house furnace was still controlled by an ancient thermostat, built using Cold War era technology and I set out to replace it with something better… While an off-the-shelf thermostat would have worked as a replacement, I wanted more!

  • I wanted to be able to control the temperature of the house from anywhere using a web browser
  • I wanted to get interesting energy consumption statistics to measure the effectiveness of our home improvements

Last week, I finally achieved the first step and here’s what the interface looks like right now:

Temp=20.50C / 68.89F
Heat=ENABLED
Relay=OFF
Heat Timer=0 mins
Turn Heat Timer ON or OFF
Disable or Enable Heat

The thermostat is built with an Arduino Duemilanove board, upgraded with an Atmega328 chip, a WiShield board, a Maxim DS1822 temperature sensor and a 5v relay to switch the furnace on/off.

WiFi Thermostat.

The code, in progress, is available here