Monday Experiment: Bootloading an ATmega32u4 with Arduino

ATmega32u4 Breakout

A month or two ago I ordered some of Atmel’s ATmega32u4 microcontrollers to play around with. I was excited to get them, but at the time I was really busy at work, so I quickly forgot about them. Last Friday I received some TQFP44 breakout boards and decided to spend some time this past weekend getting the Arduino bootloader and some example sketches up and running on the ATmega32u4. Turns out, it was pretty easy.

One oO

One of the big features of the ATmega32u4 is that is has a built-in USB interface. This means that it’s super simple to program (just connect a USB cable and you’re good to go). Now in order to upload Arduino sketches to it, I first had to burn the Arduino bootloader to it. Since I don’t have a programmer, I used an Arduino Uno.

The breakout boards for the ATmega32u4 I got from one of my favourite online shops; Dipmicro. I soldered the microcontroller using my hot air station. I could have used my soldering iron, but that’s less fun.

Once that was done, I uploaded the ArduinoISP sketch to my Uno. Then I put the 10uF capacitor between RESET and GND. I added the 32u4 to my breadboard and put a 1uF decoupling capacitor between pin 6 and GND. Then I added the 16MHz crystal and 22pF ceramic caps, wired the appropriate SPI pins, and wired all of the GND and VCC pins. Here’s a diagram of the wiring:


fritzing-atmega32u4-usb1

I believe that some of the VCC and GND connections are also made internally on the 32u4 but it doesn’t hurt.

Once it was all wired up, I plugged my Uno back into my laptop, opened the Arduino IDE, chose “Arduino Leonardo” from the list of boards, and hit “Burn Bootloader.” After about 20 seconds, it was finished.¬†Once¬†

Now, in order to test it, I removed my Arduino Uno. What I had now was a very basic Arduino Leonardo clone. I added an LED on pin 25 (digital pin 4), and a switch from the RESET pin (13) to GND. If you haven’t used an Arduino Leonardo before, they are a little tricky for loading sketches – you have to hold the reset button, hit Upload in the Arduino IDE, and then release the button. If you get an error, just try again.

Lastly, I added the USB connections. I used a stripped USB cable, which had four wires:

  • Black – GND
  • Red – 5V
  • Green – D+
  • White – D-

The GND and 5V, I connected to the power rails, and the data lines I connected to pins 3 and 4 through a 22ohm resistor. Pin 3 is D- (white) and pin 4 is D+ (green):

fritzing-atmega32u4-usb

With the wiring done, I plugged the USB cable into my laptop and switched back over to the Arduino IDE. I opened the Blink example, changed the LED pin to pin 4, held down the reset button, hit Upload, and let go of the reset button.

A few seconds later, my LED started blinking. Success.

 

13 Responses to Monday Experiment: Bootloading an ATmega32u4 with Arduino

  1. hello,
    herein u have shown programming via USB. Say, i wld like to do via a serial port.
    Can i connect a FT232 and do the job.

    Vinod.

    • It should work, yeah.

    • no u do not need to do that cuz. the ATMega32u4
      is not a mega AVR but a Atmel 8-bit AVR RISC-based microcontroller….
      it can program itself over a usb as it has Native USB Capabilities (after burning the bootloader….
      you will surely see arduino leonardo on your com port after you connect it using a simple usb cable…………………………….
      there is no way you can program it using the tx and rx pins of the ftdi chip.. if you need to program it externally you need an ISP (OR AVR ISP) OR USB ASP PROGRAMMER …….
      YOU ARE ACTULLY USING THE UNO AS ISP as the name suggests Arduino as ISP……….

  2. u have connected pin 2 to GND. Its UVCC.

  3. i don’t know the little trick from Leonardo. Big thanks!

  4. Hello,

    I am getting the message “yikes invalid device signature+arduino”

    Any tips pls.

    Vinod.

    • this error may be due to no proper selection of bootloader or not proper burning of bootloader.
      also make sure that you have connected a 16 MHz crystal ………

  5. Hello,

    I am able to upload the boot loader.
    But, I wanted to program the Atmega32u4 via UART(Tx/Rx) pins. Can we do that.

    Vinod.

  6. Thanks! I couldn’t get it running, turned out I forgot the capacitor at pin 6

  7. Thanks for the tutorial. I wasted my time trying other things that didn’t work.

  8. An awful lot of people are having problems with trying to program these 32u8 chip via USB. The Leonardo bootloader ONLY allows programming via USB. They need to change the bootloader to allow the FTDI option.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>