Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Nodemcu esp8266 stepper motor NEMA 17 controlled over WiFi

By EG Projects May 13, 2021

This tutorial is about controlling stepper motor over WiFi through desktop or mobile web browser using nodemcu esp8266 WiFi module. Nodemcu will work as a server and it will serve a web page. Web page contains the stepper motor control buttons. Stepper motor takes steps to complete one full 360 degree rotation. Number of steps required to complete one full rotation depends on the particular motor step angle. Normally step angles are 0.9 degree and 1.8 degree per step. Stepper motors are capable of delivering high torque at small angles. They consume high power in order to produce high torque. Their small steps made them popular to be used in projects where high accuracy is required. They are popularly used in car manufacturing industry. Stepper motors drives robotic arms used in car manufacturing. Stepper motor drive arms in such a precise angle that an arm can easily insert a small nut in car parts where ever is required. Stepper motors are also the main part of 3D printers. Even normal printers and disk drivers uses stepper motors to accurately rotate the discs.     

NEMA 17 Stepper Motor

Stepper motors are dc brush less motor. Stepper motors are divided in two general categories uni polar stepper motors and bipolar stepper motors. You can find many tutorials on internet which explains the difference between the two. For this project i am going to use bipolar stepper motor. Bipolar stepper motor which i am going to use in the project is NEMA 17. Nema 17 is popular 4 wires 2 coils stepper motor. Its step angle is 1.8 degree. So for one complete rotation it takes 200 steps (200 x 1.8 = 360). Normal power consumption of NEMA 17 is 5 to 12 volts and it drains 1 to 1.5 amperes of continuous current when load is attached to it.
Four wires of the NEMA 17 are colored differently. Normally wires are red, blue, green and black. Red and blue represents first coil and green and black represents second coil. In some motors blue is replaced with yellow and black with grey. If you are going to use NEMA 17 in a diy project first please make sure the correct coil pair with colors.    

A4988 stepper motor driver

Stepper motors consumes lot of power while moving loads. When their is no load current consumption is drastically reduced. To supply the amount of power discussed above to stepper motor(NEMA 17 12 volts 1.5 amperes) we need and external power source. With external power source we also need a circuit which can control the motor rotation perfectly and easily. Traditionally a combination of transistors or mosfets know as H-Bridge circuit is used to control the stepper motor with microcontrollers. Making an H-Bridge circuit and testing it is a time consuming task.  Now a days variety of pre-assembled H-Bridge boards or motor controller drivers are available in market. They are not only cheap but are also easy to work with. For this project i decided to use one of the pre-assembled H-Bridge stepper motor driver board. The stepper motor driver which i selected for the project is A4988. A4988 is a bipolar stepper motor driver. Power requirements of A4988 is 3.3 volts to 5 volts. It can easily drive a two coiled stepper motor. External power is supplied to it and its internal H-Bridge circuit divides the power among the coils when coils are energized.
I explained each and every pin of of A4988 bipolar stepper motor driver in an another tutorial. Pin configuration and steeper motor rotation mode is also explained in the tutorial. I suggest you to please take that tutorial first in order to get familiarize with A4988 driver and its operations requirements. If you go through that small tutorial and its part on A4988 motor driver you can easily understand the code and circuit diagram below.

A4988 Stepper motor driver pin configuration and connection requirements

Project Circuit diagram

9 volt battery is connected between Vmot and gnd pins of A4988 motor driver. 9 volts are enough to energize NEMA 17 coils. Stepper motor coils are connected to 1A, 1B, 2A and 2B pins of A4988 stepper motor driver. A4988 driver is powered by nodemcu 3.3 volt output power rail. Step pin of A4988 is connected to D3 pin or GPIO-0 of nodemcu esp866 12e. Dir pin of A4988 is connected to D4 of nodemcu WiFi module. Reset and Sleep pins are interconnected. A4988 mode pins Ms1, Ms2 and Ms3 are left open. In this configuration motor is set in full step mode. Enable pin is also left open. It is internally pulled down and the module always remain in enable mode. I again encourage you to please take the tutorial recommended above other wise you can not understand the circuit discussed earlier  and code code going to discussed further.   

Nodemcu esp8266 12 e controlling stepper motor over WiFi

