Installing the EXP6 library: MINDSTORMS Robot Inventor (51515)
For teachers, students and first-time users: follow these steps in order and the LEGO MINDSTORMS Robot Inventor (51515) hub can control the EXP6 with Python. You install the library only once; every Python project can then use it. Install it again after a hub firmware update.
Using LEGO Education SPIKE Prime (SPIKE App 3)? See the Education install guide.
What you need
- A Robot Inventor hub (battery charged)
- A USB cable or Bluetooth, either works (USB is recommended: the cable that came with the hub works; charge-only cables do not)
- A computer or tablet with the LEGO MINDSTORMS App (Robot Inventor App 10.x)
- EXP6 firmware dated 2026-11-03 or later
- MBC_EXP6_Robot_Inventor_Lib.zip from this site, unzipped
USB or Bluetooth
We have installed it in the App both ways and both worked (Bluetooth took about 3 seconds). USB is recommended: the install sends a fairly large file, and a cable is steadier. If you have no data cable at hand, Bluetooth works too.
LEGO stopped updating and supporting the Robot Inventor App on 2026-10-01; on 2026-11-05 we tested App 10.5.4 and installing and running both work.
Install steps
- Connect the hub to the computer with the USB cable (or use Bluetooth) and press the centre button to turn it on.
- Open the LEGO MINDSTORMS App and connect to the hub (the App shows it is connected).
- Make a new project and choose Python.
- Open the unzipped
Install_MBC_exp6_Lib.pyin a text editor, select all and copy. - Delete what is in the App's Python editor and paste what you copied.
- Press the App's Run button (▶).
- Open the console at the bottom of the App. Within about 10 seconds you will see:
MBC_exp6_SPIKE_App_Lib.py … B OK
MBC_exp6_mbc.py … B OK
MBC_exp6_cam.py … B OK
安裝成功! (Installed OK) "Installed OK" means you are done. You can delete this install project; the library stays on the hub (/projects/mbc_exp6/, kept after power-off).
8. If you installed over USB, you can unplug the cable now and connect over Bluetooth from then on.
Tip
If you see "Install failed, please run again": press Run once more. If it still fails, connect by USB and install again.
Start programming
- Connect the EXP6 battery and plug the EXP6 Host cable into a hub port (for example port F).
- Make a new Python project and start it like this:
from hub import port
import time
from projects.mbc_exp6.MBC_exp6_SPIKE_App_Lib import MBC_EXP6
exp = MBC_EXP6(port.F) # EXP6 on hub port F
exp.motor_run(1, 50) # motor on EXP6 port 1 at 50% speed
time.sleep(2)
exp.motor_stop(1, "brake") # brake to a stop- Press Run. You can also open the 10 examples in the
examplesfolder of the download pack (EXP6 in port F, motors in EXP6 ports 1 and 2; they print their messages in Chinese).
Try each function in your browser first: Robot Inventor App interactive tutorial; everything is explained in the Robot Inventor section of the official App guide.
3 things to know on Robot Inventor
- After running a program, the EXP6 only goes back to normal when you take out its battery: until then the App's device screen does not show the EXP6, which is normal. Before moving it to another hub (for example an Education SPIKE Prime), take the EXP6 battery out and put it back.
- The motors stop by themselves within 10 seconds after the program ends: to keep a motor turning longer than 10 seconds while doing nothing else, wait with
exp.keep_alive_wait(ms), for exampleexp.keep_alive_wait(15000)for 15 seconds. - The import line differs from the Education version: on Robot Inventor it is
from projects.mbc_exp6.MBC_exp6_SPIKE_App_Lib import …; a wrong line gives anImportError.
Remove
To remove it: make a new Python project, paste Uninstall_MBC_exp6_Lib.py from the download pack and run it until you see "Uninstall Successful!".
Troubleshooting
| What you see | What to do |
|---|---|
ImportError: no module named … |
Not installed, or a firmware update wiped it → install again; also check the import line has projects.mbc_exp6. |
| "讀不到擴充板資料" (cannot read the expander) | Check the EXP6 battery, and that the port in MBC_EXP6(port.X) is the one it is plugged into |
| The hub switches off during install | Connect by USB and install again |
| The motors stop after a while | Nothing called the library for 10 seconds → wait with exp.keep_alive_wait(ms) |
| The App's device screen does not show EXP6 | Take the EXP6 battery out and put it back |
MemoryError |
The program is too big → split it, restart the hub and try again |
Still stuck? Contact us with a screenshot of the console messages.