Motorized LEGO Train Gets Qi Charging in the Track

This project started, as many do, with a simple idea. [Ben Hoad] just wanted to take a static LEGO Hogwarts Express train kit and make it motorized. It was compatible with standard LEGO track pieces, so all he should have to do was figure out how to shoehorn a motor in there and be done with it. Right?

Well, you already know how things like this go. It started with adding the motor, which ended up being relatively straightforward once [Ben] used some community LEGO CAD tools to figure out which kits had the specific parts he needed to redesign the train in such a way that he’d have enough space inside for the motor without ruining the way it looked. But then the feature creep kicked in, and he found himself falling down that familiar rabbit hole.

A 3D representation of the train’s internal components.

The first problem was how to reliably power the train. It turns out the rear car was more or less empty already, so that became home for two 18650 batteries (the project details say “16850” but we believe that is merely a typo). [Ben] didn’t want to have to take the thing apart every time it ran down, so he wondered if it would be possible to add wireless charging.

A Qi coil in the bottom of the train car and one in a specially designed section of track got the power flowing, but getting them lined up proved a bit finicky. So he added a Hall effect sensor to the car and a strong magnet to the track, so the train would know when the coils were lined up and automatically pump the brakes.

So now he had a motorized train that could recharge itself, but how should he turn it on and off? Well, with an ESP8266 along for the ride, he figured it would be easy to add WiFi control. With a bit of code and the Homebridge project, he was able to get the train to appear as a smart switch to Apple’s HomeKit. That allows him to start and stop the train from his smartphone, complete with a routine that returns the train to the charging station once it’s finished making the rounds. [Ben] says the next steps are to put some sanity checks in, such as shutting the motors down if the train hasn’t passed the charging station in a few minutes; a sure sign that it’s not actually moving.

All [Ben] needs to do now is implement automatic LEGO train decoupling before the plastic Hogwarts students come back from spring break.