Raspberry Pi Build HAT for LEGO
The Raspberry Pi Build HAT combines the power of Raspberry Pi computing with LEGO® hands-on learning to enable a fun and creative learning experience for students, teachers and makers. The Build HAT is compatible with the most recent generation of LEGO® Technic™ motors, and with sensors included in the LEGO® Education SPIKE™ Prime portfolio. The HAT is the second Raspberry Pi product, after Raspberry Pi Pico, to be powered by the Raspberry Pi RP2040 microcontroller.
Specifications:
• Controls up to 4 motors and sensors.
• Powers the Raspberry Pi (when used with a suitable external PSU).
• Easy to use from Python on the Raspberry Pi.
A whole new world
Raspberry Pi has released an add-on that will let you use many of its tiny, inexpensive computers to control certain Lego robot motors and sensors. The add-on is called the Build HAT, and slotting it onto a Raspberry Pi’s GPIO pins will give you four ports that you can use to control things like the Lego Education’s SPIKE components. Which the HAT and its software are specially designed for. It’ll also connect to most other parts that use an LPF2 connector. Including the components from the Lego Mindstorms robot inventor kit.
There’s also a Python library (basically a set of commands you can use to control the robot) available to go alongside the HAT, which will let you write software to control the robot parts you’ve got hooked up. Programing Lego’s SPIKE components with Python isn’t a unique selling feature from Raspberry Pi — the SPIKE kit comes with a hub that supports connecting six devices (compared to the Build HAT’s four) that can also store and run Python programs.Adding a Pi to a project gives you a lot of flexibility
Install the buildhat Python library
Open a terminal window on your Raspberry Pi by pressing Ctrl+Alt+T.
At the prompt type: sudo pip3 install buildhat
Press Enter and wait for the “installation completed” message.
Raspberry Pi says that hooking the Build HAT up to an 8V power supply with a barrel plug will let it provide juice to both the Lego accessories connected to it and the Raspberry Pi itself. The company will sell a specific 48W power supply to go along with it if you don’t have one that’s capable.
If your kid or students are playing around with Lego’s SPIKE robots but want to go deeper into programming and electronics modding, the HAT could be a good way to help them do that with the motors and sensors you already have. Plus, Raspberry Pi and Lego seem to be a perfect match for each other — both brands have a sort of DIY spirit and could make some interesting projects if they end up doing more work together.
Build HAT Links
- Raspberry Pi Build HAT Website
- Getting started with the Raspberry Pi Build HAT
- Raspberry Pi Build HAT Projects
- Raspberry Pi Build HAT Documentation and Python Library
- LEGO Device compatibility
- Build HAT Announcement Article
LEGO Links
- Meet LEGO® Education SPIKE™ Prime
- Getting started with LEGO® Education SPIKE™ Prime
- LEGO® Education SPIKE™ Prime Set (45678)
Read more: