What you need 2 min
Pybricks is new firmware for the hub: the program that runs the hub itself. Once it is installed, the hub runs Python programs you write in your web browser.
- A SPIKE Prime hub, charged. The install takes a few minutes and must not lose power halfway.
- The hub’s USB cable. The install uses the cable. After that, you connect over Bluetooth.
- A computer with Windows 10 or 11, macOS, Linux or ChromeOS. An Android tablet works too. An iPad or iPhone does not.
- Google Chrome or Microsoft Edge. Firefox cannot talk to Bluetooth devices, so it cannot connect to the hub.
Nothing here is permanent. You can put the LEGO firmware back at any time (section 8) and use the SPIKE App again.
Teachers: before the first class once
Installing on twelve hubs at once is slow and noisy. Do it before lesson 1, so the lesson is about the first program.
- Charge every hub.
- Install Pybricks on each one (section 3). Give each hub a short, different name, such as a team name or an animal. Put a sticker with that name on the hub.
- Keep a list of hub names and which team has which. At a competition there may be forty hubs in one room, all called “Pybricks Hub” unless someone named them.
- On Windows laptops, do the USB driver step (section 4) once per laptop. It is only needed the first time.
- Open code.pybricks.com once on every class laptop while online. After that it also works offline.
Install Pybricks 10 min
1. Open the install wizard
Go to code.pybricks.com. Click the gear button at the top left to open settings. Under Firmware, click Install Pybricks firmware.
2. Choose the hub, accept the licence, name it
- Select hub type: click the SPIKE Prime hub, then Next.
- Accept licenses: Pybricks is free, open-source software. Read the licence, tick the box, then Next.
- Configure options: type the hub’s name in Hub name. Keep it short. If you see “The name is too long”, shorten it. Then Next.
3. Put the hub in update mode
The last step shows a short video. These are the same steps, in words:
- Unplug the USB cable and make sure the hub is turned off.
- Press and hold the Bluetooth button on the hub.
- Still holding it, plug in the USB cable.
- Keep holding until the Bluetooth light blinks pink, green, blue, off, over and over.
- Let go of the Bluetooth button.
4. Install
- Click Install.
- A browser pop-up asks which device to use. Choose LEGO Technic Large Hub in DFU Mode and click Connect.
- Wait for the progress bar to finish. Do not unplug the cable until it does.
No “DFU Mode” device in the list? The hub is not in update mode. Unplug, switch off, and do step 3 again. Hold the button until the light really blinks. Letting go too early is the most common mistake. On Windows, also check the USB driver steps.
Windows only: the USB driver 5 min, once per laptop
If you are using Pybricks on a Windows computer for the first time, the wizard may say you need to install a USB driver. Do this once, with the hub in update mode (“Put the hub in update mode” above) and plugged in:
- Right-click the Windows Start menu, then click Device Manager.
- Look for the hub under Other devices.
- Open it, and in its Properties click Update Driver…
- Click Browse my computer for drivers.
- Click Let me pick from a list of available drivers on my computer.
- Select Universal Serial Bus devices, then Next.
- In Manufacturer choose WinUsb Device. In Model also choose WinUsb Device. Click Next.
- Windows warns that the driver is not recommended. Click Yes. The driver works.
- Click Close. Now go back to the install and click Install.
Connect over Bluetooth 2 min
- Unplug the cable. Turn the hub on with the centre button. The light blinks blue: it is waiting for you.
- In Pybricks Code, click the Bluetooth button in the toolbar (“Connect using Bluetooth”).
- A pop-up lists nearby hubs. Pick your hub’s name and click Pair.
Never pair the hub in your computer’s Bluetooth settings. Always connect from Pybricks Code. If someone already paired it in Windows or macOS settings, remove it there first, then connect from Pybricks Code.
Your first program 5 min
Click the page button at the top left to open your files, then the + button to make a new file.
Click Create. The template writes the import lines for you, and the program starts with hub = PrimeHub().
print() appears and errors are shown, is at the bottom.The buttons along the top, left to right:
- Page — show or hide your files.
- Gear — settings, firmware and help.
- USB plug and Bluetooth — connect to the hub. The lessons use Bluetooth.
- Play — run this program (shortcut F5). It is sent to the hub and starts.
- Square — stop the program.
- >>> — type Python one line at a time in the terminal (the REPL). Useful for testing one sensor quickly.
On the hub itself:
- The centre button starts the last program, even with no computer connected. Press it again to stop.
- The hub has 5 program slots. Use the left and right buttons to choose one. A program you run from Pybricks Code is stored in that slot.
- To switch the hub off, hold the centre button for three seconds.
Now go to Level 5 lesson 1 and write the first program.
Save and back up your programs 3 min
Your programs are stored inside the browser, on that one computer. If someone clears the browser’s data, they are gone.
- To back up one program, select it in the file list and click the download button beside it (“back up to your computer”).
- To back up everything, click the box button at the top of the file list (“Back up all files”). You get one zip file.
- To bring programs onto another computer, use the upload arrow (“Import a file”).
- Switch the hub off properly (hold the centre button). If the battery is pulled out first, the program on the hub is not saved.
For competitions: back up all files at the end of every session. Take the zip to the event on a USB stick and a second laptop. A team whose only copy is in one browser has one point of failure (see Level 5 lesson 23).
Go back to the LEGO firmware 5 min
To use the SPIKE App again, open settings (the gear) and click Restore official LEGO firmware. Choose the SPIKE Prime hub and follow the screen. It uses the same update-mode steps as the install (section 3, step 3), and the button says Restore instead of Install.
You can switch between Pybricks and LEGO firmware as often as you like. Back up your programs first (section 7), so nothing depends on what is left on the hub.
When something goes wrong reference
| What you see | Try this |
|---|---|
| No “DFU Mode” device in the install pop-up | The hub is not in update mode. Redo section 3, step 3, and hold the button until the light blinks. On Windows, do section 4. |
| An error as soon as the install starts | The Bluetooth button was released too early. Start again. |
| The hub switches off during the install | The button was held too long. Release it as soon as the light starts blinking. |
| The hub is not in the Bluetooth list | Turn the hub on (blinking blue). Remove it from the computer’s own Bluetooth settings. Turn off other Bluetooth devices nearby, especially keyboards and mice. |
| The page acts strangely or will not connect | Refresh with Ctrl+F5. If Windows Bluetooth seems stuck, restart the computer. |
| Lots of hubs in the list, all the same name | Nobody named them. Reinstall with a name (section 3), and put a sticker on the hub. |
| Still stuck on one laptop | Try another computer. Pybricks sometimes works on a Mac, Chromebook or Android tablet when a Windows laptop will not. |
Still stuck? Pybricks Code’s settings has Community answers, which opens the Pybricks discussion forum.