A remote-controlled G-scale locomotive system powered by NodeMCU ESP8266 microcontrollers. This project enables wireless control of model trains through a custom-built remote controller with rotary encoder input.
This system consists of two main components:
- TMF2-2 G-Scale Locomotive: A 3D-printed train with integrated motor control and WiFi connectivity
- Remote Controller: A handheld device with rotary encoder for speed control and direction switching
- Wireless Control: WiFi-based communication between remote and locomotive
- Variable Speed Control: Smooth PWM-based speed regulation (-100 to +100)
- Direction Control: Forward/reverse operation with LED indicators
- Web Interface: Browser-based control panel for additional functionality
- Real-time Feedback: System status and diagnostics display
- LED Status Indicators: Visual feedback for WiFi connection and direction
- NodeMCU ESP8266 microcontroller
- L9110S H-bridge motor driver
- 2x DC motors
- White and red LEDs
- Battery holder
- 3D-printed locomotive body
- NodeMCU ESP8266 microcontroller
- Rotary encoder (with push button)
- WiFi status LED
- Direction indicator LEDs
- 3D-printed controller housing
- Main Body: TMF2-2 RhB Scale G Locomotive
- Controller Housing: Remote Control for G-Scale Locomotive
- Curves: G-Scale Train Tracks
- Straight Tracks: Straight G-Scale Train Tracks
- Left Switch: Left Switch Track Scale G
- Right Switch: Right Switch Track Scale G
NodeMCU -> L9110S Motor Driver
D1 -> Motor1A (Motor 1 Input A)
D2 -> Motor1B (Motor 1 Input B)
D4 -> Motor2A (Motor 2 Input A)
D3 -> Motor2B (Motor 2 Input B)
NodeMCU -> LEDs
D5 -> White LED (Forward indicator)
D6 -> Red LED (Reverse indicator)
NodeMCU -> Rotary Encoder
D6 -> CLK (Clock)
D5 -> DT (Data)
D7 -> SW (Switch/Button)
NodeMCU -> LEDs
D0 -> WiFi Status LED
D1 -> Forward Direction LED
D2 -> Reverse Direction LED
- Flash NodeMCU firmware to both ESP8266 boards
- Follow: How to Flash NodeMCU Firmware
- Install Arduino IDE and ESP8266 board support
- Guide: NodeMCU ESP8266 Setup Guide
- Locomotive: Upload
train_system/train_system.inoto the locomotive's NodeMCU - Remote Controller: Upload
Train_controller/Train_controller.inoto the remote's NodeMCU
- Install motors in the base plate as shown in build photos
- Connect L9110S motor driver according to wiring diagram
- Wire LEDs for direction indication
- Install battery holder underneath the locomotive
- Mount NodeMCU in designated compartment
- Install on/off switch in cockpit area
- Assemble remaining 3D-printed parts
- Print all remote controller parts
- Install rotary encoder in housing
- Connect LEDs for status indication
- Wire according to provided diagram
- Assemble housing components
- SSID:
TrainAP - Password:
12345678 - Web Interface: http://192.168.4.1
- Rotate Encoder: Adjust speed (-100 to +100)
- Press Button: Toggle direction (Forward/Reverse)
- WiFi LED: Indicates connection status
- Direction LEDs: Show current movement direction
- Speed control slider
- PWM input field
- System diagnostics (MAC, IP, RSSI, CPU frequency, memory usage)
The web interface displays real-time system information:
- MAC Address
- Local IP Address
- WiFi Signal Strength (RSSI)
- CPU Frequency
- Flash Memory Size
- Free Heap Memory
- Flash Chip ID
- Control Range: Variable speed from -100 to +100
- Communication: WiFi (ESP8266 Access Point)
- Motor Control: PWM-based L9110S H-bridge
- Power: Battery-operated (voltage depends on motor requirements)
- Scale: G-Scale (1:22.5)
Train_Control_System/
├── train_system/
│ └── train_system.ino # Locomotive control code
├── Train_controller/
│ └── Train_controller.ino # Remote controller code
└── README.md # This documentation
Feel free to contribute improvements, bug fixes, or additional features. Please ensure all changes are well-documented and tested.
This project is open-source. Please check individual component licenses for 3D models and external libraries.
Note: Ensure proper safety precautions when working with electronics and power supplies. Always disconnect power when making wiring changes.