Expander for the Calliope mini

FunduinoPublished on

Module, MakeCode und elf Praxisaufgaben für den MINT-Unterricht

Der Expander für den Calliope mini V3 ist ein vielseitiges Zubehör, das speziell für den Einsatz im MINT-Unterricht entwickelt wurde. Besonders im Informatik- und Technikunterricht eröffnet er zahlreiche neue Möglichkeiten, um den Calliope mini V3 sinnvoll und kreativ einzusetzen.

Die vorkonfektionierten Stecker und die beschrifteten Kontakte machen es einfach, Module sicher und schnell zu verbinden – ohne komplizierte Vorbereitung. Gleichzeitig ist das System offen: Über die universellen Anschlussmöglichkeiten lässt sich der Expander mit einer Vielzahl von Mikroelektronikkomponenten kombinieren.

Diese Anleitung erklärt zuerst die Module, dann die Programmieroberfläche MakeCode und die serielle Kommunikation. Danach folgen elf Praxisaufgaben, die aufeinander aufbauen – von der blinkenden Leuchtdiode bis zur selbst gebauten Toniebox.

Expansion board for the Calliope mini V3 with an overview of all modules

The Calliope mini V3 and the expander

The Calliope mini V3 is a small computer you can program. It has colorful lights, buttons, and even sensors that can measure things like movement or temperature. You can program it to play music, light up, or react to movement.

The Calliope does have an interface that exposes all the microcontroller’s pins, but wiring it up using only breadboard wires is often a challenge. That’s where the expander comes in: it bridges the gap between the Calliope “all-in-one” board and the further use of external modules.

There are also some interesting accessories, such as the “Calle” - a robot chassis that you can attach the Calliope mini V3 to. You can program Calle to follow a line or avoid objects.

Expansion board for the Calliope mini V3 with an overview of all modules
Calliope mini V3 with the Calle robot chassis
1 / 2

What the expander makes accessible

The expander base board is divided into colored sections. The Calliope mini V3 plugs into the black section on the left, while the colored areas on the right bring out the contacts.

The expander makes many hard-to-access Calliope contacts usable: P0, P1, P2, P3, C8, C9, C12, C13, C14, C15, C19, C20, and the motor outputs. C12 and C13 are used by the removable MP3 module, while C19 and C20 provide access to all I2C connectivity options.

All contacts are labeled on the expander. You can connect to them using JST connectors, Grove connectors, or standard breadboard jumper wires. You don't need an additional power source—the Calliope's battery compartment is sufficient for most applications.

Colored sections of the expander baseboard
Drawing of the expander with all connection areas
1 / 2

The modules at a glance

The Calliope mini V3 expander is supplied as a set with the following components, which are programmed step by step in the practical exercises.

  • LED module – an LED on a small board with a JST socket
  • Push button – a push button on a board with a JST socket
  • Rotary control – a potentiometer with a rotary knob
  • Moisture sensor – measures moisture directly at the sensor, not air humidity
  • Motor – a fan with an integrated electric motor and JST-XH connector
  • SG90 servo motor – a typical model-making component with a JR connector
  • MP3 module and speaker – with a slot for a microSD card
  • RFID receiver with chip card and key fob
  • Display – an OLED display or an LCD 1602, depending on availability

It is important to set the RFID module to I2C mode using the slide switches. To do this, remove the protective film over the switches and set the switch to “ON”.

LED module with JST socket
LED module
Pushbutton module with JST socket
Button
Rotary potentiometer module with rotary knob cap
Rotary knob
Moisture sensor with two contact pins
Humidity sensor
Fan with integrated electric motor and JST-XH connector
Motor
SG90 servo motor with JR connector
Servo motor
MP3 module with slot for the microSD card
MP3 module
RFID receiver with chip card and key fob
RFID receiver and the two tags
Set the RFID module’s slide switch to ON for I2C mode.
Switch to ON: I2C mode
OLED display SSD1306 with the GND, VCC, SCL, and SDA pins
OLED display
1602 LCD Display with I2C Backpack
LCD display
1 / 11

The MakeCode programming interface

