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
#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.
- char ssid = “PLDTHOMEFIBRPN3RV2.4”; //Enter WIFI Name
- char pass = “CBVI@DO14621”; //Enter WIFI Password
- SimpleTimer timer;
- int mq2 = A0; // smoke sensor is connected with the analog pin A0
- int data = 0;
- void setup()
- {
- Serial.begin(115200);
- Blynk.begin(auth, ssid, pass);
- timer.setInterval(1000L, getSendData);
- }
- void loop()
- {
- timer.run(); // Initiates SimpleTimer
- Blynk.run();
- }
- void getSendData()
- {
- data = analogRead(mq2);
- Blynk.virtualWrite(V2, data);
- if (data > 700 )
- {
Blynk.notify("Smoke Detected at home!");
- }
- }
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. }