pip install bambucontroll
from bambucontroll import printer
printer = printer(
ip="192.168.1.100",
printer_id="01P00A000000000",
password="12341234" # Also known as "ACCESS CODE"
)
printer.home()
Main class for connecting to Bambu Lab printers
printer(ip: str, printer_id: str, password: str, port: int = 8883,
client_id: str = "BambuControll", username: str = "bblp")
# Initialize printer connection
printer = printer(
ip="192.168.1.100",
printer_id="YOUR_PRINTER_ID",
password="YOUR_PASSWORD" # Also known as "ACCESS CODE"
)
Send a G-code command
| Parameter | Type | Description |
|---|---|---|
| command | str | G-code command |
printer.send_gcode("M104 S210")
Home all axes
printer.home()
# Home printer
printer.home()
Start a print from .gcode.3mf file.
| Parameter | Type | Description |
|---|---|---|
| filename | str | File name of the .gcode.3mf file on printer. |
| plate | int (optional)
|
Plate number (default: 1) |
| use_ams | bool (optional)
|
Use AMS (default: False) |
| timelapse | bool (optional)
|
Record timelapse (default: False) |
| flow_cali | bool (optional)
|
(default: False) |
| bed_leveling | bool (optional)
|
Do bed leveling (default: True) |
| layer_inspect | bool (optional)
|
(default: False) |
| vibration_calibration | bool (optional)
|
Do vibration calibration (default: False) |
printer.start_print("file.gcode.3mf", plate=1, vibration_calibration=True)
Control cooling fan speed
| Parameter | Type | Description |
|---|---|---|
| speed | int | Fan speed (0-255) |
# Set cooling fan to 100%
printer.cooling_fan(255)
Control chamber fan speed
| Parameter | Type | Description |
|---|---|---|
| speed | int | Fan speed (0-255) |
# Set chamber fan to 50%
printer.chamber_fan(127)
Control auxiliary fan speed
| Parameter | Type | Description |
|---|---|---|
| speed | int | Fan speed (0-255) |
# Set auxiliary fan to 25%
printer.aux_fan(63)
Set extruder temperature
| Parameter | Type | Description |
|---|---|---|
| temperature | int | Target temperature |
| wait | bool (optional)
|
It will wait for the temperature to be reached |
| state | str (optional)
|
The state to wait for. Can be "exect" (exact), "more" or "less" than the target temperature. Defaults to "exect". |
# Set extruder to 210°C
printer.set_extruder_temperature(210)
# Set extruder to 210°C and wait for the temperature to be reached
printer.set_extruder_temperature(210, wait=True)
Set bed temperature
| Parameter | Type | Description |
|---|---|---|
| temperature | int | Target temperature |
| wait | bool (optional)
|
It will wait for the temperature to be reached |
| state | str (optional)
|
The state to wait for. Can be "exect" (exact), "more" or "less" than the target temperature. Defaults to "exect". |
# Set bed to 210°C
printer.set_bed_temperature(210)
# Set bed to 210°C and wait for the temperature to be reached
printer.set_bed_temperature(210, wait=True)
Push parts of the printer
| Parameter | Type | Description |
|---|---|---|
| filename | str (optional)
|
Name of the gcode file. Example: "push.gcode" |
| under_temperature | int (optional)
|
Wait for the bed to cool under this temperature. Defaults to 30°C |
| object_hight | int (optional)
|
Set the height of the object. Defaults to 256mm. If there is more than one object select the highest one. |
| push_every | int (optional)
|
Push every this many mm. Defaults to 40mm |
# Push the print with "default" when the bed cools under 30°C
printer.push()
# Push the print with "p.gcode" when the bed cools under 50°C
printer.push("p.gcode", under_temperature=28, object_hight=56.3, push_every=20)
Control the printer light
| Parameter | Type | Description |
|---|---|---|
| state | str (optional)
|
light("on") or light() to turn the light on. Light("off") to turn it off |
# Turn the light on
printer.light()
# Turn the light off
printer.light("off")
while True:
cooling = int(input("Cooling fan speed: "))
printer.cooling_fan(cooling)
chamber = int(input("Chamber fan speed: "))
printer.chamber_fan(chamber)
aux = int(input("Aux fan speed: "))
printer.aux_fan(aux)
Ensure printer is connected to the network and credentials are correct.
Enable debug mode: printer.debug = True this will print all messages on printers MQTTs server.