Arduino Forum

Using Arduino => General Electronics => Topic started by: Pipo123 on May 17, 2019, 01:55 pm

Title: 230v relay with arduino
Post by: Pipo123 on May 17, 2019, 01:55 pm
Hi,

I wanted to build a simple watering system for my plants and came across a problem considering the relay. On this forum I wasn t able to find any related topic bc I didn t really know what to look for.

I m using an arduino nano and a humidity sensor that can be plugged into the soil and is directly connected to the arduino.
Furthermore i have connected a relay to one of the digitalouts of the arduino that is supposed to trigger the relay whenever the soil passes a certain humidity level.
The relay triggers a 230 v ac plug.

Now to the problem. When I put the humidity sensor in the soil and measure with a multimeter to a ground object(like a heater body) , then the ac voltage reads a value of approx 45 v? The same happens if I connect any pin of the arduino to the heater body(ground).

(If i connect the gnd port of the arduino to the earth(aka ground aka heater body) then the voltage disappears. But how i can fix this problem without always having to connect the gnd port to a big metal object?)

 What can I do to "ground" the entire arduino board?
Is there maybe a common thing that i ve overseen and that you re familiar with?

Cheers Paul

P.S. I put this in the electronics topics area bc it s only related to the relay i think. Had the same issues when i connected only a relay without arduino to the ac electricity and measuring between in1 pin and the heater body
Title: Re: 230v relay with arduino
Post by: adwsystems on May 17, 2019, 02:02 pm
Can you please draw this out and post, labeling (numbering) all points and describe where you are placing the probes when you take the voltage measurements. I cannot figure out between which two points you are measuring 45V.

The relay when open, should be be like the 230V is not there. So what is voltage measurement when you disconnect the wires from the relay terminals?

We will also need details on you power supply for the arduino. How is it powered (USB or external), and if external please provide information on the power supply.
Title: Re: 230v relay with arduino
Post by: Pipo123 on May 17, 2019, 02:13 pm
The problem also ocurrs when the arduino is not even powered yet. It already ocurrs when i connect the ac to the NO and the COM port and then measure the voltage on the other side between and pin that would go to the arduino. I attached a drawing of how I connected the relay with the ac voltage and the arduino.

So I m not sure if it is rather related to the relay than the arduino but didn t know where else to ask. And atill i was wondering how i could make this bulletproof ao that the arduino won t get damaged on future time

Thanks already
Title: Re: 230v relay with arduino
Post by: Pipo123 on May 17, 2019, 02:30 pm
And i just added a photo of the entire system. Sorry for the messy cables hanging around but i think you can see where I am measuring the voltage. It s now lower again. Around 11 v. But it seems to differ depending on when and where. I have no idea why.

Any ideas?
Title: Re: 230v relay with arduino
Post by: adwsystems on May 17, 2019, 02:54 pm
Three items to note about your relay board:

1. The relay is rated for 250VAC
2. The board is not designed for 250VAC (the terminals are too close together)
3. There are no standoffs between the relay board and the wood behind it which means the pins on the bottom of the board have a non-zero ohm connection between them and you are risk a short circuit or fire.

Since all of you PCBs are pressed into the wood behind it, that is one likely source of you issue. Wood is NOT an insulator.
Title: Re: 230v relay with arduino
Post by: PerryBebbington on May 17, 2019, 03:16 pm
In your photo of the unit and the DVM I cannot tell if the low voltage electronics is earthed or not. I can see a yellow wire that might be an earth, but based on what you say I will assume not.

The neutral wire will have 230VAC on it coming from the load while the relays is not operated. As adwsystems pointed out, wood is not a (very good) insulator, so you have 230VAC being applied to the wood at one end and you are measuring some of that at the Arduino USB connector at the other end.

Earth your low voltage electronics and put a good insulator under the board with an air gap. I usually use plastic sheet of similar thickness to window glass, available at DIY places. You can buy nylon nuts and bolts and spacers to mount everything.
Title: Re: 230v relay with arduino
Post by: adwsystems on May 17, 2019, 03:58 pm
Earth your low voltage electronics and put a good insulator under the board with an air gap. I usually use plastic sheet of similar thickness to window glass, available at DIY places. You can buy nylon nuts and bolts and spacers to mount everything.
That depends on the design of the power supply for the Arduino. From the pictures it is not connected, so I cannot say if it would be grounded when the power supply for the Arduino is connected.
Title: Re: 230v relay with arduino
Post by: MarkT on May 17, 2019, 04:27 pm
Quote
Now to the problem. When I put the humidity sensor in the soil and measure with a multimeter to a ground object(like a heater body) , then the ac voltage reads a value of approx 45 v? The same happens if I connect any pin of the arduino to the heater body(ground).

(If i connect the gnd port of the arduino to the earth(aka ground aka heater body) then the voltage disappears. But how i can fix this problem without always having to connect the gnd port to a big metal object?)
I'm guess these are potted plants indoors?

Then they will be picking up capacitively from the mains wiring in the building.  The currents involved are
miniscule and shouldn't affect any low impedance sensor.
Title: Re: 230v relay with arduino
Post by: PerryBebbington on May 17, 2019, 04:47 pm
Quote
That depends on the design of the power supply for the Arduino. From the pictures it is not connected, so I cannot say if it would be grounded when the power supply for the Arduino is connected.
In the photo it's not, as far as I can see, earthed. I would want it earthed at the point the mains comes in, not rely on some other earth that might or might not be connected.

Pipo123 I don't want to discourage you but I do want you to be safe. If I were building your project I'd do the following:


Others here might have more advice.