Nodemcu esp8266 12 e controlling stepper motor over WiFi
Coming to wards the project code. First the ESP8266WiFi library is included in the code. This library initializes the server and WiFi of nodemcu esp8266 WiFi module. Than the SSID and PASSWORD of the WiFi is required to which you want to connect you nodemcu WiFi module. It will be you home router WiFi password and ssid if you are going to test the diy project at home. Please enter the password and ssid in code before moving forward. Enter the ssid and password in the double quotes.  

const char* ssid = “Your SSID”;
const char* password = “Your Wifi Password”;

Next the A4988 control pins are defined. Step pin of A4988 stepper motor driver is connected to GPIO-0 or D3 pin of nodemcu WiFi module. Direction pin of A4988 is connected to GPIO-2 of D4 pin of nodemcu esp8266 board. 

In the setup function control pins are declared as output. Arduino ide serial monitor is initialized at 115200 baud rate. Server is started and web page IP is published. I will talk more about it after code. In the loop function the main program logic is running. In the loop function server is waiting for a client request. As soon as the server receives the client request it manipulates it and responds to request.

Just make the circuit and download the above code in it. Before uploading the code to nodemcu first make sure correct board is selected. After downloading the code in nodemcu open the arduino serial monitor from arduino ide. As soon as you open the serial monitor you will see nodemcu requesting your router for an IP assignment. After IP assignment nodemcu will start its server. After server startup the address of the server will be printed on serial monitor window. This address is actually the address of web page which contains the stepper motor controls. You have to enter this address in your browser to access the web page.       

Picture

HTTP web page address example is given on the upper right corner. One most important thing. Server (nodemcu, esp8266) and client (mobile, desktop, laptop or notebook) must be connected to same WiFi network. If any one of the module client or server is connected to another network, web page will note appear in your browser. Once you enter the IP in browser following web page will appear in the browser. 

Stepper motor WiFi control with nodemcu esp8266

Stepper motor WiFi control with nodemcu esp8266
Web page has two buttons one is forward and the other is backward. If you press the forward button motor will move 50 steps a head. If you press backward motor will change its direction and start taking 50 steps backward. Recall we are using NEMA 17 stepper motor and it take 200 steps to complete one rotation. So if i move motor 50 steps on each button press. It means i am moving stepper motor shaft by 90 degree on each button press. A for loop is run 50 times to allow stepper motor to take 50 steps. So now in our case stepper motor is taking 4 steps to complete 360 degree rotation or 1 step to move 90 degree.

Picture

Stepper motor steps angle count
Future Recommendations
This tutorial is a simple tutorial on how to control stepper motor over WiFi using nodemcu WiFi module. In future you can test other modes of stepper motor rotation steps 1/4, 1/8 and 1/16 micro steps. You can also manually enter steps in web page and move the motor according to the entered number. A bar can be inserted in web page and motor position can be controlled through it using AJAX web development language.   
Download the project code. Folder contains nodemcu arduino code .ino file. Code is open source one can use and change it. Please provide us your feed back on the tutorial.
Code/Files

You may also like:


  • What is the LoRaWAN network and how does it work?

  • What are the top development boards for AI and ML?

  • What is LoRa and LoRaWAN?

  • What are LoRa gateways and what types are available?

  • What is IP geofencing?

  • What is an SoC?

Filed Under: Electronic Projects, ESP8266
Tagged With: circcode and circuit diagram, circuit, esp8266, stepper motor, wifi
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • BF999 Input and output impedance
  • Control for DC motor
  • Industrial Relay Board Design for Motorcycle Use
  • Sendust vs Ferrite for SMPS
  • On/Off Slide Switch Reassembly Help

RSS Electro-Tech-Online.com Discussions

  • More fun with ws2812 this time XC8 and CLC
  • Wierd makita battery
  • I Wanna build a robot
  • using a RTC in SF basic
  • Is AI making embedded software developers more productive?

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • STMicroelectronics unveils SoC based on secure MCU
  • Nexperia’s 48 V ESD diodes support higher data rates with ultra-low capacitance design
  • Taoglas releases Patriot antenna with 18 integrated elements covering 600 to 6000 MHz
  • Amphenol RF introduces SMPM to SMPM assemblies on RG-178 cable
  • Infineon launches 3D magnetic sensors with ±50 mT to ±160 mT measurement ranges

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe