Voltage drop when relay activates and affects analog readings

I have a Sparkfun 5V generic relay hooked up to my Leonardo. I'm driving it via a 2N2222A NPN and have a 1N4004 across the relay contacts.

The relay opens and closes fine but when it's open it drops the voltage about 0.05 to 4.92 and throws off my analog reading (humidity sensor).

The relay has a coil resistance of 60 Ohms and I'm powering it from the Arduino 5V. I've tried both usb power and external 9V power but same result. Is there a solution here or do I just add x to the humidity readings when the relay is on and live with it? Thanks

Here are some readings. Note without the relay the readings are very consistent

Relay On current: 25.97, high: 26.13, low: 25.97 current: 25.97, high: 26.13, low: 25.97 current: 25.97, high: 26.13, low: 25.97 Relay Off current: 26.28, high: 26.28, low: 25.97 current: 26.28, high: 26.28, low: 25.97 current: 26.13, high: 26.28, low: 25.97 Relay On current: 26.13, high: 26.28, low: 25.97 current: 26.44, high: 26.44, low: 25.97 current: 26.28, high: 26.44, low: 25.97 Relay Off current: 26.60, high: 26.60, low: 25.97 current: 26.60, high: 26.60, low: 25.97 current: 26.44, high: 26.60, low: 25.97

Circuit .

Give the relay its own power supply. Don't expect the Arduino to power external devices unless they consume very little current.

...R

(5V - 0.7V)/60 ohms = 72mA USB is good for 500 - surprised that 72mA drops it so much. 4.92 is within the 5V +/-5% tolerance for USB.

Not sure about the onboard regulator, probably similar tolerance.

  1. Make sure your humidity sensor ground wire goes to its own ground pin on the Arduino. Connect the relay board ground to a separate ground pin. Otherwise, the relay current will cause a small voltage drop across the resistance of the wire and connection to the pin, which will get added to the analog voltage you are measuring.

  2. USB power makes a poor voltage reference because it is not very stable. What is the output voltage range of your humidity sensor? If the output range is contained within 0 to 3.3V, and the sensor is not both ratiometric and powered from 5V, then I suggest you use the 3.3V pin as your analog reference.

CrossRoads: (5V - 0.7V)/60 ohms = 72mA USB is good for 500 - surprised that 72mA drops it so much.

Perhaps some of the voltage drop is caused by the resistance of the polyfuse?

Hi, it could be a layout problem, can you post a picture of your project. If you are using a protoboard then you could have volt drops in the wiring or connections.

Tom...... :) dc42, damn beat me by "that much". Yes what dc42 says, tempted to cut and paste. lol.

Thanks for suggestions. Ok it's either the usb power, or it just stabilizes somehow over time. I had it plugged into an external 9V PS (and usb for communication) and after several hours there is still some drop with the relay on but it's very subtle. With usb power I'm seeing about a 1.7 %RH swing.

Any idea if the variance is related to my computer usb power or usb power in general? I was hoping to power the project with a usb wall wart. Of course once I plug that in I can't get serial data to see if the problem still exists.

When it's plugged into both barrel plug power and usb I understand it uses external (barrel plug)

I'm going to let it run overnight on usb power and see if it stabilizes

Hi, what is the humidity sensor you are using? I'm surprised that it is that sensitive to supply variations, can you post us a picture of your project and a circuit diagram, even a hand drawn circuit will do.

Thanks Tom... :)

Does your code leave time for the voltage to settle after a relay move before reading a voltage?

I've no idea if this would make a difference but may be worth trying.

...R

Ok, I was using a Leonardo clone. When I swapped with a genuine Leonardo I don't see any noticeable variation. Is it that the clone has a cheaper vreg? What's interesting is over time the readings stabilize, with the clone

BTW, the humidity sensor is a Honeywell HIH-4030 and yes I had a 1 second delay between readings and relay activation.

As I said before, you should use separate Arduino ground pins for the sensor and the relay. The resistance of connections made in a breadboard can easily be high enough to cause the relay ground current to affect the analog reading.

I guess I didn't understand that. There are two GND pins on the Arduino, but I thought they were the same circuit. So are you suggesting I should have relay go in one and the sensor use the other? In either case the problem is solved with the genuine Leonardo.

rappa: I guess I didn't understand that. There are two GND pins on the Arduino, but I thought they were the same circuit. So are you suggesting I should have relay go in one and the sensor use the other?

Yes. In an ideal world, it wouldn't make any difference. In the real world, the resistance of your common ground wire and the push-in connections at either end of it may cause the relay current to interfere with the analog reading from the sensor.

rappa: In either case the problem is solved with the genuine Leonardo.

It may be that the Leonardo clone used an inferior voltage regulator. Or it may be that in swapping the Arduino, the ground connection you made to the genuine Leonardo had a lower resistance than the one you made to the clone.