Calliope mini

The Calliope mini [1] is a single-board computer developed for use in German primary schools. It is inspired by the BBC Micro:bit, and shares some of its features.

Like the BBC Micro:bit it is based on the Nordic Semiconductor nRF51822 ARM Cortex-M0 microcontroller running at 16 MHz and with 256 Kbytes of flash program memory. The boards produced from 2019 onwards use the nRF51822-QFAC version with 32 Kbytes of RAM, twice as much as the BBC Micro:bit:

CalliopeMini.jpg 

It's available from Adafruit [2], or from Amazon in the UK [3].

Like the BBC Micro:bit it includes a 5x5 LED matrix display, two push buttons, banana plug/crocodile clip connections, and a JST battery connector. It also features a MEMS microphone, piezo speaker, DC Motor Driver (TI DRV8837), two Grove connectors (I2C + serial/analog), and a space for an optional DataFlash chip.

It is named after Kalliope, a daughter of Zeus and the muse who presides over eloquence, science, and epic poetry.

Installing uLisp on the Calliope mini

You can install the ARM Version 3.3 or later of uLisp on a Calliope mini using the Arduino IDE as follows:

  • Download the ARM version of uLisp from the downloads page: Download uLisp.
  • In the Arduino IDE open the Preferences dialog box, and add the following URL to Additional Board Manager URLs:
https://sandeepmistry.github.io/arduino-nRF5/package_nRF5_boards_index.json
  • Open the Boards Manager… from the Board item on the Tools menu, search for nRF5, and install Nordic Semiconductor nRF5 Boards by Sandeep Mistry.
  • Connect the Calliope mini to your computer using a USB cable.
  • Select Calliope mini from the Board menu, set Softdevice to None, and set Port to the USB port.

You should now be able to upload uLisp to the Calliope mini.

Follow the instructions in Using uLisp to interact with uLisp on the Calliope mini.

Updating the serial buffer

As of uLisp Version 3.6 there is no longer a problem pasting large Lisp programs in via the Serial Monitor, so there is no need to change the serial buffer size from the default.

Using the full 32 Kbytes of RAM

The Arduino core assumes that the Calliope mini has 16 Kbytes of RAM. To take advantage of the full 32 Kbytes you need to make the following changes:

  • Locate the boards.txt file at:
/Users/david/Library/Arduino15/packages/sandeepmistry/hardware/nRF5/0.6.0/boards.txt

replacing David by the name of your user folder, and 0.6.0 by the version of Sandeepmistry you have installed.

  • Edit the following three entries as shown, changing "xxaa" to "xxac" in each case:
CalliopeMini.build.ldscript=nrf51_xxac.ld
CalliopeMini.menu.softdevice.s110.build.ldscript=armgcc_s110_nrf51822_xxac.ld
CalliopeMini.menu.softdevice.s130.build.ldscript=armgcc_s130_nrf51822_xxac.ld
  • Change the #define in the ARDUINO_CALLIOPE_MINI section in the ulisp-arm.ino file as follows, to increase the workspace to use this extra space:
#define WORKSPACESIZE 3328              /* Objects (8*bytes) */

Peripherals

Pin connections

The Calliope mini has 6 pads which can take crocodile clips or banana plugs.

Calliope_mini_1.gif

The board also includes two pushbuttons and a matrix of 5 x 5 multiplexed LEDs. See Example programs below for examples of using these from uLisp.

Buttons

The Calliope mini provides two pushbuttons on pins 20 (A) and 22 (B). You can read these with the following program:

(defun buttons ()
  (pinmode 20 nil)
  (pinmode 22 nil)
  (loop
   (print
    (list (digitalread 20) (digitalread 22)))
   (delay 1000)))

Run it by typing:

(buttons)

LEDs

The Calliope mini provides a matrix of 5 x 5 LEDs. They are connected in an illogical arrangement of nine rows and three columns, and to light any individual LED you need to take the row low and the column high corresponding to that LED.

The following table shows the (row, column) for each LED:

(4, 13) (7, 14) (5, 13) (8, 14) (6, 13)
(7, 15) (8, 15) (9, 15) (10, 15) (11, 15)
(5, 14) (12, 13) (6, 14) (12, 15) (4, 14)
(11, 13) (10, 13) (9, 13) (8, 13) (7, 13)
(6, 15) (10, 14) (4, 15) (9, 14) (5, 15)

This program flashes the LED at (row, column):

(defun b (row col)
  (let ((x t))
    (pinmode row t)
    (pinmode col t)
    (digitalwrite row nil)
    (loop
     (digitalwrite col x)
     (delay 1000)
     (setq x (not x)))))

For example, to flash the centre LED run:

(b 6 14)

Analogue inputs

The Calliope Mini provides eight 10-bit analogue inputs, on pins 1 (A1), 2 (A2), 4 (A3) to 6 (A5), 16 (A6), and 17 (A7). Two of them are available on the edge connector pads labelled 1 and 2. Pin 28 (A0) is connected to the microphone.

The following example program reads the analogue input on pin 1 and displays the value as a bar of LEDs, using the fourth row of LEDs on the matrix. The program takes advantage of the fact that this row of LEDs share the same column number and have consecutive row numbers. Here's the program:

(defun meter ()
  (let ((row 7) (col 15))
    (pinmode col t)
    (digitalwrite col t)
    (dotimes (i 5) (pinmode (+ row i) t))
    (loop
     (dotimes (i 5)
       (digitalwrite 
        (+ row i)
        (< 
         (analogread 1)
         (* (1+ i) 170)))))))

To run it evaluate:

(meter)

If you touch pad 1 on the edge connector you'll see the bar flash from the voltage on your finger. Connect a voltage of up to 3.3V to pad 1 to display a bar of LEDs in proportion to the voltage.

Analogue outputs

Any pin can also be used as an 8-bit analogue output, so you can pulsate the centre LED slowly on and off with the program:

(defun pulse ()
  (let (down)
    (pinmode 6 t)
    (digitalwrite 6 nil)
    (loop
     (dotimes (x 256) 
       (delay 5) 
       (analogwrite 14 (if down (- 255 x) x)))
     (setq down (not down)))))

Run it by typing:

(pulse)

Exit from any program by entering ~.

Serial

The Calliope Mini has one serial port on pin numbers 30 (RX) and 29 (TX).

SPI

The Calliope Mini has one SPI port on pin numbers 16 (MISO), 17 (MOSI), and 22 (SCK).

I2C

The Calliope Mini has one I2C port on pin numbers 18 (SDA) and 19 (SCL).

DataFlash capability

Interestingly the Calliope mini circuit board has a space for a 8-pin surface-mount DataFlash chip, type M45PE80 (8 Mbyte) or M45PE16 (16 Mbyte). It's possible this could be used to add the ability to save and load uLisp images to the board.


  1. ^ Calliope mini website.
  2. ^ Calliope mini on Adafruit.
  3. ^ Calliope mini on Amazon.