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.

 

37 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. thank you ! 🙂

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

  5. 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 ………

  6. 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.

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

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

  9. 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.

  10. It does not work for me unless I connected pin 7 (VBUS) to Vcc.

  11. i follow your methods to burn the bootloader to atmega32u4 and it sussess. But i insert the usb to my computer. The computer can’t find the serial port. it is nothing to happen. i don’t know what is the problem? do you have any idea? i really need help. Thanks very much

  12. Thanks! Only for me this setup didn’t work initially. I had to connect Vbus (pin 7) to VCC, which isn’t in the above schematic. After that it worked fine!

  13. After selecting “burn bootloader”, I am greeted with the error: “usbdev_open(): did not find any USB device “usb” bug”. Any thoughts on what I might try? Thanks!

  14. I followed your procedure and got the following response.

    Arduino: 1.6.7 (Windows 8.1), Board: “Arduino Leonardo”

    avrdude: Expected signature for ATmega32U4 is 1E 95 87
    Double check chip, or use -F to override this check.
    Wrong microcontroller found. Did you select the right board from the Tools > Board menu?

    This report would have more information with
    “Show verbose output during compilation”
    enabled in File > Preferences.

  15. Could you let us know which Version you were used and what’s the ArduinoISP.ino, i tried couple times but did not work?

    • This was written almost 3 years ago now but I think it was Arduino 1.0.3 or something similar. I haven’t worked with the 32u4 in a while (and not with the newer versions of the Arduino IDE) so I’m afraid I probably can’t be of much help here.

      What error are you getting? Have you made sure all the connections are made as per the diagrams above?

      • I got the same info. with Muhammad,
        avrdude: Expected signature for ATmega32U4 is 1E 95 87
        Ani am also confuse, Uno is using 328P, how will can program bootloader into 32u4?
        I check the connection again, which has followed your connection as well.But don’t know why?
        Maybe i can download old version to try it again.

  16. Hi!
    Thanks for the tutorial, it worked!

    But I would like to use the internal oscillator instead of the external crystal. Is it possible?

    • Glad to hear it worked! It should be possible but I’m not 100% sure if this would require a modification to the bootloader itself.

      At the very least you would need to modify the boards.txt file to create a new entry for the ATmega32u4. You would need to change the fuse bits in there to use the internal crystal and also change the clock divider. For the fuse bits you’ll need to find a fuse calculator to figure out which fuse bits to modify and what value to set them to.

  17. I will give it a try.
    Thank you again!

  18. Earvin Casillas

    I actually did exactly the same in this guide and it works perfectly! I’ll design another boards with atmega32u4 microcontroller based in this post, thanks a lot!

    • hi ! Earvin Casillas,
      I did follow this tutorial, but i got an error. Could you tell me which version of ArduinoIDE that you use? and What “programmer: ” did you selete before hit “burn bootloader”?

      Thanks
      Albert

  19. Dear Jeff,
    thank you so much for this article, its great.

    I just found this circuit on banggood and I was wondering if you may know how the layout looks like: http://www.banggood.com/CJMCU-Beetle-USB-ATMEGA32U4-Mini-Development-Board-p-970011.html

    Apparently there is no switch? So how is it possible to upload a sketch without a switch?

    In the Banggood forums someone posted this layout from which I am not sure if it is correct: http://forum.banggood.com/forum-topic-168420.html

    Your thoughts on that?

    • Howdy,

      I haven’t seen those guys before so I’m not positive. It might work without using the reset button, or you may need to add a reset button or just short the RES pin to GND. I’m not positive though and I would ask the seller if a reset button/switch is needed in order to upload the code.

  20. Can you describe how you burned the bootloader please? Which settings @arduino ide

  21. Works perfectly!!
    Thanks millon

  22. Did you choose 1. file-examples-ArduinoISP ?
    2. tools-programmer-AVR ISP?

    Then hit “Burn Bootloader” ?????

  23. Hi Jeff,

    I came across this article after searching for ISP Programming of 32u4 using Arduino Uno. You have wrote a nice blog.

    I want to tell you that I have a similar breakout board like yours. But I am finding it difficult to program.
    Please have look at this link (https://www.seeedstudio.com/Hardware-Development-Kit-for-Arduino-Leonardo-p-2520.html)
    I don’t have a programmer but I do have an Arduino Uno. It would be helpful if you let me know how to program it (pin-outs).

    Thanks in advance.

    Regards,
    Sushant Magoo

  24. I want to ask, can I burn Micro Pro’s bootloader in the ATMEGA32u4, when I follow these instructions?

  25. I had a lot of problems with burning Leonardo’s bootloader to ATMEGA32U4. Eventually, I traced all issues with my PCB. Once those are resolved, I was able to burn bootloader with Arduino Uno.

    With the same Arduino Uno connection (i.e. ICSP pins), I could not upload the sketch. It turns out that you just need to connect ATMEGA32U4 to computer with USB connection.

  26. Just tried this and it still works with 1.8.4. If you are having problems double check your connections, then triple check them. I had a few things wired wrong and had many of the same problems listed here.

    You should use “Arduino as ISP” for the programmer and upload the ArduinoISP to the UNO you are using as the programmer.

  27. I would like to just add to this Bootloading Atmega32U4. I thought i could upload a Blink sketch which i did, using the (Upload using programmer)from the File menu from the Arduino IDE after installing the bootloader. But it turns you are over writing the bootloader and you will not be able to use or upload any sketch with the USB.

Leave a Reply to Zulfidin Cancel reply

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