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.
- 1 Presentation of the CJMCU card (LilyTiny)
- 2 Specifications of the CJMCU card
- 3 LilyTiny vs LilyPad
- 4 Comparison between the ATTiny85 and the ATmega328 of an Arduino
- 5 Programming the CJMCU with the Arduino IDE
- 6 Upload the Blink program to the CJMCU card
- 7 Equivalent board
- 8 Problem with macOS X
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.
Specifications of the CJMCU card
- 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 – ATTiny 85
Programming via the USB port
|LilyTiny – ATTiny85
IC Test Clip for SOIC 8-Pin
|LilyPad – ATmega 32u4
Programming via the USB port
|LilyPad – ATmega 328
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.
|Number of pins||8||28|
|Flash size (ko)||8||32|
|SRAM size (bytes)||512||2048|
|GPIO (with ADC and PWM)||6 (5, but one more if you disable activate reset*)||23|
* 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.
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
Then go to the card manager and add the Digistump AVR Boards library.
Now select the Digispark card (Default 16Mhz).
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.
|CMJCU bord ATtiny85|
|Leds (for e-textile application)|
|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.
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.
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:
- Go to the card manager and uninstall the Digistump cards.
- Close Arduino IDE
- Open the Finder and go to the /Users/YOUR_NAME/Library/Arduino15/packages directory
- Delete the digistump directory
- Restart the Arduino IDE
- Reinstall the Digistump cards
And it works on macOS X too!