Skip to main content

Introduction

Documentation Status Discord Build Status Code Style: Ruff

A library to interface with a Bambu Labs 3D printer and query status and information

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle or individual libraries can be installed using circup.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install circuitpython-bambulabs

To install system-wide (this may be required in some cases):

sudo pip3 install circuitpython-bambulabs

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .env/bin/activate
pip3 install circuitpython-bambulabs

Installing to a Connected CircuitPython Device with Circup

Make sure that you have circup installed in your Python environment. Install it with the following command if necessary:

pip3 install circup

With circup installed and your CircuitPython device connected use the following command to install:

circup install bambulabs

Or the following command to update an existing version:

circup update

Obtaining Your Printer Credentials and Save in settings.toml

  1. Login to MakerWorld.

  2. Open the dev-tools (F12 in most browsers) and select Application > Cookies > https://makerworld.com.

  3. Copy the token string and save it as BAMBU_ACCESS_TOKEN in settings.toml.

  4. Access https://makerworld.com/api/v1/design-user-service/my/preference and copy uid as USER_ID.

  5. Access https://makerworld.com/api/v1/iot-service/api/user/bind and copy dev_id as DEVICE_ID.

  6. On your printer, go to Settings and obtain the IP address and copy it as BAMBU_IP.

You will need a settings.toml file with the following to connect via MQTT:

  • CIRCUITPY_WIFI_SSID = “your_wifi_ssid”

  • CIRCUITPY_WIFI_PASSWORD = “your_wifi_password”

  • BAMBU_BROKER = os.getenv(“BAMBU_BROKER”)

  • ACCESS_TOKEN = os.getenv(“BAMBU_ACCESS_TOKEN”)

  • USER_ID = os.getenv(“USER_ID”)

  • DEVICE_ID = “your_printer_serial_number”

  • BAMBU_IP = “your_printer_IP_address”

Misc. information

This library queries your Bambu Labs 3D printer via the Bambu Cloud using MQTT 5.0. Local mode is not supported due to it using MQTT 3.1.1. Issuing commands to your Bambu printer is out of scope for this library.

Usage Example

import json
import os

import wifi

import bambulabs as bl

# You will need a settings.toml file with the following to connect via MQTT:
# bambu_broker = os.getenv("BAMBU_BROKER")
# access_token = os.getenv("BAMBU_ACCESS_TOKEN")
# user_id = os.getenv("USER_ID")
# DEVICE_ID = "your_printer_serial_number"

# Set up networking
print("Connecting to AP...")
wifi.radio.connect(os.getenv("CIRCUITPY_WIFI_SSID"), os.getenv("CIRCUITPY_WIFI_PASSWORD"))
print(f"Connected to {os.getenv('CIRCUITPY_WIFI_SSID')}")
print(f"My IP address: {wifi.radio.ipv4_address}")

device_id = os.getenv("DEVICE_ID")

printer = bl.BambuPrinter(bl.BambuPrinter.__init__, device_id)
printer.connect()

status = printer.pushall()

if status is None:
    print("Timed out waiting for pushall response.")
else:
    # Print out each individual status
    print("--- Printer Status ---")
    print(f"State:             {status.gcode_state}")
    print(f"File:              {status.gcode_file}")
    print(f"Job:               {status.subtask_name}")
    print(f"Progress:          {status.print_percentage}%")
    print(f"Remaining:         {status.remaining_time} min")
    print(f"Layer:             {status.current_layer} / {status.total_layers}")
    print(f"Print speed:       {status.print_speed}")
    print(f"Print error:       {status.print_error_code}")
    print(f"Nozzle temp:       {status.nozzle_temperature} / {status.nozzle_temperature_target} C")
    print(f"Bed temp:          {status.bed_temperature} / {status.bed_temperature_target} C")
    print(f"Chamber temp:      {status.chamber_temperature} C")
    print(f"Part fan:          {status.part_fan_speed}")
    print(f"Aux fan:           {status.aux_fan_speed}")
    print(f"Chamber fan:       {status.chamber_fan_speed}")
    print(f"Nozzle type:       {status.nozzle_type}")
    print(f"Nozzle diameter:   {status.nozzle_diameter} mm")
    print(f"WiFi signal:       {status.wifi_signal}")
    print(f"Light state:       {status.light_state}")
    print(f"Firmware version:  {status.firmware_version}")
    print()
    # Print the entire JSON response
    print("--- Raw JSON ---")
    print(json.dumps(status.raw))

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

This library was created with the assistance of Claude. (I know, I know…)

Release files for circuitpython-bambulabs 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for circuitpython-bambulabs 1.0.0
File Size Uploaded
circuitpython_bambulabs-1.0.0.tar.gz 27.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for circuitpython-bambulabs 1.0.0
File Interpreter ABI Platform
circuitpython_bambulabs-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.9 kB

Release files / circuitpython_bambulabs-1.0.0.tar.gz

Download URL circuitpython_bambulabs-1.0.0.tar.gz
Size 27.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fde0ff9ad5c31041a3114796b3c029db67776644957fe1e92bdb53694fece5f3
BLAKE2b-256 checksum
How to use checksums
d65f9e0e16e9d8c76ea86ba19a2626e259896ef3aac8631b9f41b74fb3e51967
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / circuitpython_bambulabs-1.0.0-py3-none-any.whl

Download URL circuitpython_bambulabs-1.0.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab1d33872b5fd36cb5e1a2426dee2806a9bf2b3a28dc2e620bb37172995b62e2
BLAKE2b-256 checksum
How to use checksums
8808af9ef3086ce38bf38182580fc066327ca1b9b3a1d07e7fdf4fcb691ef458
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page