The motorized LEGO train takes charge of Qi on the track
This project started, as many do, with a simple idea. [Ben Hoad] i 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 would have to do was figure out how to shoehorn an engine in there and be done with it. Right?
Well you already know how it goes. It started with adding the motor, which ended up being relatively straightforward once [Ben] used LEGO CAD community tools to determine which kits contained the specific parts he needed to redesign the train so that it had enough space inside for the motor without ruining its appearance. But then the function creep kicked in, and he found himself falling into that familiar rabbit hole.
The first problem was how to reliably power the train. It turns out that the rear car was already more or less empty, so it became the home for two 18650 batteries.
(project details say “16850” but we believe this is just a typo). [Ben] didn’t want to have to take the thing apart every time it broke, 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 made the current flow, but aligning them turned out to be a bit finicky. So he added a Hall sensor to the car and a strong magnet to the track, so the train would know when the coils were aligned and would automatically pump the brakes.
So now he had a motorized train that could recharge, but how do you turn it on and off? Well with an ESP8266 for the ride he figured it would be easy to add WiFi control. With a little code and the Homebridge project, he was able to make the train appear as a smart switch to Apple’s HomeKit. This allows him to start and stop the train from his smartphone, with a routine that brings the train back to the charging station once it’s done doing the tour. [Ben] says the next steps are to put in place mental health checks, such as shutting down engines if the train has not passed the charging station in a few minutes; a sure sign that he’s not really moving.
All [Ben] must now implement automatic decoupling of LEGO trains before the plastic students at Hogwarts return from spring break.