Adding analog input to the Pi using the Digispark

Lead Image © Dietmar Hoepfl ,

Analog Pi

Analog input needs special treatment in the digital Raspberry Pi world. We show you what you need to do to get analog data into your Rasp Pi via the USB port.

My original project was simple enough: I wanted to use an analog dial – like one you would find on a safe. A program on the Pi would then set the combination. By twiddling a knob, a user would input a guess and, if it matched, the Pi would flash a green LED and unlock a hypothetical safe, door, or whatever. If the combination was wrong, the Pi would flash a red LED and the user would have to try again.

A Road to Nowhere

The plan was to use the analog pins on the Raspberry Pi – which was the first problem: The Raspberry Pi has no analog pins. So, although it can send out messages (i.e., make LEDs blink), as far as receiving information from the outside world, it's as blind as a bat, or at least severely colorblind. Although I looked for workarounds, the Pi is a purely digital machine. I googled to see how other people have done this sort of thing and discovered they use an extra piece of hardware called an ADC (analog-to-digital converter) [1]. When you clip the ADC onto a breadboard, it translates the analog signals from your sensors into something the Pi can understand. Although I could have ordered an ADC, I didn't have the time to wait for delivery.

Being a Kickstarter junkie, though, I did have three Digisparks [2] – coin-sized, Arduino-like development boards  – lying around. I bought them for US$ 8 a pop when the guy making them was crowdfunding, but I had never used the Digisparks (Figure 1), because I realized that, to do so, I would have to solder bits onto them.

Figure 1: The tiny Digispark – some assembly required.

For someone who usually needs help unsticking his fingers whenever he busts out the superglue, the prospect of messing around with hot, molten metal was terrifying. Desperate times require desperate measures, however, and I had a hardware store nearby where I could get a soldering iron and some solder in five minutes.

Burning Down the House

Soldering is more difficult than I thought. The ladies of Adafruit [3] do this kind of thing in their videos all the time, daintily touch their soldering irons to the pins of tiny components and magically connecting everything together.

With the Digispark, you have to solder the six-pin female header to the I/O pins along the top of the device and a three-pin header to the 5V, ground, and VIN pins that run along the side. After ruining my first Digispark trying to do just that, I got lucky the second time around and even managed not to make the joints look too messy. Although I was pleased with myself, my wife was not impressed.

Buy this article as PDF

Express-Checkout as PDF

Pages: 8

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Get your Pi to read analog data

    The Raspberry Pi still lacks analog GPIOs that would allow it to read directly from temperature and light sensors, or even humble potentiometers. With an inexpensive chip and some software-fu you can grant the Pi the gift of analog sensing.

  • A home intrusion detection setup (sort of)

    At least part of the popularity of the Raspberry Pi can be attributed to its high maker value; that is, a skilled maker with a Pi can build marvelous and beautiful things. Me? Not so much, but I was willing to try to build a home security system with the stuff in my junk box. Here's what happened …

  • A new way of no-solder prototyping

    The Grove system's standardized connector and multitude of devices allow quick and easy project prototyping with your favorite small-board computers.

  • Write your own drivers for Arduino

    So, you have some new kit for your Arduino – maybe some sensors or ICs – but programming them is clumsy and painful. Don't despair: You can make your life easier by writing your own drivers!

  • Use an analog sensor as a video game controller

    We put our Analog-to-Digital converter to work reading positions from an analog sensor (a potentiometer) and control a bat in a simple implementation of the classic Breakout game.