Blynk DC motor speed control through NodeMCU

I am trying to use a NodeMCU to control the speed of a brushed DC motor through the blynk IOS app. I have no experience with DC motors, so I’m hoping someone can help me out with the coding side.

Here is what I have so far:

    #define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "1de9d226f13c487c8640447e4901265f";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "wifi";
char pass[] = "password";

int motorPin = 3; 
int speeed = 0;
void setup() {
  Blynk.begin(auth, ssid, pass, "", 80);
    pinMode(motorPin, OUTPUT);  
    while(! Serial);{
    Serial.println("Speed 225");}
  Serial.println("WiFi connected");

void loop() {;

    {speeed = (param.asInt());}
    analogWrite(motorPin, speeed);


I am still unsure of how to assign the speeed int to the blynk slider. Assistance would be appreciated. Thanks in advance

Controlling DC motors require some sort of intermediary circuit inbetween the NodeMCU and motors, such as L293D IC/Shields, L298N and other types of ICs. NodeMCU alone can’t handle the current needed for the motors

It’s easier (i think) to use Arduino IDE to program the NodeMCU, since there are a lot of libraries to use, to help ease the programming.

Google is your best friend !!

i am currently using arduino IDE and have managed to program a servo motor through the NodeMCU, however the DC motor is proving to be more tricky

Are you using an extra driver/circuit board with H bridge etc?

Or are you trying to use the output pins straight from the board?

I’m using a 3v dc motor, so the voltage from the board should be enough; I am using the pins straight from the board.

Well, there’s a few issues here…

  1. How much current is the motor drawing? The ESP8266 has a maximum current of 12mA per GPIO pin. That won’t drive much of a motor.

  2. Do you only want your motor to rotate in one direction? If you do then that’s okay, simply wire the negative connection to GND and the positive connection to a GPIO pin. However, if you want to reverse the direction then the connections need to be reversed. How are you going to achieve this?


The motor only needs to rotate in one direction, and the motors use 150 mA +/- 10%

I could wire the NodeMCU to an UNO and draw the power from there if the NodeMcu alone is not sufficient.

There are lots of approaches you could take, but the most sensible on in my book would be going for a NodeMCU motor shield, Wemos D1 Mini with Motor shield, or building your won H Bridge instead of using a shield.

Either way, it’s not really a Blynk related issue at this stage in the process.


I’m sure an Uno can only supply around 40mA. You need a transistor really. Or a relay.

Bad, bad, bad :unamused: … Microcontroller GPIO are designed for DATA not power, aside from a few LEDs, etc. And even then need to have current limiting resistors to mitigate overload.

And aside from large startup current (easily 2-3 times rated current) and running current requirements, motors are inductive circuits and can cause EM feedback that can damage your MCU. Use a proper H-Bridge Motor controller.


Would an ULN2803A work with the Node and dc motor?

Not directly as a motor controller… for that you need an h-Bridge based one. Just Google a bit and see the myriad of options to do so.

1 Like