Arduino as Generator Auto Start System

Hi, [u]Please[/u] do not go back and do major edits to previous postings, it confuses anyone tryng to follow the postings.

Example, where is the circuit diagram you posted, that we are talking about?

Please post your circuit again so we can help you.

Tom... :o

TomGeorge: Hi, [u]Please[/u] do not go back and do major edits to previous postings, it confuses anyone tryng to follow the postings.

Example, where is the circuit diagram you posted, that we are talking about?

Please post your circuit again so we can help you.

Tom... :o

It is there on page 1 and this is the 2nd page

tariqsahi:
hello, i made a simple generator auto start system for my gasoline generator and it worked fine for a while. Now from last two days as soon as the mains not available the generator starts and then shuts off. To me arduino is somehow reseting automatically and it turns off the Switch Relay of the generator shutting down the generator and then attempt to restart it and the process keeps on going.
Here is my code it is very simple and works fine on the table but starts to act funny when generator has started.

#define IGN 13 //Ignition Pin

#define SW 12 //Switch Pin
#define AC 11//mains sense pin
#define Gen_IP 10 // generator start sense pin
int IGN_Time=0;
unsigned long Report_Time=0;
unsigned long Stop_Time=0;
int IGN_Attempt=0;
void setup() {
pinMode(IGN,OUTPUT);
pinMode(SW,OUTPUT);
pinMode(AC,INPUT);
pinMode(Gen_IP,INPUT);
digitalWrite(SW,LOW);
digitalWrite(IGN,LOW);
}

void loop() {
if(digitalRead(AC)==HIGH)
  {
 
  if(IGN_Attempt<4&&digitalRead(Gen_IP)==HIGH)//Gen_IP will be high when generator has not started yet
    {
       
    for(IGN_Time=0;IGN_Time<=4000;IGN_Time++)//give ign for 4 sec
      {
        digitalWrite(SW,HIGH);
        digitalWrite(IGN,HIGH);
        if(digitalRead(Gen_IP)==LOW||digitalRead(AC)==LOW)//if gen has started or mains is available then break the ign loop
          break;
        delay(1); 
      }
    if(IGN_Time>=4000&&digitalRead(Gen_IP)==HIGH&&digitalRead(AC)==HIGH) //if ign loop was complete and genrator has not started yet then wait for 5 sec before next attempt
    {
      for(int i=0;i<=5000;i++)
      {
        digitalWrite(IGN,LOW);
        if(digitalRead(Gen_IP)==LOW||digitalRead(AC)==LOW)
        break;
        delay(1); 
      }
    IGN_Attempt++;
    }   
    }
  else
    {
      if(digitalRead(Gen_IP)==LOW)//if generator has started reset the ignition counter
        {
          IGN_Attempt=0;
        }
        digitalWrite(IGN,LOW);
    }
  } 
else //if mains is available
{
  digitalWrite(IGN,LOW);
if(digitalRead(Gen_IP)==LOW)//if generator is running
  for(Stop_Time=0;Stop_Time<=120000;Stop_Time++)//wait for 2 mins before truning of the gen
    {
    if(digitalRead(Gen_IP)==HIGH||digitalRead(AC)==HIGH)
      { break; }
  if(Stop_Time>=120000)
  digitalWrite(SW,LOW);
  delay(1);
}

IGN_Attempt=0;

}
}

Great code! one question: would it be possible to overcome all the possible issues if I attach a standard 5v/12v relay to each PIN? I understand the code, but not familiar with the technical connection to the generator. My idea is to use a simple “arduino relay board” to switch on/off the ignition, starter… (I would add choke too, using a car door lock actuator). What do you think?