ESPHome Powers Festive Lego Train Set

A Christmas-themed LEGO train engine and coal car

While the basic concept of LEGO bricks might have changed little since the mid-20th century, some components such as motors and sensors are still affected by technological progress and end up obsolete and unsupported. [Travis] ran into this problem when he was building a festive train setup and realized he didn’t have the speed controller to match his train engine. Without that part, the engine would only run at full speed and derail as soon as it hit a curve. The official speed controller had been discontinued and was hard to find, so [Travis] had to resort to building his own.

The basic components needed were an H-bridge driver to operate the motor and an ESP8266 to generate PWM signals. In order to keep the bricky appearance of the train engine intact, [Travis] hollowed out a few cheap imitation LEGO bricks to house the electronics. He also cut out slots for JST connectors, which are far more convenient to work with than LEGO’s brick-style connectors.

Two imitation LEGO bricks with electronics insideThe ESP8266 runs ESPHome, which enables [Travis] to control the entire setup using Home Assistant. The train is programmed to run a few laps at the top of the hour and play choo-choo sounds from a mini MP3 player hidden in the coal car. That car also holds a standard AA battery holder to power the system, which makes it easy to swap the batteries without having to partially disassemble the train.

There are various ways to control LEGO creations using standard computer platforms: we’ve seen the ESP32 powering a LEGO tank, for instance. If you need a bit more computing power, there’s even an official LEGO Raspberry Pi HAT.

5 thoughts on “ESPHome Powers Festive Lego Train Set

      1. Na, not willing to FDM that myself. Having a open-source robotic platform that is block-compatible with Lego and eventually electrically compatible with some Lego sensors would be a must. The possibility to equip a whole classroom with affordable hardware would be just great.

  1. Having the same problem I bridged half of the battery slots so the train runs with 3 instead of 6 AAA batteries. This reduces the voltage from 9V to 4.5V which results in a descent speed without a controller.

  2. So cool!
    This year I got exactly the same LEGO train, original from OLX In Portugal, It was a expensive as hell. The double as it was the launch price.
    I was planning a similar control with and ESP32 and control it via the mobile by WiFi, similar to a project I have for H0 scale.
    Unfortunately due to my professional activity I had no time for such a project, so I got the original motor and power function Rick from eBay and a bunch of train tracks, plus an exte train in parts.
    I spread all the track around the living room and played with my daughter for hours with it. In order to do run the train around the Christmas tree and run around the living room without being a bi hazard to tripping on the tracks, I 3d printed one 90 degree crossing and some right and left switches as well some other parts.
    I was pretty happy with the results I’m planning to make a permanent setup in my attic and enjoy it with my daughter.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.