Raspberry Pi LEGO sorter

Raspberry Pi is at the heart of this AI–powered, automated sorting machine that is capable of recognising and sorting any LEGO brick.

And its maker Daniel West believes it to be the first of its kind in the world!

Best ever

This mega-machine was two years in the making and is a LEGO creation itself, built from over 10,000 LEGO bricks.

A beast of 10,000 bricks

It can sort any LEGO brick you place in its input bucket into one of 18 output buckets, at the rate of one brick every two seconds.

While Daniel was inspired by previous LEGO sorters, his creation is a huge step up from them: it can recognise absolutely every LEGO brick ever created, even bricks it has never seen before. Hence the ‘universal’ in the name ‘universal LEGO sorting machine’.

Hardware

There we are, tucked away, just doing our job

Software

The artificial intelligence algorithm behind the LEGO sorting is a convolutional neural network, the go-to for image classification.

What makes Daniel’s project a ‘world first’ is that he trained his classifier using 3D model images of LEGO bricks, which is how the machine can classify absolutely any LEGO brick it’s faced with, even if it has never seen it in real life before.

We LOVE a thorough project video, and we love TWO of them even more

Daniel has made a whole extra video (above) explaining how the AI in this project works. He shouts out all the open source software he used to run the Raspberry Pi Camera Module and access 3D training images etc. at this point in the video.

LEGO brick separation

The vibration plate in action, feeding single parts into the scanner

Daniel needed the input bucket to carefully pick out a single LEGO brick from the mass he chucks in at once.

This is achieved with a primary and secondary belt slowly pushing parts onto a vibration plate. The vibration plate uses a super fast LEGO motor to shake the bricks around so they aren’t sitting on top of each other when they reach the scanner.

Scanning and sorting

A side view of the LEFO sorting machine showing a large white chute built from LEGO bricks
The underside of the beast

A Raspberry Pi Camera Module captures video of each brick, which Raspberry Pi 3 Model B+ then processes and wirelessly sends to a more powerful computer able to run the neural network that classifies the parts.

The classification decision is then sent back to the sorting machine so it can spit the brick, using a series of servo-controlled gates, into the right output bucket.

Extra-credit homework

A front view of the LEGO sorter with the sorting boxes visible underneath
In all its bricky beauty, with the 18 output buckets visible at the bottom

Daniel is such a boss maker that he wrote not one, but two further reading articles for those of you who want to deep-dive into this mega LEGO creation:

15 comments
Jump to the comment form

Avatar

This is SO IMPRESSIVE. It looks like a lifetime project, but the maker isn’t that old yet and has finished it already!

Reply to Niels

Avatar

I wonder if I can borrow this machine for a few days. ?

Reply to Stefan Misch

Avatar

Can I borrow it after you do?

Reply to Timothy J

Avatar

I NEED THIS NOW!!!!!
This is just amazing. Cool project.

Reply to Langerosso

Avatar

Jacques Mattheij built something like this four years ago:

https://jacquesmattheij.com/sorting-two-metric-tons-of-lego/

Reply to Justin Simms

Avatar

Which is also mentioned a few seconds into the video.

Reply to P

Avatar

Impressive!

I wonder if would be possible to create a “LEGO sorter Zero”, to classify images without human supervision, just watching different images of the bricks.

Reply to foo

Avatar

What about a machine to get the pieces of a desired set from the available stock? :)

Reply to Baraka

Avatar

Such wonderful engineering.

Reply to James Carroll

Avatar

Great project! Any idea what the chances are of it making a mistake?

Reply to Will

Avatar

Would really like to see this go to market… Even if it isn’t made of Lego to keep the cost down.

Reply to Timothy J

Avatar

Awesome! I also use LEGO with my Arduino but RPi is more advanced!

Reply to Strony WWW Kłodzko

Avatar

You area genius. The Lego company should create your machine as a Lego model and pay you a gazillion dollars! I am going to watch for your beast model.

Reply to Sam Muncy

Avatar

Daniel West, take a bow. This is such a great idea and is beautifully made! Genius.

Reply to Harry

Avatar

Does this work with raspberry pi 0 w? I really want this but I don’t have that lego/money/more money – it’s absolute genius!

Reply to Max

Replying to Harry
Cancel reply?