LEGO Orrery Real-time Driver MOD
A real-time motor driver mod kit for the LEGO 42179 Earth & Moon Orrery
Introduction
📝NOTE
Want to build your own? Click here to Sign-up for updates if you're interested in an Orrery Driver kit!
I recently got my hands on the Lego Orrery set, which despite being an educational interactive toy is an impressively accurate (it's not that accurate actually more on this on the following chapter) functional model that simulates the orbital movements of the Sun, Earth, and Moon.
It features a manual crank that runs a gear system that simulates three motions simultaneously: the Earth orbiting the Sun, the Moon orbiting the Earth, and the Earth rotating on its tilted axis. While turning the crank manually is a fun way to visualize the seasons, and the moon's phases. I hated seeing the model sit idle on my shelf after I was done playing with it. So I began to wonder: is this model precise enough to be driven by a motor for real-time celestial tracking? As it turns out, it absolutely is!
The mod I've made consists of a custom PCB that can be directly mounted to the back of a NEMA17 stepper motor an can be attached to the LEGO set replacing the manual crank by only removing 5 LEGO pieces. I'm using esp32 as the brains and a tmc2208 stepper motor driver to silently drive the motor, there's a knob which can be used to go back or forward in time to see upcoming lunar phases, and a button that resets the model to the current local time. When left idle the Orrery Driver runs the motor to match the real time with an impressive rotation of
As always this project is fully open-source and I'm also planning to offer it as a plug & play electronics kit on Tindie as I have some PCB's and components left over from the project. Let me know if you're interested in the comments!
📝EDIT: Note on Accuracy
As pointed out in the comments (Thanks Joseph!), the accuracy of the moon has an error of 8.6%. I designed a custom 3D printed gear replacement to bring that error down to 0.95%. You can find more info in the Accuracy section below. Also see Joseph's detailed breakdown for reference here -April 5th, 2026
Accuracy
As noted in the comments, altough the model represetns the orbits to a fairly good accuracy the synodic period has a 8.7% error. This effects the accuracy of the model overtime. At first I calibrated the motor step count to match this error but later came up with a better solution which includes replacing the Moon gear with a custom 3D printed one. The .stl file can be found in the project repo.
Fixing LEGO's mistake
The culprit in this case is the Moon gear. The default gear train for the lunar orbit is as follows:
In this equation, 3 represents the Earth rotation ratio (one turn of the crank rotates the Earth three times). This result very close to the lunar period which is 27.3 days. However this gear does not represent the lunar orbit (how long it takes the Moon to circle the Earth once) It should represent the synodic period (how long it takes the Moon to return to the same phase. eg. full moon to full moon) which should be ~29.5 days. A 8.5% error is significant enough to throw the moon phases off after just a few days. The best way to fix this was to design a custom gear. I replaced the 60-tooth moon gear with a 65-tooth version, which results in:
That is only a 0.95% off. Which is a significant improvement! However there are some trade-offs, increasing the teeth count of the gear without adjusting it's size makes the gear not smooth. But for real time tracking that's not a major issue and it'll run smoothly. Also FDM printers introduce some layer lines in between the teeth that is hard to sand down, printing this gear on a resin printer could definetly help with that.
Hardware
The hardware consists of a ESP32-c3 super mini for it's small scale factor, a center detent potentiometer, a tactile button, RTC module and a tmc2208 silentstick stepper driver, and a nema 17 motor.
Since the LEGO Orrery is already quite compact, there was no room to hide a protoboard. To keep the footprint as small as possible, I designed a custom PCB that mounts directly onto the motor.
PCB

I've used JST-EH connectors on the pcb to make assembly easier, a dedicated power supply of 5V 2A is needed as the motor is power hungry when it accelerates. All the components are through hole so you can easliy solder them on your own with a basic soldering iron. Just make sure you clean any flux residue after soldering as the contacts are really close and can cause a short if not careful.
Freeform Soldering
📝NOTE
I didn't use sketches/drawings for the freeform brass structure, I ended up with this just with trial&error. So in these instructions I'll tell you how I managed to solder the structure. But I can't provide dimensions, etc. since I also don't know them.
The 4 digit 7 segment display can be mounted directly with a regular JST cable connector, but I went for a freeform look just for the aesthetics. I've used 0.8mm brass wire and a small set of pliers to bend them into shape.
Firmware

Driving the motor
Now we get to the fun stuff! How do we drive the motor so that it can match real-time? Through testing, I discovered that one full rotation of the crank rotates the Earth three times on its axis. This 1:3 ratio is the key to calculating the exact speed our stepper motor needs to maintain. But before we do that we need to know how many steps the motor takes to complete a single revolution (
Where
In my case the motor has
Now going back to the initial calculation of the
Uploading the code
Download the code from the repository and upload it to your ESP32 board via USB using the Arduino IDE, if this is the first time you are uploading code to your ESP32-C3 you might have to put the board in to download mode by holding the boot and reset buttons at the same time and then releasing the reset button after a few seconds.
Calibration
The display will prompt you to calibrate the orrery when you first plug it in, use the knob to move the orrery in to the winter solstace position as shown in the LEGO manual:

Simply press the button after you align the orrery and the orrery will start moving into it's real-time position!
📝NOTE
You only have to calibrate the motor once when you plug it in first so it knows where the gears are, once set there's the RTC module alon with the EEPROM of the ESP32 is used to save the state of the motor to keep track of time in case of a power loss. So you only have to calibrate it once!
And with that the build is finished! This project was really fun to build, I hope you enjoyed it as much as I did!
The PCB
The PCB mounted on the motor
Fully assembled
Schematic
Breadboard Prototype
Brass wire with a JST connector