MicroPython | 2 min | 3396
As you may have noticed in my past videos, I've been using a self-made rotating platform to display the projects. In this article, I'll describe and present it to you. It is still in its baby step, and I need a case to put everything inside. However, the code is available. The microcontroller is an ESP32, which is connected to Wi-Fi and hosts a website to configure the angle, speed, and direction of rotation. The ESP32 is programmed using MicroPython. Check out the following video!
Software and Hardware
The following hardware and software will be used in this article:
I used a bipolar stepper motor to rotate the plate. The L298N is a friendly motor driver and works well with the bipolar stepper motor. You can also use an L293D. However, the L293D can drive a motor with up to 600mA, while the L298N supports up to 2A. Both ICs can be used for brushed motor, bipolar and unipolar stepper motors.
To build the rotating platform, follow these steps:
- Connect the bipolar stepper motor to the L298N board. Check the cable colors in Figs. 1 and 2. to see how to connect the bipolar stepper motor cables.
Connect the L298N board to the ESP32 board. I connected the INx pins following this table:
but you can change this inside the
- Bridge the jumpers
- Bridge the
12Vjumper, if your motor needs
12Vand connect an external power supply to the terminal board. Otherwise, you can use
5V. If you've 12V stepper motors, you'll need another power supply for the ESP32.
- Clone the repository
git clone https://github.com/lemariva/uPySteppers.git
- Rename the file
config.pyand configure your Wi-Fi credentials. If you've changed the pins to connect to the L298N, modify the
motor_configvariable too. Configure the
max_speedof your motor. In my case, the motor has a resolution of 1.8°, which means it needs 200 steps to achieve a 360° rotation. Thus, 200 is
max_speedparameter unit is steps/second. My motor can run up to 80 steps/second with the actual moment of inertia of my projects (battery + boards + etc.). If you set this parameter too high, the magnetic field rotates, but it won't be followed by the rotor. Therefore, it doesn't rotate.
- Flash MicroPython on the ESP32. If you are new with this, follow the steps in this tutorial: Tutorial: Getting Started with MicroPython on ESP32, M5Stack, and ESP8266.
- Upload the project code to the ESP32 using VSCode and the PyMakr extension.
- Connect to the ESP32 using a browser. You should get something like in the video. Have fun! :)
Fig. 1: Bipolar Stepper Motor schematic.
Fig. 2: L298N board schematic.
This article presents a DIY rotating platform. The angle, speed, and direction of rotation are controlled using an ESP32 connected to Wi-Fi. The ESP32 is wired to an L298N that drives a bipolar stepper motor.
The ESP32 is programmed using MicroPython and hosts a website that allows you to configure and start the rotation remotely.