Hi All!
Right at the beginning, let me mention that this is my first encounter with Arduino and that I am a total amateur. So I apologize in advance for some stupid questions. Ok, my problem is too high voltage in the AC network in the house caused by my private solar power plant. Therefore, I decided to make a circuit that will turn on the sanitary water heater when the 9-minute average voltage exceeds 251V. That same heater consumes 3kW and that is enough to bring down the voltage in the network to normal levels. Now, I need a CODE that will control it. I have already made the circuit for measuring the voltage and it works perfectly, now I just need to add a part of the code that will send a signal to the relay and turn on the hot water heater through it. I would be very grateful if someone could help me. I'm even willing to pay someone to write the code if someone has the will and time.
According to this picture, I connected the sensor and the LCD display to the arduino, now I need a code that, when the 9-minute average voltage passes 251V, will signal the relay to turn on the sanitary water heater.
If you need any more information, just say so.
You mention several phrases that make me think you shouldn’t be doing this.
Call your certified solar tech. / electrician before you hurt someone - uyour kids, visitors, contractors etc.
I won't attempt to write the code for you.
You really should fix the root problem by repairing (or upgrading your inverter)... It shouldn't over-voltage and it should probably shut down if it "browns out".
But if you want to do it your way -
One step at a time, testing as you go!
First, you'll need a relay to switch the heater on & off. You can't directly drive a regular electro-mechanical relay with the Arduino. You'll need a driver circuit, and you can buy "relay boards" with a relay & driver built-in if you don't want to build the circuit yourself. Or there are solid state relays that can be directly controlled with 3.3 or 5V at low current.
Next, modify the Blink Example to "blink" the relay at a slower speed so you can confirm that you can control it.
The basic logic is simply an If-statement. If the voltage is too high, turn on the relay, otherwise turn it off. But there's an issue - When you turn-on the heater, presumably the voltage will instantly drop and the heater will shut-off almost instantly and you're stuck in loop with the relay "chattering".
So, you'll need a delay after turning the heater on, or maybe you can monitor for a slightly high voltage after the heater is on, etc.
Youl'' need to make one or two timers with millis(). The Blink Without Delay Example shows you how do this.
According to my calculator, 9 minutes is 540,000 milliseconds.
The "trick" with millis() is that there is only ONE millis() or currentMillis but you can have more than one previousMillis and more than one interval. (Such as previousMillisHighVoltage and intervalHighVoltage, or whatever you variable-names you want to use.
And since you want the voltage to be high for 9 minutes you'll have to reset the timer if the voltage drops before 9-minutes is up. (You can figure that out later after you've got the basic delay working.)
And later when you've got everything working, you'll need to research how to handle millis() overflow. After about 50 days, millis() will count as high as it can go, roll-over back to zero, and start-over. (There are ways of dealing with that but I don't have a link handy.)
No, your problem is you fiddled with the system and illegally added a solar array.
My advice would be either return the system back to how it was, or.....keep and eye peeled for supply authority who will be placing monitoring equipment on the supply lines here and there to "track down" your system.
Result of that will be at best, a rather large fine.
All i can say is if your an amateur dont.
High voltage burns houses down and kills
Theres a reason there licensed electricians and electrical products dealing with high voltage have to be certified and meet standards
Yes, a link to the data sheet for the "sensor".
Because none of us will accept liability for a mains connected system that you have implemented I'd be amazed if anyone is prepared to write your code.
SO you will need to abandon the project or write it yourself.
The remaining parts are easy. You can google for them.
Can you make a signal to turn a solid state relay on and off?
Can you calculate a moving average?
However tinkering with mains operated devices is unsafe and in most countries illegal.
I say don't encourage the Op.
Obvious it is way out of their depth and illegal to boot.
Now that is not only from a supply authority perspective but clearly stated Arduino application as well.
From what you are saying , your solar system is not connected to the local grid , or the voltage would not rise ?
I would say you need to export power to the grid or fix the issue with your invertor to stop over voltage .
The switching in of a load will be an issue when that load is satisfied ( water is hot ).
I too don’t think this is for a hobby forum , it’s impossible to give reliable safe advice , and not really the place to ask advice with safety implications from someone you don’t know about (who might end up being an 8 year old who had a UNO for his birthday .)
Hammy ( aged 6, interested in Arson)
The problem with overvoltage is due to a bad network. The electricity distributor's answer was: we put you in a 10-year plan to build a transformer near your house. So I was left to solve the problem myself.
The biggest problem with too high a voltage is the inverter, which resets because of it, and during the reset I lose electricity production.
I thought I would solve the ignition of the heater with the Songle SRD-05VDC-SL-C Relay. If I understood correctly, it can react to a voltage of 5V and turn on a heater that works on 220V.
If it would be simpler, I was thinking of installing a special timer that will keep the heater on for 9 minutes and then turn it off.
What are you talking about? don't be angry, but that's nonsense, what would an illegal solar power plant mean to me if my consumption counter counted the production as if I had consumed it, it makes no sense
I shared this idea about "stabilizing the voltage" with the electricity distributors, of course no one has anything against it. Because it's simple, only one additional consumer is turned on when the voltage in the network is too high. It's the same, I sit next to the voltmeter and turn on the hot water heater until the voltage rises or the arduino will do it to me. Do you agree with me?
Everything is absolutely legal. I described everything in other posts
I have answered everything else in previous posts, but what about the problem with ignition while the water is hot. The same will not be a problem because I have a 300 liter water tank. one heater that will be turned on 4-5 times a day, for 9 minutes, has no chance of heating the water to the maximum value. The problem with the voltage is only around noon, so from 11 a.m. to 2 p.m. the rest of the day is not a problem.
"That same heater consumes 3kW and that is enough to bring down the voltage in the network to normal levels" Please show your calculations that prove it will not overheat the water. If you want the formula is:
P(kW) = 4.2 x L x (T2-T1) / 3600
T1 = Initial water temperature
T2 = Final water temperature.
Remember you are working with water that is probably already warm to hot so you calculate the temperature rise.
That calculation should have appeared in your question showing the heater actually has the capacity. What happens when something fails using equipment not rated for the application.
Because of the potential problems and your apparent lack of experience I highly recommend you not do this. I wish you luck, and only posted this to save a potential accident.
Ah, because you say so...mmm... well it MUST be ok then........it's absolute bullshit.
No supply authority would allow you to connect solar generated power to their grid whereby you designate the level of voltage.
There are also regulations in place to protect against the worst possible cases, in this instance, you home electric generation plant made by, as you freely admit, a total amatuer.
In my 50 plus years experience as an electrical contractor, when amatuers cut loose, it is almost always someone else that gets fried. It's dangerous stuff so don't play with it.
All I can say is , hope the angels are looking after any other so called "adjustments" you may have decided are necessary.
In addition, if you look amongst the legalaties of using Arduino, you will find a section about using same in what might be considered "life threating situations".
I suggest you familiarise yourself with it.
@zdenis
I guess I completely misread your question. I thought you had a residential solar system tied to a grid that has really poor regulation. So poorly regulated that it would cause your grid-tied inverter to reset when the grid voltage rose to over 250V. Your solution was to load the grid down to an acceptable voltage by enabling a 3 kW load during the time of day that it was most likely to be too high.
Not the case?
Exactly
That relay is only rated for 7A @ 240VAC.
You need a relay that can handle at least 14A @ 220VAC and can operate at voltages greater than 250VAC
