Relay control pin never drops to zero

I am trying to control the CW and CCW rotation of a brushed DC motor with a relay (datasheet found here.)

My problem is that my measured voltage never drops to zero, causing the relay to swap directions. It's at either 6.2 or 1.5 as you will see in pictures below.

This project is to control a dc motor which in turn opens and closes a window.

The circuit control is a slide potentiometer whose range is divided into 3 parts. All the way to the left = start opening window (mapped POT value between 10 - 333), all the way to the right = start closing window (mapped POT value 666 - 989), otherwise set both to low (no movement).

I'm also using the mapped POT value to control the interval between the builtin LED flashes. If you want to learn more about that you can click here.

I put a video on youtube of how the Node MCU is flashing and the serial output.
https://youtu.be/uweEY3No0pg

Below is my circuit diagram and where you see the 2 red stars is where I placed my multimeter prongs to get the 1.5V and 6.2V readings in the pictures below the diagram. and you can see the Yellow POT knob is on opposite sides corresponding with what the voltage should be to either rotate CW or CCW.

So my 3 questions are:

  1. Why is my voltage at 1.5V and not 0V?
  2. How do I fix it?
  3. Is there a more reliable, budget friendly Slide POT you can recommend?

1.5V Slide POT Left should be 0V

1.5V Slide POT Center should be 0V

6.2 V Slide POT Right, OK, But other control pin is 1.5V

int closePin = 16;
int openPin = 5;
int mappedPot;
int potValue;  // value from the analog pin
const int trigPin = 9;
const int echoPin = 10;
int potPin = A0;
//mapped pot values 0    333  666   999 
int startOpen = 334;
int startClose = 665;

// constants won't change. Used here to set a pin number:
const int ledPin = 2;  // the number of the LED pin

// Variables will change:
int ledState = LOW;  // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store

// constants won't change:
unsigned long previousMillis = 0;
int interval = 1000;  // interval at which to blink (milliseconds)


// the setup function runs once when you press reset or power the board
void setup() {
  Serial.begin(115200);
  // initialize digital pin 2 as an output.
  pinMode(2, OUTPUT);
  pinMode(potPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(closePin, OUTPUT);
  pinMode(openPin, OUTPUT);
}

void loop() {
  // here is where you'd put code that needs to be running all the time.
  potValue = analogRead(potPin);   // reads the value of the potentiometer (value between 0 and 1023)
  mappedPot = map(potValue, 0, 1023, 10, 989);

  //pot values 0    333   666  999  -> map to interval lengths 0 <-> 333, 0  ,  333 <-> 0
  //                                                                            666-333
  if(mappedPot < startOpen) {  // <334
    //led will flash faster as POT moves left. no need to modify interval
    interval = mappedPot;
    digitalWrite(closePin, LOW);
    digitalWrite(openPin, HIGH);
  } else if(mappedPot > startClose) {  // >665
    //interval gets longer as POT moves right, but need it to blink faster as moves right
    //startclose = 666, so interval needs to be 999 - mappedPot at 666 = 333 and goes to 999 - potValue at 999 = 0
    interval = 999 - mappedPot;
    digitalWrite(openPin, LOW);
    digitalWrite(closePin, HIGH);
  } else {
    interval = 100000;
    digitalWrite(openPin, LOW);
    digitalWrite(closePin, LOW);
  }

  Serial.print("int: ");
  Serial.print(interval);
  Serial.print("  mappedPot: ");
  Serial.println(mappedPot);
  
  // check to see if it's time to blink the LED; that is, if the difference
  // between the current time and last time you blinked the LED is bigger than
  // the interval at which you want to blink the LED.
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
}

  • Seeing 6.2v on the output pin on a ESP8266 (3V3 controller) means you are measuring wrong or the 8266 is ready for your junk box.

  • Is the meter switch on DC or AC volts ?

It should be on DC . . .

The wiring diagram in the relay data sheet shows it being used with mechanical switches that short the FWD and REV wires to ground. This implies that FWD/REV wires are carrying a voltage generated by the module.

If you are using the 5v version then you will see up to 6.5v on the FWD/REV pins. This is outside the range of the ESP8266.

In addition the ESP8266 pin current limit is going to make it difficult or impossible to pull the voltage low enough to activate the relay. Suggest using the ESP8266 to drive a MOSFET (with protection diode) that pulls the FWD/REV lines low.

Hi, @joortiz22

The connection diagram.

You need two relays to connect to where the two switches shown.

I would be very worried that you might have damaged your 8266.

Tom.. :grinning: :+1: :coffee: :australia:

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