DigiSpark is one of the cutest Arduino-related widgets around. It’s about the size of a postage stamp, plugs straight into your USB port and will probably cover most of your microcontroller project needs. The problem is that it doesn’t seem to play nice, out-of-the-box with 64-bit Ubuntu Linux.
The DigiSpark isn’t a particularly New Thing – it was a KickStarter project from August 2012. Since it’s Open Hardware, the inevitable happens and some people in Shenzen have taken the board layouts and started cranking out the hardware super, super cheap.
Here’s How I Got It Working
- Install the standard Arduino IDE for 64-bit Linux. This is version 1.5 at the time of writing.
- Follow DigiSpark’s instructions for adding their extensions to the Arduino IDE.
- You should now see something like this listed when you lsusb:
16d0:0753 MCS Digistump DigiSpark.
- This is specifically for 64-bit Linux (Ubuntu 14.04LTS) at the time of writing: Download the Arduino IDE programmer binary for 64 bit here and use it to replace the version that you have in
~/.arduino15/packages/digistump/tools/micronucleus/2.0a4(your mileage might vary a little, but you get the idea). If you want to build this yourself (I would totally understand if you did), here’s the source to that binary.
Bootnote 1 – What’s So Cool About Yet Another Arduino
- DigiSpark is very, very small. 2.7×1.9cm and that includes the USB connector. Being so tiny you can take advantage of Dirty Board PCB’s manufacturing at $14 shipped for 12 5x5cm PCBs for making ‘motherboards’ for the DigiSpark. I say ‘motherboard’ rather than ‘shield’ here since your PCB is likely to be a fair bit larger than the DigiSpark itself.
- It’s got great power supply options with a beefy regulator that accepts up to 35V(!) input and supplies up to 500mA (presumably not when feeding with 35V since it’s an oldskool 7805 linear regulator). So that’s really cool for automotive (nasty power supply that’s often at almost 15V and spikes around), machine shop (24V), and solar (18V or more on open circuit for a nominal ’12V’ panel).
- DigiSpark clones from China / eBay are about $2 delivered. (Sorry to the DigiSpark creators, I’d love to support you by buying from you, but in Spain we just can’t afford that luxury right now since the country is in about as good economic shape as Greece.)
- You’d be amazed how many of your microcontroller jobs can be done with 6 I/O pins.
- DigiSpark has its own USB interface, unlike, say Arduino Pro Mini.
Bootnote 2 – First Program With DigiSpark
The first thing to note that’s a bit weird / different with the DigiSpark as opposed to the normal Arduino is that you need to leave the device / target normally unplugged from USB, then you press Upload on the IDE, then you plug it in, the programmer detects the device and uploads your program. I.e. you can’t just leave the gadget permanently plugged in at the end of the USB cable while you make change after change – it’s slightly annoying but I can live with that. I’d recommend a USB extension cable for convenience and so as to not put too many miles on your PC’s USB connectors. Generally I found the programming to be a bit flaky with quite a lot of unplugging and replugging to get the program uploaded at times. At other times it Just Worked first time.
I ordered three of the Chinese clones at once. Good thing since I killed the first one after about an hour of playing. Since I was only messing with the Blink program, I’m guessing that it’s early death was more due to Shenzen sweatshop quality control standards rather than a deep-seated design defect in DigiSpark itself.
Apparently there’s a Model A and a Model B DigiSpark. They have subtly different wiring regarding how the onboard LED is connected (pin 1 for Model A and pin 0 for Model B) and I2C compatibility (Model A is out-of-the-box I2C compatible). Boy, that’s a bit confusing. Using the following variant of the Blink program I determined that the devices I got from China are the Model A variant – which is good since I’m most likely to be hooking things up via I2C since there are, after all, only 6 I/O pins on this little beastie.
// Fast blink (ten times a second): Model A
// Slow blink (once a second): Model B
#define PIN_LED_MODEL_A 1
#define PIN_LED_MODEL_B 0
#define DELAY_MILLISECONDS 50
for (int i = 0; i < 9; i ++)
The pinout is silkscreened on the back of your board, but for completeness any of the five pins can be used for digital I/O and there are some specific capabilities / wiring for each pin:
- 0: I2C SDA, PWM (LED on Model B)
- 1: PWM (LED on Model A)
- 2: I2C SCK, Analog
- 3: Analog In (also used for USB+ when USB is in use)
- 4: PWM, Analog (also used for USB- when USB is in use)
- 5: Analog In