The CJMCU board is a small board 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 board (LilyTiny)
The CJMCU board is a circular miniature board 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 board
- 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 board based on the ATTiny microcontroller and the LilyPad (link to the project) board 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 boards. 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 board 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 boards. 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 board. Go to Device Manager. If your board 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 board manager and add the Digistump AVR Boards library.
Now select the Digispark board (Default 16Mhz).
Upload the Blink program to the CJMCU board
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 board, you will need to unplug it from the computer. Then tap Upload. After compiling the program, a message prompts you to connect your board. You have 60 seconds to plug it in. As soon as the board 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 boards at major manufacturers. At Adafruit, the Gemma board has a USB port for programming and a JST connector for adding a LiPo battery. Sparkfun markets the LilyTiny, a very compact board (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 board library. Here’s how to fix the problem:
- Go to the board manager and uninstall the Digistump boards.
- 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 boards
And it works on macOS X too!