Shouldn't My Meter Show A Voltage

I purchased a really cool motor shield for my node mcu v2

ESP8266: NodeMCU Motor Shield Review – Squix – TechBlog

After hooking it up to a simple dc motor on motor a ports it didn't work. so I hooked up my meter to the motor b + & - ports and still get 0 volts. I am powering nodemcu from computer USB.

So my 2 questions are

If it's hooked up correctly there should be a voltage read, correct?

Do you have any suggestions on getting this to work?

image

image

/*
     Board pin | NodeMCU GPIO |  Arduino IDE
          A-                    1                         5 or D1
          A+                    3                         0 or D3
          B-                    2                         4 or D2
          B+                    4                         2 or D4
*/

const int pwmMotorA = D1;
const int pwmMotorB = D2;
const int dirMotorA = D3;
const int dirMotorB = D4;

int motorSpeed = 500;

void setup() {
  Serial.begin(115200);
  Serial.println();

  pinMode(pwmMotorA , OUTPUT);
  pinMode(pwmMotorB, OUTPUT);
  pinMode(dirMotorA, OUTPUT);
  pinMode(dirMotorB, OUTPUT);

  Serial.println("Motor SHield 12E Initialized");
  delay(5000);
}

void loop() {
  Serial.println("Activate A");
  digitalWrite(pwmMotorA, motorSpeed);
  digitalWrite(dirMotorA, LOW);
  delay(1500);

  Serial.println("Reverse A");
  digitalWrite(dirMotorA, HIGH);
  delay(1500);

  Serial.println("Stop A");
  digitalWrite(pwmMotorA, 0);
  digitalWrite(dirMotorA, LOW);
  delay(3000);

  Serial.println("Activate B");
  digitalWrite(pwmMotorB, motorSpeed);
  digitalWrite(dirMotorB, LOW);
  delay(1500);

  Serial.println("Reverse B");
  digitalWrite(dirMotorB, HIGH);
  delay(1500);

  Serial.println("Stop B");
  digitalWrite(pwmMotorB, 0);
  digitalWrite(dirMotorB, LOW);
  delay(3000);
}

That line doesn't do what you think it does. digitalWrite only takes LOW or HIGH for the second argument. 500 is not an option. It will just turn that into 1.

you are correct it is supposed to be analogWrite().

If it were correct shouldn't there be a voltage?

Yes the voltage will be there ~3.5V or 0 (On or Off). The pin will be turning on and off depending on the duty cycle you set. To get a voltage you will need to integrate that signal and amplify it unless you are talking very small currents. A scope or logic analyzer will show what's happening, a voltmeter is designed to smooth out the pulses and not show them. You can try AC but no promises, a lot depends on the meter. When driving a motor it actually integrates the PWM into current, voltage is dependent on the winding impedance and frequency.

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