Melopero Shake RP2040 User manual

MELOPERO
RST
CHG
BAT EN USB 13
13
12 11 10 96 5 SCL SDA
3.3V GND A0 A1 A2 A3 24 25 SCK
RESET
MO MI RX TX 4
I2C
BOOTSEL
SWD
Getting started with
Melopero Shake RP2040
Getting started with Melopero Shake RP2040
Version 1.0.0 - October 2021

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
This guide is constantly updated with corrections
and new content.
When a new version is released, we also update the
version number:
Version 1.1.0
October 2021

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
Contents
1. Hardware overview ......................................................4
1.1 LiPo Battery Charger. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Low Battery Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2. Pinout .............................................................................6
3. Installing CircuitPython ...............................................7
3.1 Download CircuitPython . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Install CircuitPython . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3 Install Mu editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4 Mu quick start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.5 The REPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4. Installing MicroPython ............................................. 11
4.1 Download MicroPython . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2 Install Thonny editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.3 Thonny quick start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.4 The REPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5. Setting up Arduino IDE ............................................. 14
5.1 Download the Arduino IDE . . . . . . . . . . . . . . . . . . . . . . . . 14
5.2 Add Shake RP2040 to Arduino IDE . . . . . . . . . . . . . . . . . . . 14
5.3 Using default I2C on Arduino IDE . . . . . . . . . . . . . . . . . . . . 15
6. Clear the Flash memory ........................................... 16
5.1 Flash nuke . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
1. Hardware overview
The Melopero Shake RP2040 is a development board based on the Raspberry Pi RP2040 micro-
controller, programmable in C/C++, MicroPython, CircuitPython and Arduino.
The board features:
• 16MB of FLASH Memory
• 3.7-4.2 LiPo battery charger (200mA charge current)
• Battery monitor (it sends an alert when the battery voltage drops at 3.4V)
• Reset and boot buttons (no need to detach/attach the board to enter boot mode)
• Qwiic/Stemma QT connector for attaching lots of Melopero, Adafruit and * SparkFun sen-
sors
• Classic Feather pinout for maximum compatibility
• USB-C connector for powering, programming and charging
• JST 2-pin connector for attaching the battery (we follow the Adafruit and SparkFun batteries
polarity)
• Green user LED on pin 13
• RGB WS2812 LED (aka NeoPixel)
• Orange LED for signaling the charging status
• SWD header for debugging
• 4 mounting holes
• Programmable in C/C++, MicroPython, CircuitPython and with the Arduino IDE.
Dimensions: 2.0” x 0.9” x 0.28” (50.8mm x 22.8mm x 7.05/max height)
16MB Flash memory
BOOTSEL button Qwiic / STEMMA QT Connector
Low Battery Monitor
LiPo Battery Charger
JST battery connector
User LED Charge status LED
USB-C input power and programming
WS2812 RGB LED
RESET button

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
1.1 LiPo Battery Charger
The Melopero Shake RP2040 features a battery charger based on the MCP73831 IC, for use with
LiPo 1-cell 3.7-4.2 batteries.
The JST connector polarity is shown on the pinout chart in section 2, and it follows the same pola-
rity of Adafruit’s and Sparkfun’s batteries.
The fast charge current has been set to ~200mA, for this reason a battery with a capacity of at
least 500mAh must be used.
1.2 Low Battery Monitor
The Shake RP2040 is also equipped with a low battery monitor, connected to pin GP17, that will
send a LOW signal on the ouput as soon as the battery voltage drops to 3.4V.
After a low battery status is detected, the battery monitor output will be back to HIGH when the
voltage will reach around 3.6V.
Please note the monitor works when the battery is not in charging status and no power input is
connects to the USB-C or to VBUS pin.
The battery monitor output is available as a digital signal (HIGH or LOW) on pin GP17, depending
on the language IDE, the pin name will be:
• D17 for CircuitPython
• 17 for MicroPython
• 17 for the Arduino IDE

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
2. Pinout
MELOPERO
PINOUT
SHAKE RP2040
MELOPERO
WWW.MELOPERO.COM
®
27 GP16
NEOPIXEL
16
28 GP17 D17 17
Wire Wire1
Wire1
44 SCL0 CS1 RX0 GP13 D13
D12
GP12TX0MISO1SDA043
D11GP11RTS1MOSI1SCL142
D10GP10CTS1SCK1SDA141
D9GP09RX1CS1SCL038
D6GP08TX1MISO1SDA037
D5
GP07RTS1
MOSI1
SCL135
SCLGP03RTS0MOSI1SCL130
SDAGP02CTS0SCK0SDA129
VBAT
EN
VUSB
A1 39GP27 RTS1 MOSI1 SCL1
A2 40GP28 TX0 MISO1 SDA1
A3 41RX0GP29 CS1 SCL0
D25 37GP25 RX1 CS1 SCL0
SCK 29GP18 CTS0 SCK0 SDA1
MOSI 30GP19 RTS0 MOSI0 SCL1
MISO 31GP20 TX1 MISO0 SDA0
RX 3RX0GP01 CS0 SDA0
TX 2GP00 TX0 MISO0 SCL0
D4 8GP06 CTS1 SCK0 SDA1
A0 GP26 CTS1 SCK1 SDA1 38
TX1
13
12
11
10
9
8
SCL0
SDA0
7
SCL1
SDA1
3
2
SCLGP03RTS0MOSI1SCL130
SDAGP02CTS0SCK0SDA129
SCL1
SDA1
A1
A2
A3
25
SCK
MOSI
MISO
RX
TX
6
A0
24
MAX output 400mA
GPIO MAX current 12mA per pin
MELOPERO
RST
CHG
BAT EN USB 13
13
12 11 10 96 5 SCL SDA
3.3V GND A0 A1 A2 A3 24 25 SCK
RESET
MO MI RX TX 4
I2C
BOOTSEL
SWD
!RST
3V3
3V3
GND
3V3
GND
44
CircuitPython
Arduino IDE
3.7-4.2 LiPo Battery
Charge current ~200mA
UART
SPI
WS2812 RGB LED
LOW BATTERY MONITOR
I2C
RP2040 Physical PIN
RP2040 GPIO / MicroPython
D24 36GP24 MISO1 SDA0
The pinout chart above is useful to quickly nd the right name to use for a specic pin, depending on the
language and IDE. As example, note how the pins labeled as 4, 5 and 6 change name depending on which
platform are using to program the board:
• CircuitPython refer to those pins as D4, D5 and D6
• In the Arduino IDE they are 7, 8 and 6 (check the green labels)
• For use with MicroPython, they are called with the number you nd in the GPxx labels (only the number)

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
3. Installing CircuitPython
3.1 Download CircuitPython
CircuitPython is a derivative of MicroPython designed to simplify experimentation and education
on low-cost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront
desktop software downloads. Simply copy and edit les on the CIRCUITPY drive to iterate.
CircuitPython is developed and maintained by Adafruit Industries, along with many sensors
libraries to start your project in the blink of an eye.
As we write the rst version of this guide, the Melopero Shake Rp2040 is already listed on the o-
cial CircuitPython.org website, but the .uf2 le is not available yet, it’ll be released automatically at
the rst new CircuitPython release.
For the sake of completeness, we show you where to always nd the latest version of Circui-
tPython for the Melopero Shake RP2040 in the near future.
In the meantime, you can download the latest current version (7.0.0) from our server, at the fol-
lowing address:
www.melopero.com/melopero_shake_rp2040_circuitpython.uf2
To download the latest version of CircuitPython for Melopero Shake RP2040, visit www.circui-
tpython.org, click “download” and search for “melopero shake rp2040”.
On the Shake RP2040 page, you can select your preferred language and download the .uf2 le.

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
3.2 Install CircuitPython
After downloading the latest version of CircuitPython, activate the boot loader mode on your
board and copy the .uf2 le to it.
To enter the bootloader, when the Shake is already connected to your computer's USB port, press
and hold the BOOT / BOOTSEL button (circled in red in the image below), then press and release
the reset button (circled in green). Continue holding the BOOT / BOOTSEL button until the RPI-
RP2 appears.
You can also start with your board unplugged from USB, press and hold the BOOTSEL button
on your Shake RP2040. While holding the button, connect the other end of the USB cable to the
Shake board. This will cause Shake to load his bootloader. You should see the RPI-RP2 appear as
a new drive on your computer when you do this.
You will see a new disk drive appear called RPI-RP2.
Drag (or copy and paste) the adafruit_circuitpython_melopero_shake_rp2040_xxxxxxx.uf2 le to
RPI-RP2.
The RPI-RP2 drive will disappear and a new disk drive called CIRCUITPY will appear.

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
Mu is a Python code editor for beginner programmers and it’s the recommended editor for pro-
gramming in CircuitPython.
It’s available for Windows, Mac and Linux at the following address:
https://codewith.mu/en/download
The rst time you’ll run Mu editor, it should ask for which mode you want to load.
Select “CircuitPython”. You can always change mode by clicking on “mode” in the upper menu
and selecting your favourite one.
3.3 Install Mu editor

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
3.4 Mu quick start
3.5 The REPL
Mu will auto-detect your CircuitPython board.
On the upper menu, clicking “new”, you’ll create a new le.
Once you have connected the Melopero Shake RP2040, click “Load“, then select the CIRCUITPY
driver, and open code.py. After editing this le, click “Save“, and it’ll be loaded on your board.
The REPL, Read-Evaluate-Print-Loop, allows you to execute lines of code directly in the console
and get an immediate result.
Click “Serial“ to open the serial console and then press any key to enter the REPL.
Use CTRL-D to reload.
Try to run the command print(“hello world“) and press enter.
The REPL will interpret the line of code and get you the result, in this case it’ll print “hello world”.

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
4. Installing MicroPython
MicroPython is a lean and ecient implementation of the Python 3 programming language that
includes a small subset of the Python standard library and is optimised to run on microcontrollers
and in constrained environments.
MicroPython is a full Python compiler and runtime that runs on the bare-metal. You get an inte-
ractive prompt (the REPL) to execute commands immediately, along with the ability to run and
import scripts from the built-in lesystem. The REPL has history, tab completion, auto-indent and
paste mode for a great user experience.
To download the latest MicroPython release for the Melopero Shake RP2040 from our server, go
to the following address:
www.melopero.com/melopero_shake_rp2040_micropython.uf2
After downloading the MicroPython uf2 le, activate the boot loader mode on your board and
copy the .uf2 le to it.
To enter the bootloader, when the Shake is already connected to your computer’s USB port, press
and hold the BOOT / BOOTSEL button (circled in red in the image below), then press and release
the reset button (circled in green). Continue holding the BOOT / BOOTSEL button until the RPI-
RP2 appears.
You can also start with your board unplugged from USB, press and hold the BOOTSEL button
on your Shake RP2040. While holding the button, connect the other end of the USB cable to the
Shake board. This will cause Shake to load his bootloader. You should see the RPI-RP2 appear as
a new drive on your computer when you do this.
You will see a new disk drive appear called RPI-
RP2.
Drag (or copy and paste) the adafruit_circui-
tpython_melopero_shake_rp2040_xxxxxxx.uf2 le
to RPI-RP2.
The RPI-RP2 drive will disappear and a new disk
drive called CIRCUITPY will appear.
4.1 Download MicroPython

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
Thonny is a Python code editor for beginner programmers and it’s the recommended editor for
programming in RP2040 based boards with MicroPython.
It’s available for Windows, Mac and Linux at the following address:
https://thonny.org
The rst time you’ll run Thonny editor, you should set MicroPython on Raspberry Pi Pico and
select the right port fo your connected device.
Go to Preferences (should be options/settings on windows), click “Interpreter” tab and then select
Micropython (Raspberry Pi Pico) and the right port from the port menu (your board must be con-
nected and with MicroPython already installed)
4.2 Install Thonny editor

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
4.3 Thonny quick start
4.4 The REPL
Write some code in the script area of Thonny. When ready click RUN or SAVE, Thonny will promt
you to select where you want to execute/save the script. Select “Raspberry Pi Pico” and give a
name to the le. If you have some prints in your code, you’ll see them in the Shell.
The REPL, Read-Evaluate-Print-Loop, allows you to execute lines of code directly in the console
and get an immediate result.
In the Shell, try to run the command print(“hello world“) and press enter.
The REPL will interpret the line of code and get you the result, in this case it’ll print “hello world”.

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
5. Setting up Arduino IDE
5.1 Download the Arduino IDE
5.2 Add Shake RP2040 to Arduino IDE
To download the Arduino IDE for your favourit OS go to:
https://www.arduino.cc/en/software
To add support for the Shake RP2040 to the Arduino IDE, we use the port of the RP2040 develo-
ped by Earle F. Philhower, III (earlephilhower on GitHub)
Go to File>Preferences and enter the following URL in the “Additional Boards Manager URLs”
eld:
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
Once the URL has been added, go to Tools>Board>Boards Manager and search “Melopero”
After the installation, you’ll be able to select Melopero Shake RP2040 as the board, going to Tool-
s>Board>Raspberry Pi RP2040 boards>Melopero Shake RP2040

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
5.3 Using default I2C on Arduino IDE
If you look at the pinout diagram in section 2, you’ll notice that you have two I2C buses, Wire on
pins GP09 and GP08, and Wire 1 on pins GP03 and GP02, also available through the Qwiic con-
nector.
If you are connecting a sensor on the I2C bus using the Qwiic connector on the Shake, remember
to replace, in your Arduino Sketch, Wire with Wire1.
(This modication does not apply if you are using I2C0/Wire pins on the Shake RP2040, GP09
and GP08, check the pinout diagram in section 2 ).
Usually, this modication must be applied on the initialization:
Wire1.begin() instead of Wire.begin(),
on the object initialization, passing to the function the I2C address and the bus instead of using
defaults values (it’s common use on the libraries to give the user the option of passing these
information to the init function):
sensor.init_device(0x77, Wire1)
Finally, you must modify all the calls to the Wire library, e.g.:
Wire1.beginTransmission()
Wire1.endTransmission()
etc.

Getting started with Melopero Shake RP2040
Version 1.1.0 - October 2021
6. Clear the Flash memory
5.1 Flash nuke
If you need to do a deep clean of the ash memory, download the following uf2 le and install it
on the Shake RP2040 as you did for CircuitPython or MicroPython (see sections 3.2 and 4.1):
www.melopero.com/melopero_shake_rp2040_ash_nuke.uf2
This manual suits for next models
1
Table of contents
Other Melopero Motherboard manuals