|
arduino IDEArduino
|
Smartphone Controlled Model Railroad With an ESP8266
Intro
A while back, I made a project where a stepper motor's position is controlled using a smartphone with the help of an ESP8266 microcontroller. After doing that project, I thought why not try controlling a model railway layout with the same concept, so here we are with this project.
Today, let's learn how to control a model railroad layout using a smartphone through Wi-Fi with the help of an ESP8266 microcontroller.
Let's get started!
Supplies
For this project, you will need:
- An ESP8266 microcontroller(With least 4 digital outputs, including 2 PWM outputs)
- A dual-channel motor driver(One channel for track power, other for turnout)
- A breadboard
- Male to male jumper wires
- A 5-volt output voltage regulator(Example: L7805CV)
- A small heatsink(Screwing a small piece of aluminium to the voltage regulator can also work)
- *A DC power source
*The voltage of the power source depends on the operating voltage of the locomotive and the turnout, make sure the voltage regulator and the motor driver are rated for the supply voltage.
Step 1: Program the Microcontroller
You can get the Arduino code folder from here.
Extract the contents of the zip folder and copy the folder named "ESP8266_Model_Railroad_Layout_Control" to the sketch folder of the Arduino IDE. Generally, it is in the Documents folder of the computer.
Before uploading, make sure to put in the name(SSID) and password of the Wi-Fo router to which you intend to connect the ESP.
Step 2: Check the Web Controller
After uploading, open the serial monitor and make sure the baud rate is set to 115200. The blue LED on the ESP will blink until it is connected to the router, after that, it will display an IP address on the serial monitor. Note or copy it and enter it in the address bar of the web browser of a device that is connected to the same Wi-Fi router. You should see a page as in the second pic.
On sliding the slider or tapping on the buttons, you should see the ESP displaying some text on the serial monitor.
Step 3: Set Up the Layout
Step 4: Put the Microcontroller and Motor Driver on the Breadboard
You can also use a PCB with soldered female headers to make a more permanent setup but a breadboard is good for testing the setup for the first time and setting it all up quickly.
Step 5: Connect the Motor Driver to the Microcontroller
Connect the +ve input pin of the motor driver(Usually marked 'VIN', 'VMOT', etc.) to the +12-volt supply and connect its GND pin to the -ve of the supply.
Make the following connections from the microcontroller to the motor driver:
D5 - > IN1
D6 - > IN2
D7 - > IN3
D8 - > IN4
A lot of motor drivers, like the one which I use, require an enable pin to be connected to the +ve of the logic voltage, so connect it to the 3.3-volt pin of the microcontroller.
Step 6: Connect Track Feeder and Turnout to the Setup
Connect the track power feeder's wires to the pins of the motor driver marked OUT1 and OUT2 as they correspond to the pins IN1 and IN2.
Connect the turnout's wires to the pins of the motor driver marked OUT3 and OUT4 as they correspond to the pins IN3 and IN4.
Step 7: Connect the Voltage Regulator to the Setup
Mount a small heatsink to the regulator to keep its temperature in a safe range.
Connect the regulator's left pin to the +12-volt supply, its middle pin to the GND of the circuit, and its right pin to the VIN pin of the ESP board.
Step 8: Connect the Setup to Power
You can use a barrel-type connecter to connect the setup to a 12-volt DC adapter easily.
Step 9: Place the Locomotive on the Tracks
Make sure the locomotive is sitting properly on the tracks to prevent derailments and short-circuit of track power.
Step 10: Power Up the Setup and Open the Controller Page
After powering up the setup, the LED on the ESP board should blink until it gets connected to the Wi-Fi router. After that open the control page on the browser of the device from which you want to control the layout by entering the IP address you noted from Step3. Make sure that the device is connected to the same Wi-Fi router.
Step 11: Test the Controls
Check if your controls are working as shown in the video.
If the locomotive is moving in the wrong direction, just reverse the polarity of track power by swapping the track feeder wires with each other. You can do the same with the turnout wires if you want to switch it in the opposite direction.
Step 12: Add More to the Project
The example provides here can only control a single locomotive and a turnout and I am sure that it is not enough for a regular model railroad layout. So why don't you try to add another turnout or maybe a locomotive control?
It might be but difficult to understand the code and modify it, but when you start to understand it, you can do a lot of things to improve this project and suit it to your liking.
Whatever you do, try to share your creation with the community to inspire more people to try this project.
All the best!
Smartphone Controlled Model Railroad With an ESP8266
- Comments(0)
- Likes(2)
- Engineer Oct 29,2023
- Daan Uttien Jun 16,2023
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by KushagraK7
- Raspberry Pi Pico RC Vehicle SuppliesA Raspberry Pi Pico(Almost any microcontroller can be used here, but the Pico offers great f...
- Stepper Motor Controlled Stepper Motor Without Microcontroller! Step 1: Watch the VideoWatch the video to get a full understanding of the project and learn how to t...
- Automated Model Railroad Layout Running Two Trains I made an Automated Model Train Layout with Passing Siding a while back. Upon request from a fellow ...
- Program the Raspberry Pi Pico With the Arduino IDE The Raspberry Pi Pico is a recently launched product in the family of microcontrollers and its load ...
- Reuse an Old Laptop's Touchpad to Control a Computer! PS/2 laptop touchpads are among the coolest user interface devices to use with a microcontroller. Th...
- Automated Model Railroad Layout With Reverse Loops In one of my previous projects, I showed how to make a Simple Automated Point to Point Model Railroa...
- Use a Stepper Motor As a Rotary Encoder Rotary encoders are great for use in microcontroller projects as an input device but their performan...
- Keyboard Controlled Model Train(PS/2 Interface) Using Arduino microcontrollers, there are a lot of ways of controlling model railway layouts. A keyb...
- Stepper Motor Speed and Direction Control Without a Microcontroller In one of my previous projects, I showed you how to control a stepper motor's speed using a 555 time...
- Smartphone Controlled 4X4 Robot With ESP8266 SuppliesFor this project, you will need:An ESP8266 microcontroller(Node MCU)A dual H-bridge motor dr...
- Touchpad Controlled Digital Servo Motor Here is a quick and simple project where we control a digital servo motor with the slide of our fing...
- Smartphone Controlled Model Railroad With an ESP8266 IntroA while back, I made a project where a stepper motor's position is controlled using a smartphon...
- Simple USB Volume Controller with Arduino This project uses a rotary encoder connected to an Arduino Leonardo to control the audio volume of a...
- Motor Speed and Direction Control with a Web-Server using an ESP01 Supplies:For this project, you will need:An ESP01 microcontroller(You can use any ESP8266-based micr...
- Wi-Fi Controlled Stepper Motor With an ESP Microcontroller Step 1: Get All the Required StuffFor this project, you will need:An ESP8266 microcontrollerA Steppe...
- Simple Automated Model Railroad Loop With Yard Siding Video:Supplies: For this project, you will require:An Arduino microcontroller board compatible with ...
- Laptop Touchpad Controlled Model Railroad Supplies:For this project, you will require:An Arduino microcontroller compatible with Adafruit Moto...
- Control a Stepper Motor with a Slide of Your Finger Supplies:An Arduino microcontroller boardA PS/2 touchpad from a laptop(Try to get one with a Synapti...
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
37 0 0 -
-
-
-
Sega Master System RGB Encoder Switcher Z80 QSB v1.2
45 0 0 -
18650 2S2P Battery Charger, Protection and 5V Output Board
55 0 0 -
High Precision Thermal Imager + Infrared Thermometer | OpenTemp
352 0 5 -
Sony PlayStation Multi Output Frequency Oscillator (MOFO) v1
114 0 2 -
-
XRC PRO: Open-Source RC Transmitter and Receiver System
149 0 2