Tutorial : How to program the CJMCU ATTiny85 (LilyTiny / LilyPad)

The CJMCU card is a small card intended for Wearable projects based on the ATTiny85 chipset (technical documentation from ATMEL). In this article, we will simply overfly the ATTiny85 which will be the subject of a next article. This article concerns the installation of the Digistump drivers, the preparation of the Arduino IDE and the programming of the CJMCU using the Arduino IDE, which is very poorly documented.

Presentation of the CJMCU card (LilyTiny)

The CJMCU card is a circular miniature card of about 25mm in diameter. It does not have any connection pin, intended for the applications of electronic clothing, we will simply connect the different components of the project (switch, button cell battery, Led, accelerometer, GPS …) using a wire Stitched.

Compared to the LilyTiny card from Sparkfun (product page), programming is simpler because a USB cable (link to the Sparkfun tutorial) is used instead of an AVR programmer.

Specifications of the CJMCU card

  • Processor: ATTiny85

  • 2 kB of available memory for the Arduino program
  • Dimensions: diameter 25mm, thickness 4mm
  • GPIO: 5 (1 reserved for Reset required for programming)
  • Connector: micro USB
  • 1 red power-on LED
  • 1 red LED connected to GPIO1
  • Bootloader: micronucleus (Github page of the project)

LilyTiny vs LilyPad

There may be confusion (maintained by the websites) between the LilyTiny, the commercial name of the Sparkfun card based on the ATTiny microcontroller and the LilyPad (link to the project) card which is based on an ATmega328 or the Atmega32u4 . The LilyPad was originally developed by Leah Buechley to facilitate the learning of e-textile. The commercial version was launched in collaboration with SparkFun Electronics. Here is a small overview of the 3 boards

cjmcu board wearable attiny85 arduino lilytiny lilypad_atmega32u4 lilypad_atmega328
CJMCU – ATTiny 85

Programming via the USB port

LilyTiny – ATTiny85

AVR programmer and IC Test Clip for SOIC8 Pins

IC Test Clip for SOIC 8-Pin

LilyPad – ATmega 32u4

Programming via the USB port

Technical documentation

LilyPad – ATmega 328

FTDI programming

Technical documentation

Comparison between the ATTiny85 and the ATmega328 of an Arduino

The ATTiny85 (and other members of the family) is an AVR microcontroller just like the ATmega328 that equips Arduino cards. It is therefore able to execute the programs created with the Arduino IDE with some restrictions. Here is a table comparing the main technical characteristics of the two microcontrollers.

ATiny85 ATmega328
Number of pins 8 28
Flash size (ko) 8 32
SRAM size (bytes) 512 2048
EEPROM size(bytes) 512 1024
PWM 2 6
GPIO (with ADC and PWM) 6 (5, but one more if you disable activate reset*) 23
I2C yes yes
SPI yes yes
UART no yes

* Deactivating the reset fuse allows the use of pin 1 as an analog or digital channel, but also deactivates the possibility of programming the microcontroller. Here is a guide to reactivate the fuse.

Programming the CJMCU with the Arduino IDE

It is quite possible to program the CJMCU card using the Arduino IDE (link to the download page) just like any Arduino.

Install the Digistump on Windows

The first step is to retrieve and install the driver for Digistump cards. You can download it on github (direct link to DigistumpDrivers.zip). After unpacking the Zip, go to the directory and run the DPinst.exe program (or DPinst64.exe if you have 64-bit Windows).

Now plug in your card. Go to Device Manager. If your card has been successfully installed, you must have a new device called libusb-win32 devices in which the Digispark Bootloader is located.

CJMCU ATTiny85 divers digistump digispark bootloader windows libusb-win32 devices

Under MacOS X

On MacOS X (I have not tested on Linux), you do not need to install drivers.

Add Digistump Card Library

Then open your Arduino IDE. The procedure works as of version 1.6.4 and beyond. For this article, I used version 1.6.8

Open preferences and add the path to the Digistump library

http://digistump.com/package_digistump_index.json

CJMCU arduino board digistump digispark

Then go to the card manager and add the Digistump AVR Boards library.
Now select the Digispark card (Default 16Mhz).

CJMCU arduino link lien package digistump digispark

Upload the Blink program to the CJMCU card

Everything is ready, we only have to upload our first program. We will simply try the Blink Arduino program by flashing a Led for e-textile application on the P3 pin.

CJMCU Attiny85 led module cable pince alligator arduino

cjmcu board wearable attiny85 arduino e-textile CMJCU bord ATtiny85
cable alligator Alligator cables
led module e-textile wearable lilypad Leds (for e-textile application)
e-textile fil conducteur cjmcu attiny85 project diy Conductive sewing thread

Whenever you want to upload a program to a Digispark card, you will need to unplug it from the computer. Then tap Upload. After compiling the program, a message prompts you to connect your card. You have 60 seconds to plug it in. As soon as the card is detected, the program flashes. The program starts at the end of the operation.

CJMCU ide arduino televerser programme digistump digispark

Equivalent board

If the ATTiny microcontroller is tempting you now and you have nice electronics clothing projects, know that you can find similar cards at major manufacturers. At Adafruit, the Gemma card has a USB port for programming and a JST connector for adding a LiPo battery. Sparkfun markets the LilyTiny, a very compact card (diameter 20mm) but more complicated and more expensive to program. An AVR programmer, IC Test Clip for SOIC8 Pins and Dupont cables must be purchased.

Programmation de l'ATtiny85 d'un carte LilyTiny de Sparkfun (source : Sparkfun)

Sparkfun LilyTiny (source : Sparkfun).

adafruit gemma attiny wearable e-textile Adafruit Gemma
lilytiny Sparkfun LilyTiny

Problem with macOS X

During my tests on macOS X, I encountered the following error message:

Board digispark-tiny (platform avr, package digistump) is unknown

I made the mistake of thinking that it was missing a drivers, but thanks to the comment of Julien (which I thank at the same time), I found the solution on this forum. In fact, it’s just a problem installing the Digistump card library. Here’s how to fix the problem:

  1. Go to the card manager and uninstall the Digistump cards.
  2. Close Arduino IDE
  3. Open the Finder and go to the /Users/YOUR_NAME/Library/Arduino15/packages  directory
  4. Delete the digistump directory
  5. Restart the Arduino IDE
  6. Reinstall the Digistump cards

And it works on macOS X too!

Subscribe to the weekly newsletter

No spam and no other use will be made of your email. You can unsubscribe anytime.

1 Comment
  1. Reply
    Mike The-Synchronistic Savage 30 December 2017 at 5 h 42 min

    Seemed to have bricked two little CJMCU – ATTiny 85 (circle boards with USB)…took a bit to get them to program…but when i did i verified that it was working with a blink sketch that seemed to indicate that this was a model A (Pin 1 = Onboard LED), after this i tried to upload a Neopixel strandtest Sketch…and budunk…the thing no longer programs, is not detected by lsusb and does not light up the WS2812 Ring…WTFluff? the only thing i can think of is after reading this i see it says something about a pin being used as a reset pin…in the example i set it to output using pin 5…could this be the issue? if i order a new one and set it to output a different pin will it work? and/or is there anything i can do to reprogram these (seemingly) bricked TinyLilyPads?? (perhaps using another arduino?) i am guessing i am not the only one who has had this issue, and look forward to any insight that may arise

Leave a Reply

DIY Projects
%d bloggers like this: