I'm making a project about a gardening system with the help of bistable solenoid valve and a microcontroller. I have use regular solenoid valve before with the help of a relay module but I now I want to try it with a bistable/latching solenoid because they don't use current while the valve is open so I can have a low power consumption setup at the garden with batteries for a long time.
My setup is a ATTiny13a MCU, 1N4007 Diode, 4xAA Alkaline batteries, MX1058 or MX1616 motor controller and a bistable solenoid valve. My setup diagram is included.
I'm using the diode to reduce voltage input of the MCU so ATTiny13a can run under 5.5V.
The solenoid valve specification is 3.6 to 6V, 9 ohm coil resistance and a pulse width of 30ms.
My code is
// Arduino Code for ATTiny13a ||
// Bistable Solenoid Valve || 30ms impulse || 9 ohms coil resistance || 3.6 to 6 Volts
// Motor Controller MX1508/MX1616 Module H-Bridge
const int SolenoidA1 = 1; // Set Digital Pin 0 on Solenoid pin
const int SolenoidA2 = 2; // Set Digital Pin 1 on Solenoid pin
void setup()
{
pinMode(SolenoidA1,OUTPUT); // Set the Digital Pin 0 as an output
pinMode(SolenoidA2,OUTPUT); // Set the Digital Pin 1 as an output
digitalWrite(SolenoidA1, LOW); // SolenoidA1 (Open Valve) - initially off
digitalWrite(SolenoidA2,HIGH); // Close the solenoid valve
delay(30); // Impulse delay for the bistable solenoid valve
digitalWrite(SolenoidA2,LOW); // When project is starting
}
void loop()
{
digitalWrite(SolenoidA1,HIGH); // Set HIGH for pin A1 to open the valve
delay(30); // Impulse delay for the bistable solenoid valve
digitalWrite(SolenoidA1,LOW); // Set LOW for pin A1 to maintain the valve
delay(10000); // Wait for 10 seconds and keep the valve open
digitalWrite(SolenoidA2,HIGH); // Set HIGH for pin A2 to close the valve
delay(30); // Impulse delay for the bistable solenoid valve
digitalWrite(SolenoidA2,LOW); // Set LOW for pin A2 to maintain the valve
delay(20000); // Wait for 20 seconds and keep the valve closed
}
Is my hardware wiring setup and my code is correct or not? The code is just a demo and if you guys think is correct then I can modify the code with millis and include sleep. Main thing is the pulse width time, should I really have that 30ms between the valve state? or change the impulse delay to shorter or longer?. I have never used a bistable solenoid so I really don't know how to run it. So I did not experiment too much and afraid that it might burn the solenoid. Also I'm using a diode to drop voltage for the MCU, is using a voltage regulator like AMS1117 is better?