Meet the Raspberry Pi Build HAT: create with Raspberry Pi and LEGO® Education

Today we have huge smiles on our faces as we announce the Raspberry Pi Build HAT, a brand-new product that for the first time makes it easy to integrate LEGO® Technic™ motors and sensors with Raspberry Pi computers. We’ve designed it to enable fun and creative learning experiences for young people, teachers, and makers.

Photo of a Raspberry Pi with a Raspberry Pi Build HAT fitted, mounted by its mounting holes to a large, flat, bright pink LEGO element lying on a desk. Cables connect three of the Build HAT ports to LEGO devices out of shot, and a few other LEGO components are connected to or adjacent to the construction. A Raspberry Pi camera module connector is connected to the Raspberry Pi through a slot in the Build HAT.

Raspberry Pi Build HAT

The Build HAT is part of an exciting new collaboration between Raspberry Pi and LEGO® Education to increase the impact and reach of STEAM learning.​ We’re really thrilled about the possibilities this new team-up will bring, as is the LEGO Education team. “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, LEGO Education.

Angled photo of a Raspberry Pi Build HAT: an approximately square green PCB with through holes for a 40-pin header, four LPF2 ports, a slot for a Raspberry Pi Camera Module connector, a barrel jack power connector, and a mounting hole in each corner. The Raspberry Pi logo and the words "Raspberry Pi Build HAT" are printed on the board.

Raspberry Pi meets LEGO® Education

The Build HAT (Hardware Attached on Top), priced at $25, is a new add-on board for your Raspberry Pi. It connects to the 40-pin GPIO header and can be used to control up to four LEGO® Technic™ motors and sensors from the LEGO® Education SPIKE™ Portfolio.

The new HAT works with all 40-pin GPIO Raspberry Pi boards, including Raspberry Pi 4 and Raspberry Pi Zero. With the addition of a ribbon cable or other extension device, you can also use it with Raspberry Pi 400.

The cool design of the Build HAT means that all the components are on the bottom, leaving room on the top of the board for LEGO Minifigures to hitch a ride, or for a mini breadboard. You can connect the HAT directly to your Raspberry Pi with the attached header, using 9mm spacers to ensure a stable fit, or you can add an extra-tall header to keep the unused GPIO pins accessible. Whichever method you choose, make sure you position the Build HAT the right way round when installing it on your Raspberry Pi!

Close-up photo of part of the Raspberry Pi Build HAT, showing the Raspberry Pi RP2040 microchip

Like Raspberry Pi Pico, the Raspberry Pi Build HAT uses the RP2040 chip developed right here at Raspberry Pi.

The power of LEGO® bricks with Raspberry Pi

The LEGO Technic motors are really powerful. And like most motors, to drive them you’ll need an external 7.5V power supply. Fortunately, the Build HAT isn’t the only new product we are launching today: we’ve also created a brand-new power supply for the Build HAT that’s reliable, rugged, and perfect for making the most of those motors. It’s priced at $15.

Photo: a white Raspberry Pi Build HAT Power Supply is plugged into a standard UK electrical power socket. The power supply is connected to a Raspberry Pi Build HAT mounted on a Raspberry Pi, itself mounted on a large, flat, bright pink LEGO element.

If you just want to read from motor encoders and the SPIKE force sensor, you can power your Raspberry Pi and Build HAT the usual way, via your Raspberry Pi’s USB power socket. The SPIKE colour and distance sensors, like the motors, require an external power supply.

LEGO® Education SPIKE™ Prime

The LEGO Technic devices included in the SPIKE Portfolio are perfect for rapidly prototyping your next robotics or physical computing project. The available sensors include a distance sensor, a colour sensor, and an incredibly versatile force sensor. The angular motors, which come in a range of sizes, include integrated encoders you can query in order to find their position. That means you can precisely control your creation’s movement, or use the encoders as input devices in their own right.

Photo: an ensemble of LEGO SPIKE Prime motors and sensors and a Raspberry Pi Build HAT, along with some LEGO bricks and an attractive indoor plant

