Selenoid motor not responding to NodeMCU instructions

I just start a project migrating from Arduino Uno to NodeMCU, basically this projects control some selenoid motors triggered by a website instructions. For example: if website returns 2, the motor #2 start work.

I hace everything ready, fetching from the website but, the motors are not working. In Arduino Uno works but in NodeMCU did not.

The selenoid motor is this one from AliExpress: the 3v -->

The circuit I made is like this:

NodeMCU / Motor

D2 -> Positive motor wire (red wire).

3.3V -> Positive motor wire (red wire).

GND -> Negative motor wire (black wire).

All this is attached to a protoboard for easy my work, but those are the connections of the circuit.

At otherwise, the code looks something like this:

void setup() {
  pinMode(D2, OUTPUT);


void loop() {
  digitalWrite(D2, HIGH);
  digitalWrite(D2, LOW);


I also tried instead of pin name D2 use 4 corresponding of the GPIO number. Didn't work.

The wired part is in Arduino Uno the same code and same circuit works perfectly, but in NodeMCU not.

What is the driver circuit for the solenoid? I do not think that the solenoid can be directly driven by an Arduino output and without a flyback diode the output would likely be damaged.

No only is the output voltage of an Uno (5V) different from the ESP8266 (3.3V) but the maximum recommended current is also lower (ESP8266, 10mA, sourcing). You really should use a proper driver.

The MOSFET will need to be a logic level device that will turn on with 3.3V gate voltage.


This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.