To program the Calliope, you need a computer and software. This software is called MakeCode and doesn’t need to be installed - you simply open it like a website: makecode.calliope.cc

On the start page, click “New Project,” give your project a name, and click “Create.” That’s it - you have an empty project.

In the middle is the programming area, where you drag the programming blocks. We’ll start with the “on start” and “forever” blocks. If you’ve worked with the Arduino IDE, these correspond to “setup” and “loop.”

On the left you’ll see a small Calliope - the simulator, where you can see what your program does right away.

Next to it are the programming blocks, with the “Basic” and “Advanced” categories. To access the “Pins” category, expand “Advanced.” The important categories there are “Pins” (with blocks such as “Digital Read” and “Analog Read”) and “Serial,” which lets you send data to the computer.

At the top you can switch between “Blocks,” “JavaScript,” and - using the small arrow - “Python.” There you can see what your block program looks like as code.

At the top right the Settings menu with the project settings is behind the gear icon.

Areas of the MakeCode programming interface highlighted in color
The MakeCode programming interface

Understanding Serial Communication

Sensors allow you to digitally measure the properties of your surroundings. A simple example is a temperature sensor.

Just like your skin, a temperature sensor can detect differences in temperature. But your skin doesn’t decide whether something is too hot - your brain does. It processes the data from your skin and tells your muscles: “Quickly take your fingers off the hot stove.”

The Calliope and a connected sensor work in a similar way. The sensor sends the measured values to the Calliope in electrical form, and the Calliope decides what should happen. If you want to build a temperature alarm that makes noise at 30 °C, you have to specify exactly that in the program.

But what values reach the Calliope, and how can you see them? For that, you need serial communication.

If you’ve never worked with a Calliope before, this section may be difficult to understand. You can skip it for now. However, if you want to use sensor readings, you’ll need to read and understand it.

Your first program

Task: The program should display a line pattern on the Calliope’s LED matrix when button A is pressed.

Drag the “if true then” block from the left-hand menu into the programming area and attach it to the “forever” block. Then drag the “button A is clicked” block from the “Input” section into the dark green “if true then” block. This is now your condition.

From the “Basics” section, get the “show LEDs” block and place it in the dark green block. Use the mouse pointer to select a pattern inside it. Then click “Download” to save the program to the Calliope.

Oh, but what’s this? Once you’ve pressed the button, the pattern doesn’t go away again. So you need to expand the program. To do this, click the small plus sign at the bottom left of the dark green block. The block will expand to include a section that runs when button A is not pressed. Add another “show LEDs” block there - this time, leave the matrix blank.

Does your program work the way it should now? And can you change it so that different patterns are displayed?

Ready-made program: Pattern on the LED matrix when button A is pressed
The finished first program

Try out serial communication

To use serial communication, first click “Advanced” in the program blocks, then select the “Serial” category. There you'll find the “redirect serial to USB” and “print serial line” blocks.

Attach the “redirect serial to USB” block to “on start” and the “print serial line” block to “forever”. In the second block, type the word “Hello” between the quotation marks.

After clicking “Download”, the PC may not automatically recognize the Calliope. The computer will then ask whether you want to connect the Calliope: click “Continue”, then “Pair”, select the Calliope in the browser pop-up, and click “Connect”.

The program now sends the word “Hello” continuously. You can view the data using the “Show Calliope mini data” button below the illustrated Calliope.

However, the Calliope is fast and would send a huge amount of data per second. So we'll slow it down: from the “Basics” category, add the “pause (ms) 100” block after “print serial line” and enter 2000 - that's two seconds. After downloading again, “Hello” will appear at much longer intervals.

Block “pause (ms)” with the value 2000
Pause of 2000 milliseconds
“Display Data” window with the received values
Display data Calliope mini
1 / 2

Practical Exercise 1: Make an LED blink

Task: An LED should blink every two seconds, turning on and off.

Wiring: The LED is soldered to a small board together with a JST socket. Plug an expander cable into the socket and connect the other end to the light blue port 3 on the expander board.

Program: In MakeCode, under Advanced → Pins, find the “write digital value of pin to 1” block and attach it to “forever.” Select P2 as the pin, since P2 is the Calliope contact connected to port 3. Look closely at the connector: “P2” is printed there.