You can get LEGO Technic devices as individual items, or together with a collection of really useful stuff in the SPIKE Prime and SPIKE Prime Expansion sets. The latter includes an exclusive LEGO element, the first-ever designed to connect to something that isn’t another piece of LEGO: the Maker Plate. The Maker Plate is designed to make it super easy to add a Raspberry Pi to your LEGO construction. But don’t worry, there are plenty of other creative ways to mount your Raspberry Pi if you don’t have a Maker Plate.

Top-down photo of a Raspberry Pi mounted on a large, flat, bright pink LEGO element which we now know is the LEGO Maker Plate. A varied selection of other LEGO elements, along with a Build HAT, are scattered around it.

We’ve compiled a list of all the compatible LEGO elements you can use with the Build HAT, so you can check what will work best for your project.

New Build HAT Python library

To make it really easy to build prototypes that combine Raspberry Pi’s computing power with your LEGO brick collection, we’ve created a Python library for the Build HAT that should feel familiar to anyone who has used other Raspberry Pi libraries like gpiozero or the one for the Sense HAT.

The Build HAT library already supports all the LEGO Technic devices included in the SPIKE Portfolio, along with those from the LEGO® MINDSTORMS® Robot Inventor kit and other devices that use an LPF2 connector.

Brand-new Build HAT projects

There are loads of amazing educational projects available using SPIKE Prime. Adding Raspberry Pi and a Build HAT into the mix gives learners more options for creativity and flexibility in their projects, ​enabling them to go even further and take their making adventure to the next level: now they can have a programmable, networked computer with access to online data sources at the heart of their build, plus they can easily add more electronic components via Raspberry Pi’s GPIO pins.

A robot face built using LEGO Education SPIKE Prime elements. It is a large, flat, square face with eyes, eyebrows, a nose, and a mouth. A Raspberry Pi Camera Module is visible mounted just above the face, and a Raspberry Pi and Raspberry Pi Build HAT are placed either side of it.

To support learners to get started using the Build HAT and programming their LEGO Education builds, we’ve got five brand-new online Build HAT project guides that will help them gain confidence as makers. You’ll find the projects fun, accessible, and engaging! Follow them to make your own DIY game controller and get hands-on with some retro-gaming action, or to create a robot buggy that you steer with your phone via Bluetooth.

A robot buggy built using SPIKE Prime elements, with a Raspberry Pi, Build HAT, and jumper cables visible at the top of the build. It sits on a desk beside a Raspberry Pi, scattered LEDs and jumper leads, a mobile phone, a mug, a Build HAT, and a plant.

Then explore the topics of computer vision and machine learning by building an expressive robot face, and look at new ways of representing local and online data by creating a plotter or data dashboard.

We’re already working on more Build HAT project guides for learners. In the meantime, we’d love to see what you will make with your Raspberry Pi computer, Build HAT, and your much loved collection of LEGO bricks. Share your favourite creation using the hashtag #BuildHAT.

Credits and thank yous

It’s fair to say that creating the Build HAT and everything that supports it has been a massive project over the last couple of years. Here’s a necessarily incomplete list of people we want to thank for contributing to the Build HAT and the Raspberry Pi Build HAT projects:

Lauren Hancock, Anthony Morton, Mark Owen, Dominic Plunkett, Simon West, Carrie Anne Philbin, George Boukeas, James Robinson, Marc Scott, Mark Calleja, Greg Annandale, Chris Richardson, Martin O’Hanlon, Rik Cross, Faye Magellan, Sam Alder, Helen Lynn, Jack Willis, Brian O Halloran, Jan Ander, Olympia Brown, Sarah Millar, Rhodri James, Gawain Edwards

Plus our friends at LEGO Education: Marianne Nytoft Bach, Jane Damgaard, Jesper Elling, Eva Guldmann, Arthur Sacek, Peter Thesbjerg, Ralph Hempel, Tobias Thyrrestrup, Zoe Bergeal, Gitte Grønborg, Andrew Sliwinski

36 comments
Jump to the comment form

Avatar

