Overview

GEMMA and Trinket are great when you want a tiny, low cost microcontroller to embed in your projects. One of the tradeoffs, however, is that they can’t send data back to the computer for debugging sensor values.

For instance, you want to make a pair of Firewalker sneakers with Gemma instead of Flora, but there’s no easy way to calibrate your Velostat step sensor since you can’t see the numerical value of the reading. I recommend keeping a FLORA around for this purpose, even if you port to GEMMA later.

But there’s a workaround-- you can use software serial and a modified console cable to debug values on Gemma. Let’s wire it up. You will need:

You can also use a spare Arduino Uno if you can't get your hand on a console cable-- check out the last page of this guide to learn how!

Build cable

Cut off the headers from the end of the console cable and tin the leads with a little solder. A third hand tool can be helpful.

Slide on some heat shrink and prep your alligator clips. I matched the colors of the wires to make it easy on myself.

Connect black to ground, red to three volts, green to pin D0 and white to pin D1. This only leaves room for debugging one sensor on digital pin 2 aka analog pin 1. So if you’ve got NeoPixels connected that react to your sensor, you’ll have to leave them off for now.

If you're only planning to send data from GEMMA to the computer and not vice versa, you can leave the green wire (receive) disconnected, giving you access to one more digital IO pin!

Use it!

Hook your sensor up to pin A1/D2 and ground. In the photo above we're testing an analog velostat step sensor as seen in the Firewalker Sneakers. You can also debug a digital sensor like the on/off antics of the vibration switches or tilt ball

Load this code onto your GEMMA using a regular USB cable:

Download: file
// GEMMA serial debugging

#include <SoftwareSerial.h>

#define SENSOR_PIN       1 // Analog input for sensor

// Establish software serial on digital pins 0 and 1
SoftwareSerial mySerial = SoftwareSerial(0,1); 

int sensorValue;       // Current filtered pressure reading

void setup() {
  mySerial.begin(9600);

  // Set internal pullup resistor for sensor pin (analog 1 is digital 2)
  pinMode(2, INPUT_PULLUP); 

}

void loop() {
  delay(500);
  
  sensorValue = analogRead(SENSOR_PIN);
  mySerial.println(sensorValue);

}

Make sure you have the console cable driver installed, then it should show up like a regular serial port in the Arduino serial monitor.

Once you can see your sensor values, you can adjust your program to trigger events at different thresholds!

Use an Arduino Uno instead

You can also use an Arduino Uno instead of a console cable. We spliced alligator clips with breadboard wires and connected D0 on GEMMA to pin 0 (aka RX) on the Arduino Uno board, D1 on GEMMA to Arduino pin 1 (aka TX), GEMMA GND to Arduino GND, and clip your sensor between GEMMA A1/D2 and GND.

Load a blank sketch onto your Arduino Uno:

Download: file
void setup() {

}

void loop() {
  
}

Load the code from the previous page onto your GEMMA. Power GEMMA over USB or with a battery, open up the serial montitor and watch your sensor values pour in!

This guide was first published on Aug 20, 2014. It was last updated on Aug 20, 2014.