Digispark ATtiny85: Install and Setup. Easily save space using
this tiny chip to replace an Uno. Learn how to program this chip
using the standard Arduino IDE.
The Digispark ATtiny85...
...is really just an ATtiny85 with a software defined USB interface and...
Has 6 I/O pins.
Uses the Standard Arduino IDE, so it is easy to use.
No external chips to operate.
Uses an internally generated 16.5MHz clock (no need for external crystal).
There's no USB chip - it is all done in software!
The programming process has been tested for IDE versions (18/9/23):
1.8.19 (Reliable and old!).
2.1.0 ( Very new - a completely re-designed and re-coded IDE ) - the entire process below also works with this IDE.
Warning: After installation it looks like the USB interface is failing. Just start the programming sequence and plug in the Digispark.Note: You must be able to hear the USB connection sound when you plug in the Digispark - otherwise fix driver issues.
Digispark Attiny85 runs at 16.5MHz (with no external crystal) and has
6 I/O pins and connects to a USB port using a micro USB
connector. The
breakout board comes with an ATtiny85 chip pre-programmed with the
micronucleus bootloader.
If you need to save board space and only need a few outputs the this
chip is ideal. It works almost exactly the same way as an Arduino Uno
(and where it doesn't there are software modules to get round missing
internal modules).
For most trivial programs that you use you won't notice any
difference in writing code between the ATtiny85 and the ATMega328P
(Arduino Uno chip). The main difference is that the Flash is smaller in
size.
Digispark vs Arduino Uno internal hardware
There are three major differences:
Digispark (using the ATtiny85):
Does not have an Internal I2C hardware
Does not have an Internal SPI hardware
Does not have a 16-bit timer.
You can use a library to get bit-banged I2C operation.
It does have:
A 10bit ADC (the same as an Uno).
Two PWM channels (the Uno has more).
Two 8-bit timers (the uno also has a 16-bit timer).
A Serial module.
Bootloader
The great thing about this bootloader is that it makes a software
compatible USB interface inside the ATtiny85 - even when that chip has
no USB interface. By adding support libraries into the Arduino IDE you
can program this chip using the Arduino IDE system in a similar way to
other Arduino microcontrollers.
The rest of this page shows you a Digispark tutorial for installing
the Digispark drivers, checking that they are working correctly and
programming the device.
Warning: The Arduino IDE operation for the ATtiny85 is
not the same
as the connection operation for the Arduino - you will think that it is
not working. You do not have to select a serial USB port as you do with
the Arduino. It is all done on the fly. See below for details. Note: You
must be able to hear the USB connection sound when you plug in the
Digispark - otherwise fix driver issues.
Digispark ATtiny85 Bootloader Timeout
The way that the Digispark Attiny85 works is to use the Window Driver to
identify the Digispark but this can only be done for 5 seconds. After
the 5 seconds the bootloader becomes a dumb device and the program
control is transferred to the program just loaded.
Arduino IDE 1.8.8 (Windows Store 1.8.19.0)
It has been successfully programmed using Arduino 1.8.8 (Windows
Store 1.8.19.0). So a bug has been corrected since 1.8.7 (I think) did
not work in that IDE. Now tested on Arduino IDE 2.1.0.
Warning on Digispark operation
The interface can be finicky - I had this system working, then worked on another project and came back to the Digispark ATtiny85. The window 10 machine that had worked perfectly came up with the dreaded popup:
Warning: Even if you see these problems - the Digispark
interface is entirely different to normal USB operation so. Do all the
Digispark board and library installation and try to program it - it will
likely work (See Step 6 below). Note: You must be able to hear the USB connection sound when you plug in the Digispark - otherwise fix driver issues.
Warning "USB Device not recognized."
I tried the following:
Re-installing Digistump drivers (clicking on DPinst64 - for a 64 bit machine).
In device manager Deleting USB entries that correspond to the
ATtiny85 by Clicking the 'View' menu entry, then show hidden devices and
uninstalling the driver for those labelled "Unknown USB Device (Device
Descriptor Request Failed)".
Using zadig to install lib32-winusb on the unknown USB Device - no effect.
Uninstall Arduino IDE 1.8.5 and install a custom version of it
(DigistumpArduinoInstall1.5.8C.exe) - no effect. Went back to IDE 1.8.5.
Note: What actually worked was putting the USB cable into a different
socket on my USB HUB with 7 extra USB ports.
Note2: On my second notebook (Windows 10). Two direct USB ports,
built into the machine, came up with the "USB Device not recognised"
message. Plugging a powered Hub (the same one from the other machine)
allowed the Digispark to connect correctly!
In the Digispark Attiny documentation it is recommend that a powered USB hub
is used so that you don't accidentally blowup the USB port in the PC.
Device Manager - Digispark Not Found
If you have a problem you'll see a message ("Unknown USB Device.") in the Windows Device Manager like this:
Device Manager - Digispark Attiny85 Driver Is Found
For successful Digispark ATtiny85 detection you will see this (message is
libusb-win32 Devices, digispark bootloader - after the highlighted line "Keyboards" below). This appears after you plug
in the Digispark to a USB port:
TIP: If you don't see the above libusb-win32 devices
after installing the digistump drivers goto the top menu, click view and
check "Show hidden devices".
What if libusb really won't show up?
The following resource allowed the libusb-win32devices> Digispark
Bootloader (as in the image above) to re-appear (I deleted it
incorrectly):
https://digistump.com/board/index.php?topic=248.0
I have copied the information from the above link above as it is labelled as unsecure:
"First, I had a lot of trouble getting 64-bit Windows 7 to recognize
the digispark. I had installed the driver using the supplied
installation tool, but windows seems to have two "levels" of
installation. The first is "give windows a driver file to use if
it ever encounters this sort of device," and the second is "tell windows
I am using this sort of device and it needs to load the relevant driver
file." (This is why, when you are uninstalling a device driver,
there's a checkbox for "also delete the driver files"; typically it only
removes the second-level installation, but the checkbox forces it to
remove the first-level installation too.) The installer program
achieved the first level of installation, but not the second; and
Windows couldn't make the transition to the second level fast
enough. When the digispark, after five seconds, switched from
appearing as a USB device to just running the "blink" sketch, Windows
would abandon trying to load the driver and say instead that the device
was malfunctioning.
The fix for this was to manually run the "install hardware wizard" as
though the digispark were not a plug-and-play device, forcing the driver
into the second-level installed mode. The steps for this are to
choose run from the start menu, type "hdwwiz", press enter, click
"next," chose "install the hardware that I manually select from a list,"
click next, choose "all devices," click next, wait for the hardware
list to appear, scroll to "Digistump," select "Digispark Bootloader,"
and click next twice more.
This is the only way I was able to get my computer to recognize the
digispark. After doing this once, everything worked the way I
expected."
TIP: When all else fails - if you don't hear the USB
connection sound when plugging in a Digispark - try a new cable - I had a
dud but it powered the Digispark - but did not connect the data!
ATtiny85 Arduino install Steps
1. Install the Arduino IDE
An easy way is to search the Microsoft Apps store in windows 8.1 or
10 and search for Arduino. Install the app. Alternatively download the
executable installer here. The latest one is 1.8.8 and it does work with Digispark.
2. Install Digispark Attiny85 Windows Drivers
Download the Digispark Attiny85 windows drivers here.
(This is the 1.67 Feb 13 2016 release found here.)
Download Digistump.Drivers.zip and unzip to your hard disc. Then double
click on DPinst (32 bit PC) or DPinst64 (64 bit PC) depending on your system (mine is 64bits).
You should now check that windows can see the Digispark - Just plug
in the Digispark usb (micro usb connector) and you will hear the USB connection sound. If windows
complains saying "USB Device not recognised." then you will need to fix
this before going further - the IDE has nothing to do with this part.
The problem is that you have to install drivers in order for windows
to correctly identify and communicate with the micronucleus device. If
you have problems have a look here.
3. Set up Digistump for the IDE
To allow Digistump boards to be seen by the Arduino IDE you need to
insert a line of code in the Menu > File > preferences window as
shown below:
The line to insert in the "Additional Boards manager URLs" box is:
>>>>http://digistump.com/package_digistump_index.json DEAD as of 10/3/24.
Click here to see contents of the package_digistump_index.json file.
As noted above digistump.com is Dead.
Setup boards manager without digistump.com
How to setup the digistump.json file even though digistump.com is dead as of 10/3/24.
The solution to add the boards manager json file is:
Add a local copy of the .json file.
Open the link above (which is a copy of the json file) and save the contents to a local text file and
rename it "package_digistump_index.json". Now place the file in a known
place on your hard disk. I used:
file:///C:/jfm/package_digistump_index.json
I used a directory on my hard disk but you can use anything e.g.:
Replacing YourUsername with your user name! Now copy and paste that
line above beginning "file:", into the "Additional boards manager URLs"
below, instead of the one beginning "http://digistump.com". When you
exit the preferences page the file will be loaded (see popup
notification).
If you have more than one of these lines click the double-box symbol
to the right of that entry box and add each entry one per line.
4. Select a Digispark Board or Mode
You won't see any examples for Digistump in the Menu > File >
Examples until you select the Digispark board in Menu > Tools >
Boards.
From that menu select the board labelled:
Digispark (Default - 16.5MHz)
Note:
The Digispark Pro is a different board that
uses a bigger chip: an ATtiny167 20 pin chip (and is slightly easier to
use). However once you have got the drivers going the Digispark is
fairly easy to program.
Install the Digistump Boards
First click Tools > Board > Board Manager
Now search for the digistump board library and click install.
Selecting the Digispark Board
5. Select a Digispark Attiny85 Example
The examples will now be available from the Examples Menu: File > Examples > Digispark_Examples.
It does not matter
which example is used, but one that does not do too much is the Infrared one -
you don't need to attach an infrared receiver - you are only going to go
through the process of programming it - to get used to the process. You
can if you want to though - just use a standard IR receiver.
Go back to the Arduino IDE Menu > File > Examples > Digispark_Examples
And choose the Infrared example.
Now you will see the following code in the Arduino IDE.
This is simple code that does not attempt to decode the IR signal it
just reacts if any signal is received by flashing the built in LED. If
it does not flash the LED is on pin 1 - newer boards use this as the LED
pin.
You don't need the IR receiver - this is just to see the programming process - the program is irrelevant.
In my new window 10 machine I re-installed all of the above and then
it all appears to fail - the device manager continually alternates
between device found (sound) and device disconnected (sound). Just
forget all that, the programming of the Digispark is completely
different to a normal Arduino device. Just start the programming sequence then plug in the Digispark to the USB cable!
Warning: After
installation it looks like the USB interface is failing. Just start the
programming sequence and plug in the Digispark. Note: You must be able
to hear the USB connection sound when you plug in the Digispark -
otherwise fix driver issues.
There are two parts to programming the board
Start the compile and upload process as you usually do for the Arduino.
Plug in the Digispark ATtiny85 to initialise USB detection.
1. Normal Arduino Compilation
To start digispark attiny85 programming hit the compile and upload button or press Ctrl-u.
Once uploading starts you will see the following information in the status box at the bottom of the Arduino IDE:
Sketch uses 700 bytes (11%) of program storage space. Maximum is 6012 bytes.
Global variables use 9 bytes of dynamic memory.
Running Digispark Uploader...
Plug in device now... (will timeout in 60 seconds)
> Please plug in the device ...
> Press CTRL+C to terminate the program.
2. Micronucleus USB Detection and Upload
At this point you need to plug in (or unplug and re-plug in the
Digispark Attiny85). Then you will see the following status output:
Sketch uses 700 bytes (11%) of program storage space. Maximum is 6012 bytes.
Global variables use 9 bytes of dynamic memory.
Running Digispark Uploader...
Plug in device now... (will timeout in 60 seconds)
> Please plug in the device ...
> Press CTRL+C to terminate the program.
> Device is found!
connecting: 16% complete
connecting: 22% complete
connecting: 28% complete
connecting: 33% complete
> Device has firmware version 1.6
> Available space for user applications: 6012 bytes
> Suggested sleep time between sending pages: 8ms
> Whole page count: 94 page size: 64
> Erase function sleep duration: 752ms
parsing: 50% complete
> Erasing the memory ...
erasing: 55% complete
erasing: 60% complete
erasing: 65% complete
> Starting to upload ...
writing: 70% complete
writing: 75% complete
writing: 80% complete
> Starting the user app ...
running: 100% complete
>> Micronucleus done. Thank you!
Notice that the version of micronucleus firmware is 1.6. This can be upgraded to get more space by reprogramming the bootloader.
7. Digispark LED Flash Test program
Here is a program to just flash the on-board LED. Re-program the
Digispark and check the led flashes (New Digisparks have the LED on pin
1, older ones have the LED on pin 0).
Now you should be familiar with the Digispark ATtiny programming process.
To save flash memory that is used by the Digispark ATtiny85 USB bootloader you can program the chip using an AVRISP
(or use an Arduino as an AVRISP) and program the chip directly through
SPI. This is a bit more involved but saves you all the Flash memory used
by the USB bootloader.
Conclusions
You will think that the USB interface is failing as it
oscillates from (success (USB sound for good USB device) to disconnect
(USB sound for bad device). It is not. Just ignore that - if you have
installed the drivers and board.
Warning: After
installation it looks like the USB interface is failing. Just start the
programming sequence and plug in the Digispark. Note: You must be able
to hear the USB connection sound when you plug in the Digispark -
otherwise fix driver issues.
All you do is start the programming sequence - then plug in the
Digispark; Magically the board is detected and programmed - try
the LED flash to see it work.
Once you have got over this problem the board works easily and well with the Arduino IDE.
How to get accurate DHT22 digital humidity sensor readings with an Arduino. Did you know it also measures temperature as Well? Find out why, in this page...
A PIR sensor lets your Arduino sense movement without contact. This tutorial covers PIR sensor basics, connecting one to an Arduino board and coding a motion detector.
Arduino Hall Effect Sensor: Add magnetic sensing superpowers to your Arduino projects with an easy-to-use hall effect sensor. With full code and layout...
Comments
Have your say about what you just read! Leave me a comment in the box below.
Don’t see the comments box? Log in to your Facebook account, give Facebook consent, then return to this page and refresh it.