Arduino Uno R3 as HID: Difference between revisions

From SGMK-SSAM-WIKI
Jump to navigation Jump to search
No edit summary
Line 27: Line 27:


Download the latest firmware from [https://github.com/arduino/Arduino/blob/master/hardware/arduino/firmwares/atmegaxxu2/ GitHub]. The file is called  
Download the latest firmware from [https://github.com/arduino/Arduino/blob/master/hardware/arduino/firmwares/atmegaxxu2/ GitHub]. The file is called  
[https://github.com/arduino/Arduino/blob/master/hardware/arduino/firmwares/atmegaxxu2/Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex] at the time of writing. You will have to open the file on GitHub and download it as raw. Otherwise, the flashing will fail with the error message: "Error parsing the line."
[https://github.com/arduino/Arduino/blob/master/hardware/arduino/firmwares/atmegaxxu2/Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex] at the time of writing. You will have to open the file on GitHub as raw and save it locally with your browsers' "save" function. If the hex is stored in a wrong format locally, the flashing will fail with the error message: "Error parsing the line."


Open a terminal and change to your download directory.
Open a terminal and change to your download directory.

Revision as of 10:16, 26 August 2014

Overview

To change your arduino into a usb HID device - for example a USB-keyboard - you will have to load a new firmware on the ATMEGA 16U2 chip on your Arduino board. That is the small square chip just behind the USB port on the board. This procedure is called DFU-programming or updating the firmware.

Updating the ATMEGA 16U2

First step is to reflash the ATMEGA 16U2 so we know that our setting is actually working. This instructions are based on some useful sites and forum hints on the web: - Updating the Atmega8U2 and 16U2 on an Uno or Mega2560 using DFU - Arduino-forum: Using Uno R3 on Linux? And some more hints in different forums I cannot recall already.

Install dfu-programmer

Download dfu-programmer from your distribution repos. For Ubuntu and Debian:

sudo apt-get install dfu-programmer

Once installed, check the version with

dfu-programmer --version

It has to be at least 0.6.1 for the following steps to work. If it's not, download the programmer directly from the authors: DFU-Programmer at GitHub


Reset 16U2

The Arduino Uno R3 (I'll call it just R3 from now on) comes with pin headers for the 16U2. To reset the chip, connect the two pins closest to the usb-port.

Flash ATMEGA 16U2

The following instructions are for linux OS's.

Download the latest firmware from GitHub. The file is called Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex at the time of writing. You will have to open the file on GitHub as raw and save it locally with your browsers' "save" function. If the hex is stored in a wrong format locally, the flashing will fail with the error message: "Error parsing the line."

Open a terminal and change to your download directory.

Check if the programmer sees the 16U2:

sudo dfu-programmer atmega16u2 dump

You should get a gazillion of qustion marks on the terminal as a response.

Erase the chip, upload firmware and reset:

sudo dfu-programmer atmega16u2 erase
sudo dfu-programmer atmega16u2 flash Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex
sudo dfu-programmer atmega16u2 reset

Unplug your Arduino and plug it back in. It should work as before. Try uploading a sketch from the Arduino environment to check.