Software Setup

Install MicroPython and configure Fabrica's control software

Step-by-step guide to installing MicroPython on Raspberry Pi Pico and using Thonny IDE for development

Install MicroPython

Step 1: Download MicroPython Firmware

Download the latest MicroPython UF2 file for Raspberry Pi Pico 2W:

Download MicroPython for Pico 2W

Look for the file named: RPI_PICO2-XXXXXXXX-vX.XX.X.uf2

Step 2: Enter Bootloader Mode

  1. 1.Disconnect the Pico 2W from your computer
  2. 2.Hold down the BOOTSEL button on the Pico
  3. 3.While holding BOOTSEL, connect the USB cable
  4. 4.Release BOOTSEL once connected
  5. 5.The Pico will appear as a USB drive named "RPI-RP2"

Step 3: Flash MicroPython

  1. 1.Drag and drop the .uf2 file onto the RPI-RP2 drive
  2. 2.The Pico will automatically reboot
  3. 3.The RPI-RP2 drive will disappear (this is normal)
  4. 4.MicroPython is now installed!

āœ“ The Pico should now show up as a serial device (e.g., /dev/ttyACM0 on Linux, COMx on Windows, /dev/tty.usbmodem on macOS)

Install Dependencies

Required MicroPython Libraries

Fabrica requires the following libraries to control the PCA9685 and manage servos:

1. PCA9685 Driver Library

Controls the 16-channel PWM driver for servo motors.

# Download pca9685.py from GitHub
# Place in the /lib folder on your Pico

# Or install via mpremote:
mpremote mip install pca9685

2. JSON Library (Built-in)

Used for saving and loading folding sequences. Already included in MicroPython.

3. Machine Library (Built-in)

Provides I2C, Pin, and hardware control. Built into MicroPython.

Using mpremote (Recommended)

Install mpremote on your computer to easily transfer files:

# Install mpremote
pip install mpremote

# Connect to Pico
mpremote connect /dev/ttyACM0

# Install libraries
mpremote mip install pca9685

Upload Control Software

Get the Source Code

Clone or download the Fabrica repository from GitHub:

git clone https://github.com/aiandrobotics/fabrica.git
cd fabrica/firmware

Or download as ZIP from the GitHub releases page.

šŸš€ Advanced Users: Prefer VS Code? check out our VS Code Workflow guide.

Project File Structure

firmware/
ā”œā”€ā”€ main.py              # Main application entry point
ā”œā”€ā”€ config.py            # Configuration settings
ā”œā”€ā”€ servo_controller.py  # Servo control logic
ā”œā”€ā”€ sequence_manager.py  # Folding sequence handling
ā”œā”€ā”€ storage.py           # File I/O for sequences
└── lib/
    └── pca9685.py       # PCA9685 driver library

Upload Files to Pico

Transfer all files to your Pico 2W:

Method 1: Using mpremote (Recommended)

# Copy all files recursively
mpremote cp -r firmware/* :

# Or copy individual files
mpremote cp main.py :
mpremote cp config.py :
mpremote cp servo_controller.py :
mpremote cp sequence_manager.py :
mpremote cp storage.py :
mpremote mkdir /lib
mpremote cp lib/pca9685.py :/lib/

Method 2: Using Thonny IDE

  1. 1. Install Thonny IDE from thonny.org
  2. 2. Select "MicroPython (Raspberry Pi Pico)" interpreter
  3. 3. Connect to your Pico via USB
  4. 4. Use File → Open to open each file
  5. 5. Use File → Save As → Raspberry Pi Pico to upload

Method 3: Using rshell

# Install rshell
pip install rshell

# Connect and copy files
rshell -p /dev/ttyACM0
> cp firmware/* /pyboard/
> exit

āœ“ Verify Installation

After uploading, verify the files are present:

mpremote ls
# Should show: main.py, config.py, servo_controller.py, etc.

Test Your Installation

Run Initial Test

Connect to the Pico's REPL (Read-Eval-Print Loop) to test the installation:

# Connect to REPL
mpremote

# Or using screen (Linux/Mac)
screen /dev/ttyACM0 115200

# Press Ctrl+D to soft reboot
# You should see the startup message

Expected Output:

MicroPython v1.23.0 on 2024-06-02; Raspberry Pi Pico 2W with RP2040
Type "help()" for more information.
>>> 
=== Fabrica Cloth Folding Robot ===
Initializing I2C...
PCA9685 found at 0x40
Servos initialized
Ready for commands

Test Servo Movement:

# In the REPL, run:
import servo_controller
sc = servo_controller.ServoController()

# Move panel 1 to 90 degrees
sc.move_servo(0, 90)

# Reset to home position
sc.home_all()

Troubleshooting

  • • ImportError: Check that all files are uploaded correctly
  • • I2C Error: Verify wiring connections (SCL, SDA, power)
  • • Servo not moving: Check power supply and servo connections
  • • Can't connect to REPL: Try different USB port or cable

Software Setup Complete!

Your Pico 2W is now running MicroPython with the Fabrica control software. Next, prepare the 3D printed parts for mechanical assembly.