A Raspberry Pi HAT for the Lego Technic fan

Sneaking in programming under the guise of plastic bricks

There is good news for the intersection of Lego and Raspberry Pi fans today, as a new HAT (the delightfully named Hardware Attached on Top) will be unveiled for the diminutive computer to control Technic motors and sensors.

In the belly of the beast: Pi Build HAT next to your correspondent's Lego

In the belly of the beast: Pi Build HAT next to your correspondent's Lego (click to enlarge)

Using a Pi to process sensor readings and manage motors has been a thing since the inception of the computer, and users (including ourselves) have long made use of the General Purpose Input / Output (GPIO) pins that have been a feature of the hardware for all manner of projects.

However, not all users are entirely happy with breadboards and jumpers. Lego, familiar to many a builder thanks to lines such as its Mindstorms range, recently introduced the Education SPIKE Prime set, aimed at the classroom.

The set contains a wide variety of components, including motors and sensors, controllable via a rechargeable hub and tablet application. It is the latter elements that a Build HAT-equipped Pi can replace: simply plug those motor and sensor components into the Pi hardware instead.

Effectively, this is a HAT device that connects to Lego devices that use a LPF2 connector. An onboard RP2040 microcontroller takes care of the low-level control of the Technic devices while an external power supply is needed to provide power. At the top level, developers can make use of Python to query sensors and run motors.

Pi Build HAT in use

A Raspberry Pi Build HAT in use ... Click to enlarge

It's entertaining stuff, and we can imagine it coming in handy in a classroom setting – sensors include devices to check distance, report colour and force, while motors can both be queried with regard to their position (if supported) and spun as required. The Pi team reckon the kit will also find fans outside of the education sector.

It's also a stepping stone to bigger and more exciting things, in our opinion. After all, once a curious mind has created a bit of code to operate machinery in the real world via the rapid prototyping made possible by the kit, making the transition to more advanced applications is not such a major leap.

As for the Build HAT itself, there are only four LPF2 connectors (adding more was apparently tricky due to space constraints) as well as a power connector and a helpful slot for feeding through the ribbon from the Pi's camera (should one be fitted.) The Raspberry Pi team reckons it should work on all models of the computer that have a 40 pin GPIO header, although Pi-400 users will need an extension cable and won't be able to use the external power supply to power the Pi.

Give it a go

We tried it out with a Pi 4 Model B and found no significant issues – there was enough juice to keep the Pi running and the Python libraries are well documented with helpful examples.

Not so great was the fact that the HAT fouled the fan we'd fitted to our Pi 4 and, of course, the stock case would no longer fit. To be fair, this is pretty much par for the course when it comes to augmenting one's Pi, but worth keeping in mind. Then again, one could regard it as an opportunity to get creative with the plastic bricks.

Compared to the cost of the Lego involved – the complete SPIKE Prime set retails for a whopping £361.99 in the UK, and $339.95 in the US – to consumers so it might be worth picking and choosing the required components), the HAT is a relative snip at $25, although you will need a power supply capable of pumping out 7.5v into a 2.1mm centre-positive barrel jack. If you've not got one to hand, the Pi team expects the branded version to go for $15. Pre-orders start today, although resellers won't have it in stock until 25 October, meaning a few more days wait for end users.

If you've gone down the Technic route, with motors and sensors armed with LPF2 connectors, the Build HAT is a fun interface. We're still pondering how to make our definitely-not-official-plastic-brick NASA crawler move without sending the Saturn V and Umbilical Tower on top tumbling.

A headless Pi running things from within the heart of the beast and slowly spinning up motors a degree at a time does have a certain appeal. ®

Similar topics

Other stories you might like

  • Prisons transcribe private phone calls with inmates using speech-to-text AI

    Plus: A drug designed by machine learning algorithms to treat liver disease reaches human clinical trials and more

    In brief Prisons around the US are installing AI speech-to-text models to automatically transcribe conversations with inmates during their phone calls.

    A series of contracts and emails from eight different states revealed how Verus, an AI application developed by LEO Technologies and based on a speech-to-text system offered by Amazon, was used to eavesdrop on prisoners’ phone calls.

    In a sales pitch, LEO’s CEO James Sexton told officials working for a jail in Cook County, Illinois, that one of its customers in Calhoun County, Alabama, uses the software to protect prisons from getting sued, according to an investigation by the Thomson Reuters Foundation.

    Continue reading
  • Battlefield 2042: Please don't be the death knell of the franchise, please don't be the death knell of the franchise

    Another terrible launch, but DICE is already working on improvements

    The RPG Greetings, traveller, and welcome back to The Register Plays Games, our monthly gaming column. Since the last edition on New World, we hit level cap and the "endgame". Around this time, item duping exploits became rife and every attempt Amazon Games made to fix it just broke something else. The post-level 60 "watermark" system for gear drops is also infuriating and tedious, but not something we were able to address in the column. So bear these things in mind if you were ever tempted. On that note, it's time to look at another newly released shit show – Battlefield 2042.

    I wanted to love Battlefield 2042, I really did. After the bum note of the first-person shooter (FPS) franchise's return to Second World War theatres with Battlefield V (2018), I stupidly assumed the next entry from EA-owned Swedish developer DICE would be a return to form. I was wrong.

    The multiplayer military FPS market is dominated by two forces: Activision's Call of Duty (COD) series and EA's Battlefield. Fans of each franchise are loyal to the point of zealotry with little crossover between player bases. Here's where I stand: COD jumped the shark with Modern Warfare 2 in 2009. It's flip-flopped from WW2 to present-day combat and back again, tried sci-fi, and even the Battle Royale trend with the free-to-play Call of Duty: Warzone (2020), which has been thoroughly ruined by hackers and developer inaction.

    Continue reading
  • American diplomats' iPhones reportedly compromised by NSO Group intrusion software

    Reuters claims nine State Department employees outside the US had their devices hacked

    The Apple iPhones of at least nine US State Department officials were compromised by an unidentified entity using NSO Group's Pegasus spyware, according to a report published Friday by Reuters.

    NSO Group in an email to The Register said it has blocked an unnamed customers' access to its system upon receiving an inquiry about the incident but has yet to confirm whether its software was involved.

    "Once the inquiry was received, and before any investigation under our compliance policy, we have decided to immediately terminate relevant customers’ access to the system, due to the severity of the allegations," an NSO spokesperson told The Register in an email. "To this point, we haven’t received any information nor the phone numbers, nor any indication that NSO’s tools were used in this case."

    Continue reading

Biting the hand that feeds IT © 1998–2021