Do BOOST/PoweredUP motors/sensors work with BuildHAT ?

Reply to przem

Avatar

We’ve got a list of everything that works with the Build Hat in the documentation.

Reply to Liz Upton

Avatar

We are just fixing that – there was a .com/.org flub caused by an inelegant use of search and replace which introduced a hyphen. (Alasdair noticed independently about the same time you did!) So the urls you pasted above aren’t the correct ones any more and have been replaced: if you’re going in via the documentation everything will work now.

TL;DR: last-minute hyphen crisis.

Reply to Liz Upton

Alasdair Allan

Total last minute hyphen crisis. Now fixed. Mea culpa!

Avatar

Oh – and I should mention, you can run PoweredUP motors/sensors direct from the Raspberry Pi using Bluetooth.

Reply to Liz Upton

Avatar

YES! THANK YOU!

Reply to Anton

Avatar

Are those HATs stackable, i.e. can I use more than one on a RPi?
Will the communication protocol between the RPi and the RP2040 running the HAT be documented and published?

Reply to Christian Treczoks

Alasdair Allan

The communication protocol between the HAT and the Raspberry Pi is fully documented, https://datasheets.raspberrypi.com/build-hat/build-hat-serial-protocol.pdf. Linked from the main Build HAT documentation which lives at, https://www.raspberrypi.com/documentation/accessories/build-hat.html.

Reply to Alasdair Allan

Avatar

OK, I just ordered a bunch of ESP8266 modules and will see to establish a wifi-to-BuildHAT bridge for my project.

Reply to Christian Treczoks

Avatar

A great idea. It’s just a shame it’s out of stock everywhere. I guess the sold out as soon as they went on sale, as is often the case with Raspberry Pi products.
It looks really good. I can’t wait to get hold of one and have a go!

Reply to Stewart watkiss

Avatar

Hi Stewart! If you can make it to the Raspberry Pi store in Cambridge, we have some in stock there. Many of our Authorised Resellers have set up pre-order processes or will notify you when stock comes in, too. (Say hi to the kids for me!)

Reply to Liz Upton

Avatar

Thanks – as much as I’d love to come to Cambridge (it’s a lovely city) it’s a bit far to go to buy a HAT. I’ve registered to get notified when they are in stock.

[The kids are getting quite grown up now – I’ll pass on your greating].

Reply to Stewart Watkiss

Avatar

When will Raspberry Pi 5 coming

Reply to Pavan Mani

Avatar

Unfortunately not for the “old” Power Functions motors in my Lego box and the many, many out there.

Reply to Smartifahrer

Avatar

I still have Lego Mindstorm EV3 that I’m about to sell. Is that what you mean by “old”? Or do you mean the previous version?

Reply to Harry Hardjono

Avatar

If you have EV3 and NXT, you can look at the BrickPi. It’s been around for years and offers more ports.

Reply to CleoQc

Avatar

I have Brick Pi from years ago. Unfortunately, I was never able to get it going. 🙁

Reply to Harry Hardjono

Avatar

Where we can buy “the Maker Plate” for mouting Lego, I dont want to use 3D print part

Reply to thinh

Avatar

The Maker Plate only comes as part of the Spike Kit from LEGO Education, so a 3D printed version might be your best bet. (This is all in the documentation – it’s worth having a quick skim of it!)

Reply to Liz Upton

Alasdair Allan

The product code for the SPIKE Prime Expansion Set that included the Maker Plate is 45681.

Reply to Alasdair Allan

Avatar

This is awesome. If rpi4’s come in stock anytime soon, I think I might grab this and play around. When I was in college (many moons ago) I took a robotics class where we built robots using legos and the MIT handyboard. It was so cool. I remember at the time looking into getting my own, and it was over $200 way too much for a student. I don’t think they make those anymore, and why would they. The pi’s are just so much better all around. Keep up the good work!

Reply to Josh Kelahan

Avatar

Hello,
Is there also a Schematic Diagramm of the Build-HAT available ?

Jo

Reply to Jo

Alasdair Allan

