Wi-Fi Controlled Stepper Motor With an ESP Microcontroller
by KushagraK7 in Circuits > Wireless
7007 Views, 33 Favorites, 0 Comments
Wi-Fi Controlled Stepper Motor With an ESP Microcontroller
I recently came across this video and decided to modify the project to control a stepper motor and add an OLED display. In this quick, little project, let's learn how to control a stepper motor's position from a web browser using an ESP8266 microcontroller. Let's get started!
Get All the Required Stuff
For this project, you will need:
- An ESP8266 microcontroller
- A Stepper Motor(Unipolar or bipolar)
- *A suitable stepper motor driver
- A breadboard
- Some breadboard wires(Or male jumpers)
- A 5-volt DC power source
- ²A 128x64 I2C OLED display(Optional)
*A motor driver like ULN2003 can be used for unipolar stepper motors, while a driver like L298N can be used for both unipolar and bipolar stepper motors.
²The OLED display is an optional device and can be omitted if not available. The motor control will not be affected.
Install the ESP Board in the Arduino IDE
- Start by going to File> Preferences or by pressing Ctrl+Comma.
- Copy this link: https://arduino.esp8266.com/stable/package_esp826...
- Paste the link in the 'Additional Boards Manager URLs.
- Then go to Tools> Boards> Boards Manager and type in 'ESP' in the search box.
- Install the latest release of the ESP boards.
Install the OLED Library
Start with opening the library manager in the Arduino IDE. You can either go to Sketch> Include library> Manage libraries or press Ctrl+Shift+I. Search for SSD1306 as shown in the picture and install the latest version of the library.
You can skip this step if you are not using the OLED display in your project.
Program the ESP Microcontroller
Depending on whether you are using an OLED display or not, you can choose which code to upload on the ESP microcontroller. You can get the Arduino codes from here.
Make sure to put the SSID(name) and password of your Wi-Fi router in the code.
Plug on the ESP Microcontroller on the Breadboard
Connect the OLED Display to the Microcontroller
You can skip this step if you are not using the OLED display in your setup.
Wiring connections from ESP to OLED display:
3v3 -> VCC
GND -> GND
D1 -> SCL
D2 -> SDA
Connect the Stepper Motor to the ESP Microcontroller
Connect the stepper motor to the output pins/terminals of the driver module.
Here is how to wire up the stepper motor driver to the ESP microcontroller:
D5 -> IN1
D6 ->IN2
D7 ->IN3
D8 ->IN4
Some stepper motors, particularly unipolar ones have a different stepping sequence. So you might need to change the sequence of the input wire connections to the driver board.
Power Up the Setup
If you have the OLED display connected to the ESP microcontroller, you can power it from any 5-volt power source. The display will show the IP address of the ESP microcontroller after it gets connected to the Wi-Fi router.
If you don't have the OLED display connected to the ESP microcontroller, then you can connect the microcontroller to your computer and open the serial monitor in the Arduino IDE, the IP address of the ESP microcontroller will be displayed after it gets connected to the Wi-Fi router.
Once you have obtained the IP address, type it in the address bar of the browser on a device that is connected to the same Wi-Fi router and you should be able to see a web page like in the above picture.
Test the Controls
On moving the slider on the browser, the motor should move and follow the direction of the slider as shown in the video.
If the motor just vibrates in place, change the sequence of wires connected to the input pins of the motor driver.
Share Your Creation and Do More!
If you have got your setup working, why not share a picture or two of your creation? I would love to see yours and it will inspire others to make this project. Also, try to take this project further by adding more features, perhaps a different type of screen, 2 stepper motors? There is a lot that can be done!