Title: Re: 230v relay with arduino
Post by: adwsystems on May 17, 2019, 05:48 pm
Keep in mind that the load is live all the time that the mains is connected to the box, even if the electronics is off or has the load off. The load is only ever save if the mains supply has been removed completely (unplugged) from the box.
This can be mitigated by running the Arduino from the same 230V as running the heater(?) thus when one is unplugged the other is too.

It depends on the design and type of wall wart (if used) as connecting the wall wart DC ground may have an effect on the output voltage (and possible the input). There is too much variability in the design of wall warts and I avoid them when possible. If unavoidable I test them for load and "stray" voltage (ie., can DC- out be connected to earth ground). I prefer actual SMPS or linear power supplies as the designs are more consistent across manufacturers. Unfortunately, they are also markedly more expensive. Luckily equally more reliable. As an aside they also tend to be more powerful both per dollar and per cubic inch.
Title: Re: 230v relay with arduino
Post by: Pipo123 on May 17, 2019, 05:54 pm
Oooh thanks that was very helpful and I ll definitely pay attention to your advice on how to proceed. (It was just me assuming that it would be safer to build the system on wood cause it s not conductive but actually it is as all of you pointed out.

Aaand if I was to build it in a metal box with an insulation layer underneath inside, how would i have to ground the electronics? I guess by connecting the yellowgreen wire to the casing and as well the gnd port of the arduino to the casing?


And i was using the usb input for the arduino nano and from the same multi ac plug the wires that go to the relay
Title: Re: 230v relay with arduino
Post by: PerryBebbington on May 17, 2019, 06:01 pm
Quote
Aaand if I was to build it in a metal box with an insulation layer underneath inside, how would i have to ground the electronics? I guess by connecting the yellow-green wire to the casing and as well the gnd port of the arduino to the casing?
Yes, to the yellow-green wire from the mains lead. I usually use a solder tag (https://www.google.com/search?safe=off&q=solder+tag&tbm=isch&source=univ&client=firefox-b&sa=X&ved=2ahUKEwiwopGG96LiAhVeQRUIHTsaCSUQsAR6BAgJEAE&biw=1680&bih=890) connected to the earth wire and use a small nut and bolt (metal, not nylon!) to attach it to the inside of the box. I suggest you solder the green-yellow from the mains lead to the tag and also solder another tag to another piece of similar wire, which you connect to 0V on your circuit, then bolt both tags with the same nut and bolt to the inside of the box.
Title: Re: 230v relay with arduino
Post by: PerryBebbington on May 17, 2019, 06:06 pm
This is what happens when you combine electricity with wood Lichtenberg figures (https://www.extremeelectronics.co.uk/lichtenburg-figures-bbc-one-show/)
Title: Re: 230v relay with arduino
Post by: Pipo123 on May 17, 2019, 06:36 pm
Ok so i ll try once i got the casing done.

And the lichtenberg figures look really nice but well rather what i ll try to avoid.

I just separated the relay from the rest and let it hang freely in the air without touching anything and still there is a noticiple voltage as it can be seen in the attached pictures. How come? Now there is nothing connecte to the relay apart from the blue wire from the ac.
Title: Re: 230v relay with arduino
Post by: PerryBebbington on May 17, 2019, 07:08 pm
Is the blue (neutral) wire connected to the mains? Is the other end of the cable connected to a load of some kind?
Title: Re: 230v relay with arduino
Post by: Pipo123 on May 17, 2019, 07:21 pm
The brown and yellowgreen wire are untouched and i split the blue wire, put one end in the com port of the relay and the other one in the NO port. At the end the wires are just hanging freely as well. There is no consumer at the end

What would happen if i touched these 10V? Would there be a current that could give me a serious shock?
Title: Re: 230v relay with arduino
Post by: PerryBebbington on May 17, 2019, 07:32 pm
Quote
What would happen if i touched these 10V? Would there be a current that could give me a serious shock?
Probably nothing.

Do I take it from that that it is connected to the mains?

A multimeter has a very high input impedance. The blue wire from the relay to the end of the cable runs alongside the live brown wire and is capacitively coupled to it. A tiny bit of the mains will leak into the blue wire and a tiny bit of that will make it across the insulation on the board and in the relay, it doesn't surprise me that you MM can pick it up.

When I said 'probably nothing', that assumes nothing is actually faulty, that there is no connection to live that you are not aware of. One of the rules I have when working with live mains is to always assume that I missed something, that I made some mistake I am not aware of, that there is something I didn't see or think of that might be dangerous. I also put my left hand behind my back so I cannot accidentally make a circuit from one arm to the other across my chest and so my heart. It helps to be right handed and have your heart on the left of your chest too.

Title: Re: 230v relay with arduino
Post by: Pipo123 on May 18, 2019, 02:27 pm
It is conected to the 230v ac. Yes (don t know what the mains are. Did you mean that by mains?)

Yes that s a good thing as well to operate with one hand only i agree :)
Title: Re: 230v relay with arduino
Post by: Watcher on May 18, 2019, 10:41 pm
The general setup as shown in the pictures suggests that you dont have the skills to be messing with mains voltages.
There are  numerous safety and electrical wiring rule violations.

I would strongly suggest to try achieve your goal with lower voltages , perhaps 24v ac.

All solenoids, water valves etc are also available for 24v.
Title: Re: 230v relay with arduino
Post by: herbschwarz on May 18, 2019, 11:26 pm
Hi All,
That looks like a quality and standard design digital meter.
It probably has an input resistance of 10 megohms. What is
being measured is a leakage current and not an actual voltage.
(I was surprised when I first came across it.) A leakage of
only 1 microamp will read 10 volts on a meter like that.
Herb