Lorraine hacks a Bluetooth-controlled LEGO train in this week’s episode of element14 Presents, mounting a track system to the ceiling of her home. She integrates CircuitPython, a Seeed XIAO board, NeoPixels, and a spinning LIDAR sensor to detect walls and control the train’s movement. Lorraine's project covers setup, track planning, component integration, and a ground-level test before moving the build to its final ceiling-mounted location. Watch to see how it performs!
Watch the Video
What happens when a Bluetooth-controlled LEGO train meets a maker's imagination and a ceiling with just enough clearance? In this episode of element14 Presents, Lorraine takes on the challenge of modifying a standard LEGO train to follow custom commands, detect obstacles, and operate on an overhead track. The result is a creative blend of electronics, coding, and home decor, designed to move a train through the airspace of a living room using smart control.
Design Intentions
The project began with a clear goal: to control the LEGO train programmatically and free it from its default Bluetooth remote. Rather than having the train occupy floor or shelf space, Lorraine designed a track layout to mount along two walls at ceiling level. The vision was to have the train run at set intervals, detect walls, and respond to its environment—all without manual input. This required integrating control logic, sensing capabilities, and a power-conscious hardware setup, all embedded within the constraints of a moving LEGO train.
Component Choices
The core controller is the Seeed Studio XIAO nRF52840 Sense board—compact, Bluetooth-enabled, and compatible with CircuitPython. It was small enough to fit inside a LEGO train carriage while providing the computing power needed for real-time control. A NeoPixel RGB LED strip was used to light up the train's windows with programmable color effects. For obstacle detection, a rotating LIDAR sensor was mounted on top of the train. Although a simpler ultrasonic setup could have sufficed, the LIDAR offered wider coverage and visual appeal. A separate battery setup powered the XIAO, with an optional servo mechanism considered for toggling the train’s power supply to conserve energy.
Challenges and Code
One of the primary challenges was managing power consumption. The LIDAR sensor in particular drew significant power, raising concerns about the available battery life. While a servo was considered for turning off the train’s main battery to conserve energy, it would also consume power and possibly reduce overall efficiency. The code was developed in CircuitPython using libraries for NeoPixel control and serial communication. Existing Python code examples were adapted to work with CircuitPython, removing unnecessary features like data plotting and focusing on extracting distance values to detect when the train should stop.
Results!
Initial testing was carried out on a dining room table with curved LEGO track sections to simulate ceiling conditions. The train ran successfully, with LEDs illuminating the interior and the LIDAR detecting nearby walls and stopping the train appropriately. Some adjustments are still needed for cornering behavior and battery optimization, but the system is functional and ready for final installation on the ceiling. This project demonstrates how off-the-shelf LEGO hardware can be enhanced using microcontrollers and sensors to create a smart, interactive home feature.
Supporting Downloads and Links
Bill of Materials
Product Name | Manufacturer | Quantity | Buy Kit |
---|---|---|---|
SEEED STUDIO SBC, XIAO nRF52840 Sense, ARM Cortex-M4, 256kB RAM, 2MB Flash, Bluetooth, USB-C | SEEED STUDIO | 1 | Buy Now |
DFROBOT Servo Motor, Micro, 6 V, 0.17 N-m | DFROBOT | 1 | Buy Now |
DFROBOT LED Strip, Digital, RGB, Weatherproof, 60 LED, 1m, BBC Micro:bit Boards | DFROBOT | 1 | Buy Now |
Lego train | |||
Lego track | |||
Wood | |||
LiDAR LD06 Module (Farnell stock a similar model from DFROBOT ) |
Top Comments