Introduction
We wanted to design a microcontroller board that was small enough to fit into any project, and low cost enough to use without hesitation. Perfect for when you don't want to give up your Flora and you aren't willing to take apart the project you worked so hard to design. It's our lowest-cost sewable controller!
The Attiny85 is a fun processor because despite being so small, it has 8K of flash, and 5 I/O pins, including analog inputs and PWM 'analog' outputs. We designed a USB bootloader so you can plug it into any computer and reprogram it over a USB port just like an Arduino (it uses 2 of the 5 I/O pins, leaving you with 3). In fact we even made some simple modifications to the Arduino IDE so that it works like a mini-Flora. Perfect for small & simple projects the Gemma will be your go-to wearable electronics platform.
Even though you can program Gemma using the Arduino IDE, it's not a fully 100% Arduino-compatible. There are some things you trade off for such a small and low cost microcontroller!
- Gemma does not have a Serial port connection for debugging so the serial port monitor will not be able to send/receive data
- Some computers' USB v3 ports don't recognize the Gemma's bootloader. Simply use a USB v2 port or a USB hub in between
- Gemma is not supported on Linux operating system at this time - try Mac OS or Windows!
- Super small, only 1.1" / 28mm diameter and 0.28" / 7mm thick.
- Easy-to-sew or solder pads for embedding in your wearable project
- Low cost enough, you can use one for every weekend project
- ATtiny85 on-board, 8K of flash, 512 byte of SRAM, 512 bytes of EEPROM
- Internal oscillator runs at 8MHz
- Ultra low power, draws only 9 mA while running
- USB bootloader with a nice LED indicator looks just like a USBtinyISP so you can program it with the Arduino IDE (with a few simple config modifications)
- Mini-USB jack for power and/or USB uploading, you can put it in a
box or tape it up and use any USB cable for when you want to reprogram.
- We really worked hard on the bootloader process to make it rugged
and foolproof
- ~5.25K bytes available for use (2.75K taken for the bootloader)
- On-board 3.3V power regulator with 150mA output capability and ultra-low dropout. Up to 16V input, reverse-polarity protection, thermal and current-limit protection.
- Power with either USB or external output (such as a battery) - it'll automatically switch over
- On-board green power LED and red pin #1 LED
-
Reset button for entering the bootloader or restarting the program.
- 3 GPIO - The 3 independent IO pins
have 1 analog input and 2 PWM output as well.
- Hardware I2C capability for breakout & sensor interfacing.
Page last edited March 08, 2024
Text editor powered by tinymce.
Guided Tour
Let me take you on a tour of your Gemma! Each Gemma is assembled here at Adafruit and comes chock-full of good design to make it a joy to use.
- Mini-B USB connector (on Version 1) - We went with the tried and true mini-B USB connector for power and/or USB bootloading on our first version of the Gemma
- Green Power LED - you'll know that the board is powered up when this bright LED is lit
- Red #1 LED - this LED does double duty. Its connected with a series resistor to the digital #1 GPIO pin. It pulses nicely when the Gemma is in bootloader mode, and its also handy for when you want an indicator LED.
- JST Battery Input - take your Gemma anywhere and power it from an external battery. This pin can take up 16V DC input, and has reverse-polarity, over-curent and thermal protections. The circuitry inside will use either the battery or USB power, safely switching from one to the other. If both are connected, it will use whichever has the higher voltage. Works great with a Lithium Polymer battery or our 3xAAA battery packs with a JST connector on the end
- Voltage Output - This pin will give you either the battery power or USB power, whichever has a higher voltage. Its great when you want to power something like NeoPixels, that might use more than the 150mA available from the onboard regulator
- 3V Regulator Out - The on-board voltage regulator can supply up to 150mA at a steady 3.3V from up to 16VDC
- Sewing friendly pads - You can easily sew to these pads, and they're gold plated so they wont corrode (oxidize). You can also use alligator clips or solder directly to them.
- GPIO! - 3 GPIO pins, at 3V logic, check the next section for a detailed pinout guide
- Reset Button - an onboard reset button will launch the bootloader when pressed and the Gemma is plugged into a computer. If it is not connected to a computer, it's smart enough to go straight to the program.
New in Version 2
- Micro-B USB connector (on Version 2) - In version 2 we upgraded to a micro USB connector, which is now the standard for all cell phones and other devices. It is used for power and/or USB bootloading on our first version of the Gemma
- On/Off switch (in version 2 only) - With the space we saved by moving to a smaller chip and micro USB connector we had enough space to add an on/off slide switch!
Page last edited March 08, 2024
Text editor powered by tinymce.
Pinouts
JST Battery Input
There is no battery INPUT pin on the Gemma. You can connect a battery via the JST jack. We have found that Lipoly batteries, coin-cells, and AAA's work great. You can also make your own battery input pack using a plain JST cable. And use a JST extension cable if necessary.
You can plug anything from around 4VDC up to 16VDC, but we suggest 4-6V since higher voltages just get wasted as heat. This input is polarity protected. If the green PWR LED lights up, you're good to go. There is no off switch on the Gemma, so unplug or switch off the battery pack when done.
Power Pads
Half of the pads on the Gemma are related to power in and out: 3Vo , Vout and GND
- Vout - This is a voltage OUTPUT pin, it will be connected to either the USB power or the battery input, whichever has the higher voltage. This output does not connect to the regulator so you can draw as much current as your USB port / Battery can provide (in general, thats about 500mA)
- 3Vo - This is the 3.3V OUTPUT pad from the voltage regulator. It can provide up to 150mA at a steady 3.3V. Good for sensors or small LEDs or other 3V devices.
- GND is the common ground pin, used for logic and power. It is connected to the USB ground and the power regulator, etc. This is the pin you'll want to use for any and all ground connections
Input/Output Pads
Next we will cover the 3 GPIO (General Purpose Input Ouput) pins! For reference you may want to also check out the datasheet-reference above for the core ATtiny85 pin
All the GPIO pins can be used as digital inputs, digital outputs, for LEDs, buttons and switches etc. They can provide up to 20mA of current. Don't connect a motor or other high-power component directly to the pins! Instead, use a transistor to power the DC motor on/off
On a Gemma, the GPIO are 3.3V output level, and should not be used with 5V inputs. In general, most 5V devices are OK with 3.3V output though.
The 3 GPIO pins are completely 'free' pins, they are not used by the USB connection so you never have to worry about the USB interface interfering with them when programming
- Pad #0 - this is connected to PB0 on the ATtiny85. This pin can be used as a PWM output, and is also used for I2C data, and SPI data input.
- Pad #1 - this is connected to PB1 on the ATtiny85. This pin can be used as a PWM output, and is also used for SPI data output. This pin is also connected to the onboard LED (like pin 13 on a regular Arduino).
- Pad #2 - this is connected to PB2 on the ATtiny85. This pin can be used as an analog input (known as Analog A1), and is also used for I2C clock and SPI clock.
Page last edited March 08, 2024
Text editor powered by tinymce.
Windows Driver Installation (Windows 8.1 and earlier)
Before you plug in your board, you'll need to possibly install a driver!
Click below to download our Driver Installer.
Download and run the installer.
Run the installer! Since we bundle the SiLabs and FTDI drivers as well, you'll need to click through the license
Select which drivers you want to install, we suggest selecting all of them so you don't have to do this again!
As of version 2.5.0.0, the Adafruit drivers package is no longer signed, and some of the drivers it contains are also no longer signed. You'll need to click the second item in this dialog box when it appears:
On Windows 7, by default, we install a single driver for most of Adafruit's boards, including the Feather 32u4, the Feather M0, Feather M0, Express, Circuit Playground, Circuit Playground Express, Gemma M0, Trinket M0, Metro M0 Express. On Windows 10 and 11 that driver is not necessary (it's built in to Windows) and it will not be listed.
The Trinket / Pro Trinket / Gemma / USBtinyISP drivers are also installed by default.
You can also, optionally, install the Arduino Gemma (different than the Adafruit Gemma!), Huzzah and Metro 328 drivers.
Click Install to do the installin'.
Manual Driver Installation
If windows needs the driver files (inf/cat) for some reason you can get all the drivers by downloading the source code zip file from this link:
And point windows to the Drivers folder when it asks for the driver location
Page last edited March 08, 2024
Text editor powered by tinymce.
About the Bootloader
One of the challenges with the Gemma is that we wanted to have a built-in USB bootloader, but the ATtiny85 doesn't have built-in USB hardware! There are existing USB bootloaders that can work on the 't85 but they use other companies' USB VID/PIDs. Since it not permitted by the USB developer's group to use others' VID/PIDs we had to adapt one of these existing bootloaders to use our USB ID, but we also wanted to not have to re-compile avrdude or the Arduino IDE since that's such a pain.
So instead, Frank (our awesome engineer with mad USB chops) created a USB bootloader that combines the elegance of V-USB with the well-supported and tested nature of the USBtinyISP. This bootloader looks just like a USBtinyISP - and since it uses the unique Adafruit VID/PID we own and that we added to avrdude so long ago, it works with only very minimal configuraton tweaks. No need to recompile anything, whew!
Don't forget to plug in the Gemma via a known-good USB cable to start the process. You should see the green power LED lit and the red bootloading LED pulse indicating that the Gemma is ready to start programming. If you've programmed the Gemma since getting it, you can always get it back to the bootloader state by pressing the small onboard reset button.
Check http://learn.adafruit.com/usbtinyisp/avrdude#for-linux for what to add to your udev file.
How to start the bootloader
Before you try to upload code to the Gemma it must be in the Bootloader Mode. That means its listening for a sketch or program to be sent to it
Don't press-and-hold the reset button, be sure to press-and-release!
See the video below for what it looks like to plug it in, have the LED pulse in bootloader mode, time out and then press reset to restart the bootloader. The board shown is a Trinket, which uses the same upload system as Gemma.
Page last edited March 08, 2024
Text editor powered by tinymce.
Setting up with Arduino IDE
Arduino IDE Setup
Just follow the steps in the steps in the Adafruit Arduino IDE setup guide to easily install a pre-configured Arduino IDE to program Gemma!
When you're finished installing the IDE come back to this page to continue the Gemma guide.
Blink!
After installing the Arduino IDE with support for Adafruit's boards you can load a simple blinking LED example to test uploading to Gemma works as expected. Open the Arduino IDE and replace the sketch code with the following blink code:
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
To upload to your or Trinket:
1) Select the proper board from the Tools->Board Menu (Arduino Gemma if
teal, Adafruit Gemma if black)
2) Select the uploader from the Tools->Programmer ("Arduino Gemma" if teal,
"USBtinyISP" if black Gemma)
3) Plug in the Gemma into USB, make sure you see the green LED lit
4) For windows, make sure you install the right Gemma drivers
5) Press the button on the Gemma/Trinket - verify you see
the red LED pulse. This means it is ready to receive data
6) Click the upload button above within 10 seconds
*/
int led = 1; // blink 'digital' pin 1 - AKA the built in red LED
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
}
If you're using the Adafruit Gemma (with a black PCB board) select the Adafruit Gemma 8MHz board from the Tools->Board menu.
However if you're using the newer Arduino Gemma (with a teal PCB board) select the Arduino Gemma board from the Tools->Boards menu.
Then select Arduino Gemma as the Programmer type
Get Into Bootloader Mode
Plug in the Gemma, make sure you see the green LED lit (power good) and the red LED pulsing. Press the button if the red LED is not pulsing, to get into bootloader mode.
Click the Upload button (or select File->Upload)
Something Went Wrong!
If you get the error message avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)
That means the bootloader wasn't active. Make sure to press the button on the Gemma to activate the bootloader before clicking the Upload button.
If you get a lot of red text, errors and also a warning about Verification Failed
Check that you updated the avrdude.conf file above - if you don't update the description of the Attiny85 in the configure file by replacing it, the IDE wont know to be patient with the Gemma bootloader and will have many upload errors
On Linux if you get the error message "usbtiny_receive: error sending control message: Protocol error (expected 4, got -71)"
These can generally be ignored and should not interfere with the program upload. Unfortunately Linux's USB core is a little flakey communicating with the ATtiny85 processor on the Trinket/Gemma and can cause these errors. If an upload does fail, try it again as it is likely an intermittent issue.
Page last edited March 08, 2024
Text editor powered by tinymce.
Programming with Arduino IDE
pinMode() & digitalWrite() & digitalRead()
You can use pinMode() to make inputs and outputs on any of digital pins #0 thru #2
digitalWrite also works well, and you can also use it with pinMode(INPUT) to activate the internal pull-up resistor on a pin
For example, to set up digital #0 as an input, with an internal pullup, and then check if it is being pulled to ground via a button or switch and turn on the red LED when it is pressed:
/*
Button
Turns on an LED when a switch connected from #0 to ground is pressed
This example code is in the public domain.
To upload to your Gemma or Trinket:
1) Select the proper board from the Tools->Board Menu
2) Select USBtinyISP from the Tools->Programmer
3) Plug in the Gemma/Trinket, make sure you see the green LED lit
4) For windows, install the USBtiny drivers
5) Press the button on the Gemma/Trinket - verify you see
the red LED pulse. This means it is ready to receive data
6) Click the upload button above within 10 seconds
*/
#define SWITCH 0
#define LED 1
// the setup routine runs once when you press reset:
void setup() {
// initialize the LED pin as an output.
pinMode(LED, OUTPUT);
// initialize the SWITCH pin as an input.
pinMode(SWITCH, INPUT);
// ...with a pullup
digitalWrite(SWITCH, HIGH);
}
// the loop routine runs over and over again forever:
void loop() {
if (! digitalRead(SWITCH)) { // if the button is pressed
digitalWrite(LED, HIGH); // light up the LED
} else {
digitalWrite(LED, LOW); // otherwise, turn it off
}
}
analogRead()
You can read an analog voltage from digital #2 (called A1)
For example, to read an analog voltage on pin #2, you would call analogRead(A1)
analogWrite()
There are a few PWM outputs on the Trinket, you can call analogWrite() on digital #0 and #1
For example, to pulse the built-in LED slowly, upload this code:
/*
Pulse
Pulses the internal LED to demonstrate the analogWrite function
This example code is in the public domain.
To upload to your Gemma or Trinket:
1) Select the proper board from the Tools->Board Menu
2) Select USBtinyISP from the Tools->Programmer
3) Plug in the Gemma/Trinket, make sure you see the green LED lit
4) For windows, install the USBtiny drivers
5) Press the button on the Gemma/Trinket - verify you see
the red LED pulse. This means it is ready to receive data
6) Click the upload button above within 10 seconds
*/
int led = 1; // pulse 'digital' pin 1 - AKA the built in red LED
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
for (int i=0; i<256; i++) {
analogWrite(led, i); // PWM the LED from 0 to 255 (max)
delay(5);
}
for (int i=255; i>=0; i--) {
analogWrite(led, i); // PWM the LED from 255 (max) to 0
delay(5);
}
}
More...
We also know the following libraries work:
- Adafruit NeoPixel - control up to ~150 Neopixels via a Trinket!
- SoftwareSerial - the built in SoftSerial library can (at least) transmit data on any digital pin.
- More as we do more testing and verification!
Page last edited March 08, 2024
Text editor powered by tinymce.
Downloads
Datasheets
Source code
Original code for the Trinket/Gemma bootloader on github
We do not offer any support for this code, it is released as-is!
Page last edited March 08, 2024
Text editor powered by tinymce.
FAQ
chip_erase_delay = 900000;under the ATtiny85 heading to
chip_erase_delay = 400000;That is, a shorter delay.
To use with neopixels:
- Connect the + power line of the strip to Vout on the Gemma, or to a separate 4-7VDC power source such as a 3 or 4 pack of AA batteries.
- Connect the - common ground to the battery pack (if being used) and also to the Gemma GND pin
- Connect the data in line to Gemma #1 - this will let you also see when data is being sent because the #1 red LED will flicker. You can use other pins but start with #1 since its easiest to debug and use
- Install the NeoPixel library as detailed in our Uber Guide, and change the PIN to 1 (its 6 by default)
- Upload and enjoy!
That tutorial also shows how to use the TinyM I2C driver, which works great on the ATtiny85, and adapt other existing libraries for the Gemma/Trinket
However, the AVR series is pretty forgiving for overclocking, so you may be able to run the 3V Gemma at 16 MHz. Note that this is still overclocking, your code may run flakey or not at all! Overclocking should not damage the AVR, but we still recommend sticking with 8 MHz only if you can get away with it!
To run at 16Mhz, use the Trinket 16Mhz board definition and modify your sketch as described here.
Page last edited March 08, 2024
Text editor powered by tinymce.