Unfortunately no, there isn’t a schematic available. The HAT talks to the Raspberry Pi using a serial connection and only makes use of GPIO 0/1, 4, 14, 15, 16 and 17. The rest of the 40-pin header can be passed through if desired. More details in the getting started documentation, https://www.raspberrypi.com/documentation/accessories/build-hat.html.

Reply to Alasdair Allan

Avatar

What H-Bridge Drivers are used ?
Is operation with 9V possible ?

Reply to Jo

Avatar

The H-Bridge drivers are from Dialog Semiconductor; I don’t have the actual part numbers to hand. I’m pretty sure 9v is outside the operating spec for the LEGO motors; you’d need to check with them.

Reply to Liz Upton

Avatar

Not having the HAT schematics is a serious drawback for me. Will they be made available at some point in the future?

I’m also wondering about the Build HAT PSU – it supplies 8V, while the normal voltage of the LEGO System motors (like the Power Function ones) is 9V. Having tried to source a sufficiently powerful 9V PSU in the past, I even run the motors from 10V (stock 12V PSU tuned down to 10V) without any issues.

That’s one of the reasons why I’d like to see the schematics to see how it deals with power.

And it would be interesting to the the limits and requirements in general, i.e. how high and how low can Vin get without causing issues, how many mA it can supply on the 5V rail, and how many Watts the board uses on it’s own.

Lets say I want to use the hat to power an ESP8266 (instead of an RPi) with some other peripherals, and run one PoweredUp! train motor from the hat, I’d like to be able to get a realistic power calculation for this special case. And for that, detailed specs and a schematic would be really helpful.

Reply to Christian Treczoks

Avatar

Surely it’s a matter of time until someone designs a Rapberry Pi-powered AI bot which auto-buys up the stock of newly-released Raspberry Pi products, before they get vaccumed up like has just occurred today. Just saying. ;)

Reply to Esbeeb

Avatar

This is wonderful, but I it brings on a strong feeling of deja-vu.
Back in 1990 I, and many others, were doing something that looked very similar.
The set-up then was a classroom of BBC Bs, with mfa (Microelectronics For All) Computer boards with Motor and Sensor boards, LEGO buggies and home-made sensors on LEGO bricks attached with ribbon cables.
There was no Python and my programming choice was Logo.
By the late 90s nearly all this was displaced by the push for ‘ICT’ and only a few schools could continue with the later LEGO materials, which became a little too slick for my taste. ;-)
I am very pleased to to see this, and it is considerably cheaper and neater than back then.

Reply to Steve Drain

Avatar

Cool collaboration!
Would love to see more of these collaborations in the future!

Reply to Henry David

Avatar

Hi. Is there a pre built os for using the spike prime or for home use new lego mindstorms mobile apps to code with the build hat, as in having the Pi just act as a regular spike prime? Otherwise what are my other options?

Reply to Mrman

Avatar

Just my personal wish: a Raspberry Pi Zero with 8 (or even better 10) LPF2 ports, a USB port (for ssh connection) and a 9V power supply socket – all on one board – nothing else – no GPIO pins – no HDMI socket – no further gimmicks.

Would be nice to have and for sure an excellent alternative to Lego’s Spike Prime Large Hub.

Reply to Murphy

Avatar

Hello All, I’m very happy to see new product working with Lego ecosystem, but I could not find the interest of the Hat board comparing to the existing Spike Prime mother board? Could I drive the Power Function Lego motors with the Hat board? Could we use the block based programming language like the Spike Prime SW or only Python is supported? Thanks. Julien

Reply to Nguyen Julien

Avatar

this is really cool.
are there plans to make a version of this that would control many more devices (say by stacking 4 ports modules ?)

Reply to Raphaël Jacquot

Avatar

I’m so excited when I saw this news, but then kinder disappointed because Micro Center is not in the resellers list.

Reply to Raspberry Pi Girls

Avatar

So many old NXT / EV£ motors out there it is a shame a simple hat like this doesn’t exist to extend their useful life. Sure there is BrickPi but they are not only expensive but also not kid friendly.

Reply to Mike B

Leave a Comment