I am using an Arduino setup to water my garden using a bistable/latching solenoid valve and batteries. My setup works flawless and has no problem but I'm concern about a certain scenario where the valve is kept open forever. The bistable needs a trigger from a motor controller to open and to close. In a worst case scenario, the valve opens and there could be any power failure then the solenoid will be kept open and the water keeps flowing. A regular solenoid valve will gets closed in case of a power failure but bistable solenoid valve is tricky and won't close until a logic trigger is needed. I don't know how to start or if a hardware or a software to fix it.
Then you know the solenoid need different polarity pulse to open and to close the valve. That is what the motor controller does for you.
Be sure your program closes all valves BEFORE doing anything else. When a power failure happens and the Arduino starts up, it will close the valves.
It was your choice to use the type of valve that may be open at the time of power failure and will stay open until power is restored. Not much can be done in that case.
Then you know if the valve has switched correctly, or in case of the battery it is starting to reach end of life.
In fail safe systems they use valves that are default closed and use (constant) power to stay open. If the power fails they will close automatically. Drawback is it can drain batteries.
That's the nature of bistable valve, there's no default state.
What kind of "power failure" you expect beyond low battery? For that you could code your arduino not to open the valve if (measured) battery level is too low.
You are right, low battery is the main and the only concern.
You mean a mechanical valve or electrical valve (like the one I'm currently using)?
There is a mechanical in-line valve before the electrical valve in order the manually shut off the water supply for maintenance or repair.
Let's say if the valve is open and a water flow detection timer is set but then if the battery goes low and cannot stop the valve.
This is included in my void setup and every time it's boots up it makes sure that the valve is closed
Correct, using bistable solenoid valves means I can run my setup outdoor with just 3 AA batteries and it can run for months. The whole setup draws only 40µA. The regular solenoids draws close to 600mA for opening the valve.
.
Can it be done without extra components or sensors? will an internal BOD detection is possible? The batteries will be close to dead when it's reach 3.4 to 3.5V.
What model of Nano? There are many different Nano models with different requirements and capabilities.
If you are using Nano V3 (atmega328) then 3xAA may not enough to guarantee reliable operation. This model of Nano runs at 16MHz and needs 4.2~4.3V minimum to run reliably. So as soon as the 3xAA fall to that level, the Nano may become unstable or freeze.
You could upgrade to 4xAA NiMH rechargeables, which would give around 5V. Or 4xAA primary cells which would give 6V. But then you might need a regulator if some kind to produce 5V for the Nano.
For battery operation, a 3.3V Arduino might be preferable, such as a Pro Mini or Pro Micro.
Chances are high that your solenoid valve stops working before arduino.
You can measure the 1.1V internal reference using Vcc as the reference. Little bit calibration and you should find the point when valve operation is not reliable anymore.
I'm using Nano V3 at breadboard with bench 5V for testing but moving to a PCB I'm using an ATTTiny13a and can run with 3xAA. The code is the same for both MCUs.
Add an emergency battery,
only to be used to switched on when main battery is too low.
triggering an digital switch takes less energy than turning the valve.
The emergency battery closes the valve and sends a notification that attention is needed.
Extra components is not a problem, I just wanted to know if it's possible to do it any extra components, like having an internal under voltage sense or something. Because I see an option inside the Arduino IDE and has BOD drop down fir Microcore library.
Is it better to use a dedicated component like a MC34064? The said component sense only 4.5V but maybe there could come components works with 3.3V?
An always open valve is also tantamount to an always closed valve. Since the plants would flood and overwater the plants and they will rot.
Anyways, I will check my garden everyday to see they are correctly irrigated so an always open valve is my top priority. Also the batteries use alkaline batteries and they are inside a IP67 enclosure, I'd have no way to see when the batteries will die. But I see your point, maybe I should include a 2.4V red LED pin to the MCU to indicate when the batteries.
That is the level where the processor will reset.
You really need an external circuit to measure the battery voltage with at least a +/- 0.1V accuracy.
What's the minimum voltage required to operate the valve?
I will connect another water line to the irrigation line and this end to a bottle with a small hole. If the water level threshold is reached and a water sensor go on and trigger it. Since the valve has a timer the bottle will never reach that threshold but if the valve is always open then the sensor will trigger it. I don't know, maybe it's a stupid idea?
All circuits draw some power. And sensor needs to be powered on to trigger anything. What's your plan with sleep cycles? How are you keeping time? Did you consider approach on post#9?