+21622886281
ESP32 Stepper Motor

Control a stepper motor by ESP32

The ESP32 is a microcontroller that can be used to control a stepper motor. It is a powerful, low-cost microcontroller that is well suited for controlling stepper motors and other devices that require precise control over position or speed.

To control a stepper motor using an ESP32, you will need to use a stepper motor driver. The driver acts as an interface between the microcontroller (ESP32) and the stepper motor. It takes the control signals from the ESP32 and converts them into the appropriate signals for the motor to rotate.

You can use the Stepper library that is available for the ESP32 to control the stepper motor. The library provides a simple and easy-to-use interface for controlling stepper motors. To use the library, you will need to include it in your code and create an instance of the Stepper class, passing in the number of steps per revolution for the motor, and the pins that the motor is connected to.

Once you have set up the stepper motor and its driver, you can use the step() function to rotate the motor a specific number of steps in a given direction.

It’s important to note that controlling a stepper motor with an ESP32 requires a bit more setup and wiring compared to a simple DC motor. It also requires a stepper motor driver to convert ESP32‘s control signal to the stepper motor control signal.

Purpose of tutorial:

In this tutorial, we will control a stepper motor by the ESP32 card: the stepper motor turns clockwise then it turns counterclockwise.

Necessary components

ESP32 card

The ESP32 is a microcontroller developed by Espressif Systems, that is based on the popular ESP8266 microcontroller. It is a powerful, low-cost microcontroller that is well suited for a wide range of applications including Internet of Things (IoT) projects, home automation, and wireless communication.

The ESP32 has a dual-core processor, with one core dedicated to handling high-speed connections, and the other core dedicated to handling the user’s application. It also features integrated Wi-Fi and Bluetooth capabilities, making it ideal for wireless communication and IoT projects.

28BYJ-48 stepper motor

The 28BYJ-48 stepper motor is a small, low-cost stepper motor that is commonly used in small hobby and robotic projects. It is a four-phase, five-wire stepper motor that is driven by a ULN2003 driver IC. The motor has a step angle of 5.625 degrees per step, meaning it takes 64 steps to complete a full rotation. The motor’s maximum torque is 34.3 mNm, so it is not suitable for heavy loads or high-precision applications.

The motor’s step angle is not very precise, but it is still suitable for many small hobby and robotic projects such as small CNC machines, printers, and other projects that require precise and smooth control of the motor.

The 28BYJ-48 stepper motor can be controlled by an ESP32 microcontroller. The ESP32 is a powerful, low-cost microcontroller that is well suited for controlling stepper motors and other devices that require precise control over position or speed.

To control the 28BYJ-48 stepper motor with an ESP32, you will need to connect the motor to a ULN2003 driver IC, and then connect the driver IC to the ESP32. The ULN2003 driver IC has four input pins and four output pins, so you will need to connect the input pins to four digital pins on the ESP32, and connect the output pins to the four wires of the stepper motor.

ULN2003 driver IC

The ULN2003 driver IC is a Darlington transistor array that is commonly used to drive stepper motors and other devices that require high current and/or high voltage. It is a monolithic high-voltage, high-current Darlington transistor array. It consists of seven NPN Darlington pairs that feature high-voltage outputs with common-cathode clamp diode for switching inductive loads.

The ULN2003 driver IC has 16 pins with 4 inputs and 7 outputs. The 4 inputs are connected to the microcontroller, and the 7 outputs are connected to the stepper motor. The inputs of the ULN2003 driver IC are connected to the digital pins of the microcontroller, which is typically an Arduino board, and the outputs are connected to the stepper motor coils. The ULN2003 IC can drive up to 500mA of current per channel.

The ULN2003 driver IC is a simple and convenient way to drive stepper motors and other devices that require high current and/or high voltage. It is relatively easy to use, as it only requires a simple connection to a microcontroller and the device that it is driving.

Battery of 9V

A 9V battery is a type of primary (non-rechargeable) battery that provides a nominal voltage of 9 volts. It is commonly used in portable devices such as smoke detectors, remote controls, and small electronic toys. 9V batteries are also used in some low-power projects such as small robots and simple electronic circuits.

Connecting wires

Wires in a robotic system are used to connect and transmit electrical signals between different components of the robot. These components can include sensors, actuators, motors, and the microcontroller, such as an Arduino. The wires in a robotic system are typically made of copper and are insulated to prevent electrical interference and short circuits.

The type of wires used in a robotic system depends on the specific application and requirements of the robot. For example, a robot that requires high-current power transmission may use thicker, high-gauge wires, while a robot that requires a high degree of flexibility and movement may use thinner, more flexible wires.

Test plate

A test plate for Arduino is a type of test plate that can be used in conjunction with an Arduino microcontroller to automate experiments or tests. The test plate typically contains multiple wells or compartments that can hold samples or test solutions, and is designed to interface with the Arduino’s digital inputs and outputs.

Mounting the ESP32 board with the stepper motor

  • We connect the UNL2003 module to the stepper motor

  • We connect the IN1 pin of the UNL2003 module to the D32 pin of the ESP32 card

  • We connect the IN2 pin of the UNL2003 module to the D33 pin of the ESP32 card

  • We connect the IN3 pin of the UNL2003 module to pin D25 of the ESP32 card

  • We connect the IN4 pin of the UNL2003 module to pin D26 of the ESP32 card

Micropython program

Here are the micropython programs that allow the stepper motor to be controlled by the ESP32 card.

boot.py

Stepper.py

 




0 commentaire


Leave a comment

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Scroll to Top