This would make the LED stay on. But it should blink. So also use the “pause” block from the “Basic” section and program the sequence: LED on – wait 2000 milliseconds – LED off – wait 2000 milliseconds.

LED module connected to the expander board via an expansion cable
Wiring of the LED module
Finished blink program with two 2000-millisecond pauses
The finished blink program
1 / 2

Practical Exercise 2: Using a Push Button

Task: When a button is pressed, an X should appear on the Calliope matrix.

Wiring: Use an expansion cable to connect the button board to the green port 2 on the expander board. Take a close look at port 2 - can you tell which Calliope contact is available there? That's right, it's P1.

The button on the board continuously supplies a voltage to the Calliope. When it is pressed, this current is interrupted.

Program: Attach the "if true then" block to "forever". The button on the Calliope is built into the program as a fixed block, but the external button is unknown to the Calliope. So take a comparison block from the "Logic" section and put it inside "if true then".

A voltage - yes or no? In programming, this is a Boolean value, also called true or false. The Calliope represents these values as 1 and 0. So you check whether the digital value at pin P1 is equal to 0.

If that's the case, an X should appear: Select "show LEDs" from "Basics" and mark an X. And because the matrix would otherwise never turn off, expand the block again using the plus sign and fill the second area with a blank matrix.

Finished button program with if-then-else and empty matrix
The completed button program

Practical Exercise 3: Rotary Control and Serial Communication

The correct term for an electric rotary control is a potentiometer. It changes the resistance in the circuit depending on how far you turn it. A potentiometer works like a water tap: if it is only slightly open, little water flows; if it is wide open, a lot of water flows.

The Calliope measures the position using an analog-to-digital converter (ADC). It reads the voltage and converts it into a number: 0 for 0 volts up to 1023 for the full voltage.

Task: When the rotary control is turned, the readings should appear in the serial monitor.

Wiring: Use an expander cable to connect the rotary control board to the green port 2 on the expander board.

Program: Connect “redirect serial to USB” to “on start” and “serial write line” to “forever.” Add the “analog value from pin P1” block to the second block. That’s it.

After downloading, click “Show data Calliope mini.” There you’ll see the current reading in orange, a chart above it, the highest and lowest values for the measurement period on the right, and a table at the bottom with all the values, which you can save as a CSV file.

Turn the control back and forth: the lowest reading is about 50, and the highest is about 990. A quarter turn to the right gives a reading of around 260.

Rotary encoder module on green port 2 of the expander board
Wiring the rotary knob
Program: output analog values from pin P1 to serial communication
Send measured values to the computer
“Display Data” window with measurement value, chart, and data table
Measured values, chart, and table in the data window
1 / 3

Practical Exercise 4: Using a Rotary Knob

Task: When the rotary knob is turned to the left, an arrow pointing left should appear on the LED matrix. When it’s turned to the right, an arrow pointing right should appear.

Wiring: As in the previous task – rotary knob board connected to green port 2.

Program: Start with the completed program from the previous task and add the dark green “if true then” block. From “Basics,” select “show icon” and choose the left arrow; use the plus sign to add an “else” section with the right arrow.

And the condition? The readings are between about 50 and 990. Rounded, that’s approximately a range from 0 to 1000 – so the midpoint is 500. From the “Logic” category, drag the “0 < 0” comparison into the dark green block, enter 500 on the right, and insert the “analog values from pin P1” block on the left.

Download it – and it works. Can you make lots of different symbols appear as you turn the knob? The “and” block from the “Logic” category may come in handy.

Finished program: left arrow below 500, otherwise right arrow
The finished rotary knob program
The “AND” block from the Logic section
Tip for multiple symbols: the “and” block
1 / 2

Practical Exercise 5: Moisture Sensor

Like the rotary dial, the moisture sensor is an analog sensor. It doesn’t measure the humidity in the air, but the moisture directly at the sensor – for example, in the soil in a flowerpot.

The sensor has two small metal pins that measure how easily electricity can flow through the soil. Water conducts electricity: the more water there is in the soil, the more easily electricity flows. The sensor sends this value to the Calliope as a number – just like the rotary dial.

Task, Part 1: Look at the readings when the soil is dry and when it’s damp. To simulate damp soil, press the sensor’s contact pins against a damp tissue.

Task, Part 2: Alarm! If the moisture level is too low, an alarm should sound and an X should appear on the LED matrix.

Wiring: Use an expansion cable to connect the sensor board to the light-green Port 1. Note: This is a different port from the one used for the rotary dial. The corresponding Calliope contact is called P0.

Result, Part 1: In our tests, the readings range from 0 to 374. When the sensor is in the air, no moisture is detected and the reading is 0. On a damp tissue, the reading is about 120.

Program, Part 2: Extend the code with “if true then otherwise” and use the comparison “0 < 0”: reading less than 50. If this is the case, select the “show icon” block with the X from “Basics.” Then click the “Music” category, select “more,” choose “play … until done,” and set a sad melody.

Everything works – but wait, the X doesn’t go away. Do you know what’s still missing? Hint: The solution is in the task about the button.

Humidity sensor on the light green Port 1 of the expansion board
Wiring the humidity sensor
Finished program: X and alarm sound when the measured value is below 50
The finished alarm program
1 / 2

Practical Exercise 6: Controlling an Electric Motor

A motor makes things move by using the force of magnets. Inside the motor is an electromagnet that becomes magnetic only when electric current flows through it, and can switch its north and south poles when the current changes direction. This makes it alternately attracted to and repelled by fixed magnets at the right intervals - and it rotates.

Task, Part 1: A small fan is supposed to generate wind.

Task, Part 2: The fan should generate wind only when the temperature sensor on the Calliope is warmed with a thumb.

Wiring: The fan already has a JST-XH connector. On the expander board, you'll find a red-marked motor section with two sockets. Connect the motor to socket M0.

Program, Part 1: From the "Motors" category, get the "Motor M0 on at 100%" block. You can also select -100% using the slider in the block. Some motors - like our fan - rotate in only one direction. Find out whether yours runs at +100% or -100%.

Program, Part 2: Start again by outputting the sensor values in serial communication, but add the Calliope temperature value from the "Input" section. The temperature sensor is in the black square component next to button A.

In our example, the Calliope shows a device temperature of 27 °C at a room temperature of 22 °C. With a thumb on the sensor, it rises to 31 °C. So the condition is: If the temperature is greater than or equal to 28 °C, the fan should run. Pay attention to the comparison symbol - an arrow with a line underneath means "greater than or equal to." In the "otherwise" section, set the power to 0%.

Place the fan next to the Calliope's temperature sensor. This way, the Calliope is cooled automatically when it gets too warm.

Fan at motor connector M0 in the red area of the expander board
Motor wiring
Finished program: fan on at 28 degrees, otherwise 0 percent
Automatic cooling
1 / 2

Practical Exercise 7: Servo Motor

A servo is a motor that can only turn within a certain range - in our case, up to 180 degrees. It consists of a motor, gears, and control electronics and is controlled using pulse-width modulation (PWM): A short pulse moves it to the left end position (0°), a longer one to the right (180°), and a medium one to the middle (90°).

Task: A servo is to be controlled by the Calliope. An object attached to the servo should move back and forth.

Wiring: Plug the servo connector onto the three protruding contact pins on the light green Port 1 - the brown wire on the left, the yellow one on the right. Brown is GND, red is the supply voltage, and yellow is the signal. Don't worry: Even if you get it wrong the first time, neither the Calliope nor the servo will be damaged.

Program: You can find the servo control block under Advanced → Pins. It’s called “set servo angle on P0 to 180°”. Place it in “forever” and change the angle to 90° - that’s the middle position.

Right-click the servo block and select “Duplicate” three times to copy it. This creates the movement sequence middle - left - middle - right, with angles of 90°, 0°, 90°, and 180°.

Upload the program to the Calliope. You’ll notice something’s wrong: The commands come one after another too quickly for the servo - it needs time to reach each position. How can you solve this problem? Tip: Try adding short pauses between positions.

The three wires of the servo connector: brown GND, red VCC, yellow signal
The servo's JR connector
Four servo blocks with angles of 90, 0, 90, and 180 degrees
The movement sequence Center-Left-Center-Right
Servo program with pauses between positions
The solution: Breaks between positions
1 / 3

Practical Exercise 8: MP3 – make the Calliope speak

An MP3 module is mounted on the expander board. It can read MP3 files from a memory card and play them through a speaker. This lets the Calliope play music, read out a voice message - or let a plant call for water when the potting soil is too dry.

Wiring: Check that the MP3 module with the Micro SD card is plugged into the expander. The speaker connector is next to it - this also needs to be plugged in.

Preparing the SD card: The card must be formatted as FAT32. Right-click the memory card icon, select “Format...” and choose “FAT32” under “File system”. Caution: This will delete all data on the card.

Then save your sound files to the card. You can record your own voice files on your computer or search online for “text to MP3”. For this guide, we’ll save three files: 0001.MP3, 0002.MP3 and 0003.MP3. The naming is important - always use four digits with leading zeros.

Program library: The MP3 module is relatively complex. To make it easy to work with, you’ll add a program library. To do this, open a new project in MakeCode and click “Extensions” in the programming blocks.

The tasks for playing an MP3 file are still missing here. Important for the MP3 module: Remove the blocks for serial communication, otherwise it won't work.

MP3 module and speaker on the expander board
Wiring the MP3 module and speaker

Practical Exercise 9: Reading RFID Cards

RFID (Radio Frequency Identification) transmits data wirelessly. It has two parts: the transmitter, also called a tag, and the receiver, also called a reader. When a tag comes close to the receiver, the receiver emits an energy field that wakes up the tag and gives it enough energy to transmit its data back.

Task, Part 1: Read the UID (Unique Identifier) of the RFID tags and display it in the serial monitor.

Task, Part 2: When the correct RFID tag is held up to the receiver, a melody should play.

Wiring: There is no pre-made cable for the RFID receiver. Plug one end into an I2C socket on the expander, then connect the wires one by one to the receiver: GND to GND, 3.3V to VCC, SDA to SDA, and SCL to SCL.

Program library: You won't find this library through the search function - you have to enter the link yourself in the search bar under “Extensions”: github.com/1010Technologies/pxt-makerbit-rfid

A new “MakerBit” category will then appear in the programming blocks. Place the “on RFID presented” block next to the other blocks - it runs in parallel with the main program and waits for a tag in the background.

Part 1: Go to “Variables” → “Make a Variable” to create a variable called “x”. Drag the “set x to 0” block into “on RFID presented” and replace the 0 with the “RFID UID” block from the “MakerBit” category. Use “serial write line” and the variable x to see the UID in the “Data” window. Your UID will definitely be different, since you're not using the same tag.

Part 2: Extend the program with “if true then” and a comparison: variable x equals the UID that was read. For the action, use the “play ... until done” block from “Music” → “more”.

This works - but the melody doesn't stop playing. The reason is that variable x stays unchanged until another tag is detected. A better approach is to reset the value after the melody plays. To do this, use “set x to 0” again. Note: x was saved as text, but the default block ends with the number zero. So, you need to insert a text block from Advanced → Text and enter any value in it - we chose “Empty”.

RFID receiver via four individual wires in the expander’s I2C section
Wiring the RFID receiver
Read RFID tag UID in the “Display data” window
The UID of the RFID tag
Ready-made RFID program with a text block for resetting the variables
The finished RFID program
1 / 3

Practical exercise 10: Recreate the Toniebox

A Toniebox is an audio system for children. It works without traditional buttons: when a child places a Tonie figure on the box, the corresponding audio file is played.

Task: An MP3 file should play when the corresponding RFID tag is held up to the reader. We’ll use the key fob for the first file and the chip card for the second.

Wiring: For this task, the RFID reader, MP3 module, and speaker must be connected.

