Need help in designing a Smart led bulb with Smoke detection

Hello,
I am thinking of designing a smart led bulb with smoke/fire detection in it.
The problem I am facing is that I am not able to constantly keep the smoke detection in ON state, and I also want the whole circuit to reset once the buzzer goes OFF.
The circuit image is attached.
I want help in integrating an RGB bulb and a smoke sensor together.


This is my code it's very cluttery because I had to use workarounds in order to get that smoke sensor working at all times.

int red_light_pin = 11;
int green_light_pin = 9;
int blue_light_pin = 8;
int smoke_input = A5;
int smoke_level = 0;
int smoke_thres = 450;
int buzz = 10;

void setup() {

  Serial.begin(9600);

  pinMode(red_light_pin, OUTPUT);
  pinMode(green_light_pin, OUTPUT);
  pinMode(blue_light_pin, OUTPUT);
  pinMode(buzz, OUTPUT);
  
}

void RGB_color(int red_light_value, int green_light_value, int blue_light_value)
{
  analogWrite(red_light_pin, red_light_value);
  analogWrite(green_light_pin, green_light_value);
  analogWrite(blue_light_pin, blue_light_value);
}

void smoke_read() {
  Serial.println(analogRead(smoke_input));
  smoke_level = analogRead(smoke_input);
  delay(10);
  
}

void fire_alarm()
{
  if (smoke_level > smoke_thres) {
    RGB_color(255, 0, 0);
    digitalWrite(buzz, HIGH);
    delay(6000);
   }
  else
    rgb_effect1();
    digitalWrite(buzz, LOW);
}
void rgb_effect1() {
  RGB_color(255, 0, 0);
  delay(1000);
  smoke_read();
  
  RGB_color(0, 0, 255);
  delay(1000);
  fire();
  RGB_color(255, 255, 125);
  delay(1000);
  fire();
  RGB_color(0, 255, 255);
  delay(1000);
  fire();
  RGB_color(255, 0, 255);
  delay(1000);
  fire();
  RGB_color(255, 255, 0);
  delay(1000);
  fire();
  RGB_color(255, 255, 255);
  fire();
  delay(1000);
}
void fire(){
  smoke_read();
  fire_alarm();
  delay(1000);
}
void loop() {
  smoke_read();
  delay(500);
  fire_alarm();
  delay(500);
  rgb_effect1();
}

Thanks for reading if you did. I really appreciate the help.

Now the smoke detector must by definition, contain a battery (nowadays, lithium with a ten year lifetime, and its own buzzer), otherwise it would be simply unsuitable.

The smoke detector must have a switch output to trip the Arduino. The only ones that I know of which have such an output are those designed to be wired to the mains. What one are you proposing to use?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.