Digispark

From CommonsLab
Jump to navigation Jump to search

The Digispark is a miniature version of a partly Arduino-compatible micro-controller board. It uses the Atmel ATtiny85 chip as processor and it includes a bootloader, called Micronucleus, which also emulates a USB communication port during the boot sequence, so that the chip can be flashed via USB from any PC with USB port, without the need for a special programmer.

To flash the Micronucleus bootloader onto the ATtiny85 for the first time, an Arduino UNO as ISP programmer is needed - unless the bootloader has already been written onto the ATtiny by the manufacturer. With the Arduino UNO connected to the MOSI/MISO/CLK/GND/5V pins correctly you have to run the following command from the command line: (Note that the back-slash denotes that the command continues on the next line!)

/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf \
-v -v -pattiny85 -cstk500v1 -P/dev/ttyACM0 -b19200 \
-Uflash:w:~/Programs/micronucleus-2.01/firmware/releases/t85_default.hex:i \
-U lfuse:w:0xe1:m -U hfuse:w:0xdd:m -U efuse:w:0xfe:m 

The above assumes that you have Debian GNU/Linux with the Arduino IDE installed at the standard locations and that the Arduino UNO is connected to the USB port at the /dev/ttyACM0 location.

After having written the Micronucleus bootloader onto the ATtiny, you can use the [special upload tool] or the familiar Arduino IDE. To use the Arduino IDE, you have to import the Digispark into the Board Manager of the Arduino IDE version 1.6.5 (or later) by adding the following into Preferences > Settings > Additional Board Manager URLs:

https://raw.githubusercontent.com/digistump/arduino-boards-index/master/package_digistump_index.json

After that, you can select to install the "Digistump AVR Boards", which includes the Digispark. When you now want to upload your sketch to the Digispark (or compatible) you have to select "Digispark - Default 16.5MHz" from the Tools > Board menu and select "Micronucleus" from Tools > Programmer.