Skip to main content

DigiSpark With 64-bit Ubuntu

DigiSpark . It’s about the size of a coin, 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 to get it Working on Linux

  • 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 Rev 1 and a Rev 2 DigiSpark. They have subtly different wiring regarding how the onboard LED is connected (pin 0 for Rev 1 and pin 1 for Rev 2 (and Rev 4)) and I2C compatibility (Revs 2/4 are 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 Rev 2 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): REV 1
// Slow blink (once a second): REV 2
#define PIN_LED_REV_1 0
#define PIN_LED_REV_2 1
#define DELAY_MILLISECONDS 50
void setup()
{
pinMode(PIN_LED_REV_1, OUTPUT);
pinMode(PIN_LED_REV_2, OUTPUT);
}

void loop()
{
for (int i = 0; i < 9; i ++)
{
digitalWrite(PIN_LED_REV_1, HIGH);
delay(DELAY_MILLISECONDS);
digitalWrite(PIN_LED_REV_1, LOW);
delay(DELAY_MILLISECONDS);
}
digitalWrite(PIN_LED_REV_1, HIGH);
digitalWrite(PIN_LED_REV_2, HIGH);
delay(DELAY_MILLISECONDS);
digitalWrite(PIN_LED_REV_1, LOW);
digitalWrite(PIN_LED_REV_2, LOW);
delay(DELAY_MILLISECONDS);
}
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 Rev 1)
  • 1: PWM (LED on Rev 2 and Rev 4)
  • 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

Comments

Popular posts from this blog

What is the ESP32 VSPI / HSPI

 The ESP32 integrates four SPI peripherals. SPI0 and SPI1 are used to access the ESP32’s attached flash memory and thus are currently not open to users to be used . They share one signal bus via an arbiter. SPI2 and SPI3 are general purpose SPI controllers, sometimes referred to as HSPI and VSPI, respectively. They are open for use. SPI2 and SPI3 have independent signal buses with the same respective names. Each bus has three CS lines to drive up to three SPI slaves.  

Most common baud rates table

  The following table shows the most used baud rates. The left side part of the table shows speed and bit duration. The right part shows real transmission speed assuming there is no parity, 8 data bits and one stop bit.   Bauds Bits/s Bit duration Speed Actual speed Actual byte duration 50 bauds 50 bits/s 20.000 ms 6.25 bytes/s 5 bytes/s 200.000 ms 75 bauds 75 bits/s 13.333 ms 9.375 bytes/s 7.5 bytes/s 133.333 ms 110 bauds 110 bits/s 9.091 ms 13.75 bytes/s 11 bytes/s 90.909 ms 134 bauds 134 bits/s 7.463 ms 16.75 bytes/s 13.4 bytes/s 74.627 ms 150 bauds 150 bits/s 6.667 ms 18.75 bytes/s 15 bytes/s 66.667 ms 200 bauds 200 bits/s 5.000 ms 25 bytes/s 20 bytes/s 50.000 ms 300 bauds 300 bits/s 3.333 ms 37.5 bytes/s 30 bytes/s 33.333 ms 600 bauds 600 bits/s 1.667 ms 75 bytes/s 60 bytes/s 16.667 ms 1200 bauds 1200 bits/s 833.333 µs 150 bytes/s 120 bytes/s 8.333 ms 1800 bauds 1800 bits/s 555.556 µs 225...

How to program 8051 based MCU using Ptroteous Schematic capture and Source code editor to use timers using AT892051 + project files

 This tutorial is dedicated to use a 8051 based Microcontroller core and program it using keil's C51 tools on the Proteus Source code editor.  1- Brief History of 8051 one of the first microprocessors 4004 was invented by Intel Corporation as well as  8085 and 8086 microprocessors back in 1981,shortly after Intel introduced an 8-bit microcontroller called the 8051 . It was referred to as system on a chip because it had 128 bytes of RAM, 4K byte of on-chip ROM, two timers, one serial port, and 4 ports (8-bit wide), all on a single chip. When it became so widespread, Intel allowed other manufacturers to make and market different flavors of 8051 with its code compatible with 8051. It means that if you write your program for one flavor of 8051, it will run on other flavors too, regardless of the manufacturer. This has led to several versions with different speeds and amounts of on-chip RAM. 2- Features of AT892051 Microcontroller Compatible with MCS®-51Products 2K ...