NEMA 17 - WeMos Mini - Blynk

Introduction: NEMA 17 - WeMos Mini - Blynk

About: An Open Source and IoT Enthusiast

Stepper motors such as NEMA 17 have many uses and this prototype will help readers understand the method to control NEMA 17 from Blynk App.

This is an attempt to make an IoT that will help us access and control NEMA 17 from anywhere and at any time.

There are many use-cases where Stepper motor is used (Especially when you need precision in controlling the number of turns via code).

Supplies

  1. WeMos D1 Mini
  2. L298N Stepper motor drive
  3. NEMA 17 Stepper Motor
  4. Micro USB cable to power WeMos D1 Mini and transfer the code.
  5. 12V 1A Adapter to power NEMA 17 Stepper Motor
  6. Jumper Wires Male to Male & Male to Female
  7. Female DC Power Jack Adapter
  8. Capacitor - 100 μF
  9. Breadboard.

Step 1: Connection Diagram

The uploaded image is self-explanatory and the only major change is that I made use of a 12V 1A DC Adapter to connect the L298N driver. You will also not see any breadboard.

  1. D8 of WeMos D1 Mini > IN1 of L298N
  2. D7 of WeMos D1 Mini > IN2 of L298N
  3. D6 of WeMos D1 Mini > IN3 of L298N
  4. D5 of WeMos D1 Mini > IN4 of L298N
  5. 5V of WeMos D1 Mini > 5V of L298N
  6. GND of WeMos D1 Mini > GND of L298N > GND of 12V 1A DC Power supply

Note: NEMA17 stepper motor that I got has pins that have color-coded Red, Green, Blue, and Black. To identify the ends of two coils the only best way is to touch both the ends and turn the stepper shaft. The Stepper motor shaft moves smoothly if the wires connected do not belong to the same coil, the shaft does not rotate smoothly if they belong to one coil.

In my case, I have connected the wires as follows:

  1. Red of NEMA 17 > OUT1 of L298N
  2. Green of NEMA 17 > OUT2 of L298N
  3. Blue of NEMA 17 > OUT3 of L298N
  4. Black of NEMA 17 > OUT4 of L298N

Step 2: Configuring Blynk on Mobile

Attached screenshots should give the readers of this article the step by step procedure to configure two buttons that will help the user rotate the NEMA 17 Stepper Motor clockwise (or) anticlockwise. If someone is not able to follow screenshots and complete configuring Blynk, they might as well read through the instructions below:

  1. Open the "Blynk" app on your mobile and select "New Project".
  2. Enter Project Name: "NEMA 17 Control" (In this case), select "WeMos D1mini" from the list of "Device". Now select "Create" to proceed with the next steps.
  3. Check the Email configured in the "Blynk" app to find "Authorization Token" (This will be useful during coding).
  4. The dashboard appears, allowing us to proceed with the next steps and our main aim will be to add two buttons.
  5. Adjust the buttons to match the design needs (Step is Optional). In my case, I spread the buttons to match the width of the dashboard.
  6. Configure the first button with the text "Turn Left" with "V0" as a virtual pin.
  7. Configure the second button with the text "Turn Right" with "V1" as a virtual pin.
  8. Navigate to the main menu and click on the "Play" button to check the functionality of the application and controlling the NEMA 17 motor.
  9. NEMA 17 motor is programmed to rotate 10 times on the selection of the button. It will not turn on and off the moment you push either of the buttons to "Turn Right" (or) "Turn Left". Please allow some time for NEMA17 to stop and then proceed to check the functionality of the second button.

Step 3: The Code. . .

Before uploading the following code, make sure to provide the following:

  1. Authorization Key from Blynk
  2. SSID
  3. Passkey to allow "WeMos Mini" access the Wireless network & get connected to the Internet

Also select the following from Arduino IDE menu: Tools > Board > ESP8266 Boards > LOLIN(WEMOS) D1 R2 & mini.

>>> Start of the Code Snippet <<<

#include Stepper.h

#include ESP8266WiFi.h

#include BlynkSimpleEsp8266.h

#define BLYNK_PRINT Serial

Stepper my_Stepper(200, D8, D7, D6, D5);

bool Right = false;

bool Left = false;

char auth[] = "**********************************************";

char ssid[] = "****************";

char pass[] = "****************************";

void setup(){

Serial.begin(9600);

Blynk.begin(auth, ssid, pass);

my_Stepper.setSpeed(70);

}

BLYNK_WRITE(V1){

Right = param.asInt();

}

BLYNK_WRITE(V0){

Left = param.asInt();

}

void Stepper1 (int Direction, int Rotation){

for (int i = 0; i < Rotation; i++){

my_Stepper.step(Direction * 200);

Blynk.run();

}

}

void loop()

{

Blynk.run();

if (Right){

Stepper1(1, 10);

Serial.println("Right turn");

}

delay(20);

if (Left){

Stepper1(-1, 10);

Serial.println("Left turn");

}

delay(20);

}

>>> End of the Code Snippet <<<

Note: In the above code, please do not miss entering "<" (less than) and ">" (greater than) in the "include" statement. In case of any further issues with the code, you may also refer to the screenshot that is included with this article.

Step 4: Video Prototype Functionality

Attached is the video that will help readers briefly understand how the prototype works.

Be the First to Share

    Recommendations

    • First Time Author Contest

      First Time Author Contest
    • Make it Fly Challenge

      Make it Fly Challenge
    • DIY Summer Camp Contest

      DIY Summer Camp Contest

    Comments