Here is a circuit diagram of my set-up. Apologies if its a bit basic or organised incorrectly, it is my first diagram.
For simplicity I have just drawn out one solenoid and flame sensor, but in reality there are 5 (the other 4 are setup exactly the same). The flame sensor works very simply by sending a HIGH signal to the Arduino if it senses a flame, the sensitivity of it is adjusted on the component. The ignition system is a 1.5V BBQ ignition system and is controlled by a relay, when turned on it activates the ignition (the sparks) for all 5 pilot lights at the same time, they are not independent. The valve for the low pressure ignition propane system is a normally closed 12V electric ball valve, also controlled by a relay.
The push button needs to be held down constantly for anything to happen, if your hand is removed the whole system loses power and shuts off as all the valves are Normally Closed.
There are 2 gas lines, one low pressure for the ignition (already explained) and one high pressure for the boosh's (mini flame balls).
I have decided based on the suggestions above to remove the second arduino, and install a gas sensor (probably 2 or 3 gas sensors in case one malfunctions, ive bought 5). The gas sensors are very simple, with an adjustable digital output (HIGH if gas is detected)
https://www.watelectronics.com/mq2-arduino-gas-sensor/
Below is my code. What I want to achieve is this:
-
If the pilot system isn't ignited somewhere - on flame 1 for example, I would like to be able to continue on with the rest of the sequence while flame 1 tries to relight. If flame 1 doesnt manage to relight in 5 seconds, turn the whole thing off and troubleshoot. I'm sure there's an elegant way to do this but I really dont know how.
-
I would make my code much simpler using a loop. Is it possible to assign each solenoid and sensor somehow to be accessable from a loop of 1-5? This way I could just loop through effects 1 to 5 very easily.
Let me know if you guys require anything else in order to help me, anything you have to offer is greatly appreciated. Thanks so much for everything so far
#include <Arduino.h>
// define pins for fire features, flame sensors, and ignition system
#define FIRE_1 9
#define FIRE_2 10
#define FIRE_3 11
#define FIRE_4 12
#define FIRE_5 6
#define IGNITION_PIN 7 //pin to light ingition of pilot system
#define PILOT_VALVE 8 //pin to open pilot system valve
#define PROPANE_SENSOR 2
#define FLAME_SENSOR_1 A0
#define FLAME_SENSOR_2 A1
#define FLAME_SENSOR_3 A2
#define FLAME_SENSOR_4 A3
#define FLAME_SENSOR_5 A4
// function for if gas leak is detected, turn off pilot system valve and wait
void gasLeak()
{
//turn off pilot valve
digitalWrite(PILOT_VALVE, LOW);
//stay here forever until arduino is manually reset
delay(9999999999);
}
void setup()
{
// put your setup code here, to run once:
// turn on delay for initiation
delay(3000);
// setting pin modes, solenoid switches and ignition system are outputs
pinMode(FIRE_1, OUTPUT);
pinMode(FIRE_2, OUTPUT);
pinMode(FIRE_3, OUTPUT);
pinMode(FIRE_4, OUTPUT);
pinMode(FIRE_5, OUTPUT);
pinMode(IGNITION_PIN, OUTPUT);
pinMode(PILOT_VALVE, OUTPUT);
//sensors are inputs
pinMode(FLAME_SENSOR_1, INPUT);
pinMode(FLAME_SENSOR_2, INPUT);
pinMode(FLAME_SENSOR_3, INPUT);
pinMode(FLAME_SENSOR_4, INPUT);
pinMode(FLAME_SENSOR_5, INPUT);
pinMode(PROPANE_SENSOR, INPUT);
//attach interrupt to propane sensor, to turn everything off if there is a leak
attachInterrupt(digitalPinToInterrupt(PROPANE_SENSOR), gasLeak, HIGH);
//open up pilot valve and turn on ignition system for 10 seconds to light it
digitalWrite(PILOT_VALVE, HIGH);
digitalWrite(IGNITION_PIN, HIGH);
delay(10000);
//if all pilot lights havent been lit in 10 seconds, there is a problem that needs investigating
//goes to gasLeak program which shuts off the propane
if (FLAME_SENSOR_1 == 0 || FLAME_SENSOR_2 == 0 || FLAME_SENSOR_3 == 0
|| FLAME_SENSOR_4 == 0 || FLAME_SENSOR_5 == 0)
{
gasLeak();
}
//else - if all pilots are lit, we're good to go
else
{
digitalWrite(IGNITION_PIN, LOW);
}
}
void loop()
{
// put your main code here, to run repeatedly:
// simple test sequence
// check flame sensor, is pilot flame on?
// if true then open the solenoid for a quick boosh, before moving to the next one
if (FLAME_SENSOR_1 == HIGH)
{
digitalWrite(FIRE_1, HIGH);
delay(40);
digitalWrite(FIRE_1, LOW);
delay(1000);
}
if (FLAME_SENSOR_2 == HIGH)
{
digitalWrite(FIRE_2, HIGH);
delay(40);
digitalWrite(FIRE_2, LOW);
delay(1000);
}
if (FLAME_SENSOR_3 == HIGH)
{
digitalWrite(FIRE_3, HIGH);
delay(40);
digitalWrite(FIRE_3, LOW);
delay(1000);
}
if (FLAME_SENSOR_4 == HIGH)
{
digitalWrite(FIRE_4, HIGH);
delay(40);
digitalWrite(FIRE_4, LOW);
delay(1000);
}
if (FLAME_SENSOR_5 == HIGH)
{
digitalWrite(FIRE_5, HIGH);
delay(40);
digitalWrite(FIRE_5, LOW);
delay(1000);
}
}