Raspberry Pi: This new add-on will let you connect Lego to your creations

Lego and Raspberry Pi are teaming up to let users take their projects to the next level.
Written by Daphne Leprince-Ringuet, Contributor

The Build HAT is compatible with Lego Technic motors of different sizes and various sensors from the Lego Spike portfolio.

Image: Raspberry Pi

Raspberry Pi has announced a new collaboration with Lego, which will enable users to integrate a whole new range of sensors, motors and other special pieces into their creations. 

The project has been two years in the making, according to Raspberry Pi's program manager Richard Hayler, and takes the form of a $25 add-on board called the Build HAT (an acronym for "Hardware Attached on Top") that can connect to the computer on one end while attaching to Lego components on the other. 

Specifically, the Build HAT is compatible with Lego Technic motors of different sizes and various sensors from the Lego Spike portfolio – think distance sensors, color sensors and force sensors. These are designed for users to create more advanced models than they can with traditional brick components, with Spike sets even coming with an app that lets makers program their builds with a drag-and-drop coding language based on Scratch. 

SEE: Best STEM kits, robots, and other tech gifts for hackers of all ages

Now, it is possible to connect up to four sensors and motors to the Build Hat's LPF2 connectors. Components from other Lego ranges can also be connected to the board, provided that they use the right connector. You can check the list that Raspberry Pi has compiled of all the compatible Lego elements, which also includes pieces from the Lego Mindstorms robot inventor kit, for example. 

The Build Hat is equipped with an onboard RP2040 that takes care of the low-level control of the Lego pieces. At the same time, the board can be fixed onto the 40-pin GPIO header that sits on most Raspberry Pi boards, including Raspberry Pi 4 and Raspberry Pi Zero. This lets users program the sensors and motors using Python to build their project. 

Creators, therefore, have more flexibility in their builds: contrary to using the Lego components by themselves, they can have a programmable, networked computer with access to online data sources at the heart of their project. What's more, developers can make use of the Raspberry Pi's extra GPIO pins to connect to other devices, electronics and sensors, opening up the field of possibilities for projects even more. 

Hayler announced that a Python library for the Build Hat has already been created to help users combine Lego pieces with their Raspberry Pi. The library includes guides to a handful of projects that have been programmed by the organization's own developers, such as a DIY game controller using Lego's motor encoder and wheel, a robot car complete with LED lights that can be controlled with a Bluetooth connection from an Android phone, or a robot face that reacts to different objects thanks to machine learning. 

Since these projects are a step up in terms of power consumption – driving Lego's Technic motors alone requires an extra 7.5V of power supply – Raspberry Pi is also launching a new power supply tailored for the Build Hat that is priced at $15 and can support both the computer and all of its connected devices. 

SEE: Want to get things done in tech? You'll need these surprising new allies

It's now up to developers, therefore, to make use of their imagination and come up with new Lego-improved use cases for their computer boards. And although the partnership's objective is to a large extent to improve learning for young people interested in science, technology and engineering, there seems to be lots of scope for adults too to use the Build Hat.  

"We are excited to work with Raspberry Pi to provide tools for students, teachers and makers all over the world to expand their creative digital skills and discover hands-on learning experiences," said Andrew Sliwinski, head of product experience at Lego Education. 

To help users build their new hybrid creations, Lego has even released its first-ever component designed to connect to something that is not another piece of Lego. Called the Maker Plate, the piece lets makers stick their Raspberry Pi directly into their Lego construction. The Build Hat, for its part, was also designed to leave room at the top to sit a Lego Minifigure. Next-level Lego creations are on their way, therefore; if you aren't already, it's time to start designing. 

Editorial standards