Ok the house runs off batteries through invertor. Normally very little load, fridge propane.
I'd like the generator to fill the water tank, while filling it sends power to invertor which charges batteries. Totally off grid.
I have written some code. Not sure how to get it to turn everything off if attempts 3 times to start generator and fail (j=3)
Here is code
int wellSwitchPin=3; //set well switch to pin 3
int chokeOnPin=4; //set choke on to pin 4
int chokeOffPin=5; //set choke off to pin 5
int genOnPin=6; //set generator on to pin 6
int genStartPin=7; //set generator start to pin 7
int genRunlightPin=8; //set generator run light to pin 8
int wellPowerPin=9; //set well power to pin 9
int housePowerPin=10; //set house power to pin 10
void setup() {
// put your setup code here, to run once:
pinMode(chokeOnPin, OUTPUT); //set choke on pin to output
pinMode(chokeOffPin, OUTPUT); //set choke off pin to output
pinMode(genOnPin, OUTPUT); //set generator on pin to output
pinMode(genStartPin, OUTPUT); //set generator start pin to output
pinMode(wellPowerPin, OUTPUT); //set well power pin to output
pinMode(housePowerPin, OUTPUT); //set house power pin to output
}
void loop() {
digitalWrite(wellPowerPin,LOW); //make sure well power is off
digitalWrite(housePowerPin,LOW); //make sure house power is off
digitalWrite(genOnPin,LOW); //turn gen off
if(wellSwitchPin==HIGH && genRunlightPin==LOW){
digitalWrite(genOnPin,HIGH); //turn generator to on
digitalWrite(chokeOnPin,HIGH); //turn the choke on
delay (250); //wait 1/4 second
digitalWrite(chokeOnPin,LOW); //leave choke on
for (int j=1; j<=3; j=j+1);
}
if(wellSwitchPin==HIGH && genRunlightPin==LOW);
{ // Start engine carnk loop
digitalWrite(genStartPin,HIGH); //Crank the starter
delay (5000); //crank for 5 seconds
digitalWrite(genStartPin,LOW); //stop cranking
delay (3000); //wait 3 seconds
if(genRunlightPin==HIGH && wellSwitchPin==HIGH){
delay (2000); //wait 2 seconds while generator warms up with choke on
digitalWrite(chokeOffPin,HIGH); //Turn the choke off 1/4 second pulse
delay (250); //
digitalWrite(chokeOffPin,LOW); //leave choke off
delay (15000); //wait further 15 seconds warm up with choke off
digitalWrite(wellPowerPin,HIGH); //turn power on to the well pump
digitalWrite(housePowerPin,HIGH); //turn power on to the house
}
}
}