Voltage difference of around 1.5V between 5V VCC and digital pin in a low state

Hello,

I am encountering a problem with the digital pins on my Wemos D1 R2 board. When these pins are in a logic level low state, there is still a voltage difference of approximately 1.5V between the digital pin and the 5V pin. Interestingly, when the pins are floating, the voltage difference drops to around 1V. However, if I connect a voltage between 3.5V and the digital pins, the voltage reads zero in logic low state.

The main issue I'm facing is that I am trying to drive a 5V relay (HW-307), but it remains constantly on due to this voltage discrepancy. To temporarily address the problem, I have been using the "OUTPUT_OPEN_DRAIN" mode in the setup, which has provided a workaround. However, I am still eager to understand the root cause of this issue. Is this a fault with the board, and if so, is there a way to fix it?

I apologize if I have violated any forum rules or protocols, as I am new to this platform. Please let me know if any additional information is required.

Thank you in advance for your assistance and insights.

did you make the pin an OUTPUT? share the code you used and how you made the measurement

All the I/O pins on that board are 3.3V NOT 5V.
Why are measuring between an I/O and 5V?
Normally you would measure an I/O voltage between the I/O pin and ground (GND)

1 Like

Thanks for pointing it out!

i have now figured it out, the Wemos D1 R2 logic high is 3.5v, unlike the UNO i was using before which has 5v logic high, another problem the HW-307 relay is rated for 5V. Normally most 5v relays works in 3.5v but this one is Low Level Trigger Relay and apparently 3.5 v is not high enough for it to trigger. So, it stays on.

the board has a 5V Pin but connoting to it instead of VCC normally makes things worse, because digital high stays 3.5v which means we get (5v-3.5v)=1.5 v even when logic is high, OUTPUT_OPEN_DRAIN function solves this by bringing the Digital pin to ground instead of giving logic high. So relay gets full 5v.

i was using multimeter, also another UNO through analog serial read to diagnose the issue.

the code is very basic.

int relayPin = 7;

void setup(){

   //doesnot work
  // pinMode(relayPin, OUTPUT);

  pinMode(relayPin, OUTPUT_OPEN_DRAIN); //works

}

void loop(){
  digitalWrite(relayPin, HIGH);
  delay(1000);
  digitalWrite(relayPin, LOW);
  delay(1000);
}

Just because you can make it open drain does not mean you can connect it to 5V.
You may be causing damage to the wemos d1

1 Like

:worried: should i use a transistor to drive the relay? i have checked using a multimeter the current draw from 5v to data pin is 3.5 to 4 milliamps, the limit is 40mah right?

If I remember correctly it's 12mA for an ESP8266

1 Like

Doesn't an HW-307 already have a transistor to drive the relay? I've tried looking up the schematic, but get conflicting diagrams with some having the transistor switching the ground to the relay and others switching the +5v line.

You want the current draw from the data pin to the input pin of the HW-307, the amount of current from the 5V supply includes the current for the relay coil and any other circuitry on the HW-307 board.
The ESP8266 current limit from a data pin is 12mA, not 40mA. mAh is not a current measure, it is milliamp-hours, and is generally used to state the storage capacity of a battery.

It's not the current that is the problem it's the voltage.
As I already mentioned ALL I/Os are 3.3V not 5V
So yes use a transistor.

1 Like

Yes, you are correct as i am checking the current drawn from the vcc to relay its 53mA, so yes, the HW-307 relay has transistor for switching otherwise, current drawn from data pin would have been much higher than 3.5mA.

however [jim-p] said the voltage is the problem not the current. so, I might need external transistor to drive it.

If you are looking for a quick hack because you don't have a transistor handy, try supplying the relay with the 3v3 line instead of the 5 volt. I have successfully driven a 5v HW-307 with just a 3 volt OUTPUT_OPEN_DRAIN pin when supplying it with 3 volts instead of 5. (WEMOS D1 Mini and a NodeMCU)

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