Program: You already know the modules – now you should work as independently as possible. Follow these steps:

  • Connect the RFID reader, MP3 module, and speaker
  • Save two files named 0001.mp3 and 0002.mp3 on the SD card
  • Find and write down the UIDs of both RFID tags
  • Remove the blocks for serial communication, as the MP3 module won’t work otherwise
  • Work out the appropriate conditions: if one UID is recognized, play the first file; if the other is recognized, play the second
  • Add pauses so the files can play to completion

That’s all we’ll reveal. Use the example program only if you really can’t make any more progress – and remember that it contains our UIDs. Yours are different.

RFID receiver, MP3 module, and speaker connected together
Wiring for the Toniebox
Example program for the Toniebox with two UIDs and two MP3 files
The example program
1 / 2

Practical Exercise 11a: Using an OLED Display

Task, Part 1: An OLED should display your name.

Task, Part 2: An OLED should display the temperature.

Wiring: The wiring is a little more complicated than usual because there isn’t a ready-made cable. The display receives its data via the I2C interface, so connect it to the orange I2C area of the expander. It doesn’t matter which socket you use - many I2C modules can be connected in parallel. Connect the wires one by one: GND to GND, VCC to 3.3V, SDA to SDA, SCL to SCL.

Program library: In the “Extensions” section, enter “OLED” in the search field. The new “OLED12864_I2C” category will then appear among the program blocks.

The I2C address: Each I2C module has its own address - just like the address of the house you live in. The mail carrier knows exactly where to go. The address is a number given either in hexadecimal or decimal notation. For OLED displays, it’s usually 0x3C, or 60 in decimal notation.

Part 1: In the “on start” block, add the initialization block from the “OLED12864_I2C” category and enter 60. Then take the “show string” block. In the first and second fields, enter the position on the display - the X coordinate moves left and right, while the Y coordinate moves up and down. Leave both fields set to 0. In the third field, enter your name instead of “Hello”.

Part 2: There’s also a “show a number” block in the category. Add it and replace the number with the “Temperature (°C)” block from the “Input” section. To make it clear what the value represents, also add a text block with “Temperature:” before it, then use the coordinates to position the text and number next to each other.

Since both blocks are in the “forever” block, the temperature is read continuously. Hold your thumb on the temperature sensor - can you see the change on the display?

Depending on availability, the Calliope Expander is supplied with either an OLED display or an LCD display. First check which one you have: the next step applies to the LCD.

OLED display via four individual wires in the I2C section of the expander
Wiring the OLED display
Finished program: Text and temperature value side by side on the OLED
Text and measured value on the OLED
1 / 2

Practical Exercise 11b: Using an LCD Display

Task, Part 1: An LCD should display your name.

Task, Part 2: An LCD should display the temperature.

Wiring: As with the OLED, there is no pre-assembled cable. Connect the display to the expander’s orange I2C section: GND to GND, VCC to 3.3V, SDA to SDA, SCL to SCL.

Program library: In the “Extensions” section, enter “LCD1602” in the search field. The designation 1602 stands for the number of characters per row and the number of rows - so your display has two rows of 16 characters each. The new “I2C_LCD1602” category then appears.

The I2C address: For these displays, it is usually 0x27 or 0x3F, or 39 or 63 in decimal notation. Enter 39 in the initialization block - that is the usual case. Only if it doesn’t work later should you try 63.

Part 1: Use the “show string” block. The first field contains the text, and the second and third contain the position: The X coordinate moves left and right, while the Y coordinate determines the row - 0 is the top row, 1 the bottom. So X:0 Y:0 starts at the top at position 1, and X:7 Y:1 at the bottom at position 8.

Part 2: Use the “show number” block to display a number. Replace it with the “Temperature (°C)” block from the “Input” section. To make it clear what the number refers to, add a text block with “Temperature:” in front, then position both using the coordinates.

LCD display via four individual wires to the expander’s I2C section
LCD display wiring
Back of the LCD display with cables connected
This is what it looks like from the back.
Completed program: text block and number block with offset coordinates
Text and measurement value on the LCD
LCD display shows “Temperature:” and the measured value
The result on the display
1 / 4
Rate the instructions

Comments

Ask a question or share an experience

Contact us if something doesn’t work. Please include your board and the error message.

We review every comment before publication. Your email address remains with us.