BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Combining or adding app 2 sketches to save money for buying many nodemcu boards

Hey guys and sirs. I am working with IOT projects in like 4 months now but i just discovered this blynk platform, I know how to program with blynk but i don’t know to add a 2 sketch together(I know how to add sketches in arduino but i want to learn IOT with nodemcu).If you have a time to add this up together, I’ll be honored…please read this and answer this.
this code is gas sensor and flame sensor and i want to add them app together and i only used notification because it’s all i need.
here’s the code
SMOKE DETECTOR CODE

  1. #include <ESP8266WiFi.h>
    3. #include <BlynkSimpleEsp8266.h>
    4. #include <SimpleTimer.h>
    5. #define BLYNK_PRINT Serial // Comment this out to disable prints and save space
    6. char auth[] = “----------------”; //Enter Authentication code sent by Blynk
    7.

    1. char ssid[] = “PLDTHOMEFIBRPN3RV2.4”; //Enter WIFI Name
    2. char pass[] = “CBVI@DO14621”; //Enter WIFI Password
    3. SimpleTimer timer;
    4. int mq2 = A0; // smoke sensor is connected with the analog pin A0
    5. int data = 0;
    6. void setup()
    7. {
    8. Serial.begin(115200);
    9. Blynk.begin(auth, ssid, pass);
    10. timer.setInterval(1000L, getSendData);
    11. }
    12. void loop()
    13. {
    14. timer.run(); // Initiates SimpleTimer
    15. Blynk.run();
    16. }
    17. void getSendData()
    18. {
    19. data = analogRead(mq2);
    20. Blynk.virtualWrite(V2, data);
    21. if (data > 700 )
    22. {
    23. Blynk.notify("Smoke Detected at home!"); 
      
    24. }
    25. }

Flame detector code
> 1. #define BLYNK_PRINT Serial

    2. #include <ESP8266WiFi.h>
    3. #include <BlynkSimpleEsp8266.h>
    4. BlynkTimer timer;
    5. char auth[] = "6ced08cd273148a4a81162544bcc3b26"; //Auth code sent via Email
    6. char ssid[] = "Hacked"; //Wifi name
    7. char pass[] = "0123456789";  //Wifi Password
    8. int flag=0;
    9. void notifyOnFire()
    10. {
    11.   int isButtonPressed = digitalRead(D1);
    12.   if (isButtonPressed==1 && flag==0) {
    13.     Serial.println("Fire in the House");
    14.     Blynk.notify("Alert : FIRE DETECTED HOME");
    15.     flag=1;
    16.   }
    17.   else if (isButtonPressed==0)
    18.   {
    19.     flag=0;
    20.   }
    21. }
    22. void setup()
    23. {
    24. Serial.begin(9600);
    25. Blynk.begin(auth, ssid, pass);
    26. pinMode(D1,INPUT_PULLUP);
    27. timer.setInterval(1000L,notifyOnFire); 
    28. }
    29. void loop()
    30. {
    31.   Blynk.run();
    32.   timer.run();
    33. }

@davincivermaker you’ve posted your code using block quotes instead of triple backticks, not a great idea.

You should either have two timers, one which polls the smoke detector and another that polls the flame detector; or one timer which polls both sensors and sends the appropriate notification of needed.

Pete.

hello sir! I am very sorry because I’m just new in IOT things…I wish you can HELP me out?