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.
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)
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.
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?
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.
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)