Techatronic
Published

Blynk MQ3 Alcohol Sensor| Alcohol Detector

In this project, we are making an alcohol detector using an MQ3 alcohol sensor and nodemcu.

BeginnerFull instructions provided2 hours1,247
Blynk MQ3 Alcohol Sensor| Alcohol Detector

Things used in this project

Story

Read more

Code

Code snippet #1

Plain text
 //TECHATRONIC.COM  
 // BLYNK LIBRARY  
 // https://github.com/blynkkk/blynk-library  
 // ESP8266 LIBRARY  
 // https://github.com/ekstrand/ESP8266wifi  
 #include <ESP8266WiFi.h>  
 #include <BlynkSimpleEsp8266.h>  
 #include <SimpleTimer.h>  
 #define BLYNK_PRINT Serial  // Comment this out to disable prints and save space  
 char auth[] = "fRgyO8sX1W6CjpMiY8gp65I2_0yX-t4E"; //Enter Authentication code sent by Blynk  
 char ssid[] = "DESKTOP"; //Enter WIFI Name  
 char pass[] = "asdfghjkl"; //Enter WIFI Password  
 SimpleTimer timer;  
 int mq2 = A0; // Alcohol sensor MQ -3 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); // Blynk INPUT Connect V2 Pin  
  if (data > 700 )  
  {  
   Blynk.notify("Alcohol Detected!");   
  }  
 }  

Code snippet #2

Plain text
 //TECHATRONIC.COM  
 // BLYNK LIBRARY  
 // https://github.com/blynkkk/blynk-library  
 // ESP8266 LIBRARY  
 // https://github.com/ekstrand/ESP8266wifi  
 #include <ESP8266WiFi.h>  
 #include <BlynkSimpleEsp8266.h>  
 #include <SimpleTimer.h>  
 #define BLYNK_PRINT Serial  // Comment this out to disable prints and save space  
 char auth[] = "fRgyO8sX1W6CjpMiY8gp65I2_0yX-t4E"; //Enter Authentication code sent by Blynk  
 char ssid[] = "DESKTOP"; //Enter WIFI Name  
 char pass[] = "asdfghjkl"; //Enter WIFI Password  
 SimpleTimer timer;  
 int mq2 = A0; // Alcohol sensor MQ -3 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); // Blynk INPUT Connect V2 Pin  
  if (data > 700 )  
  {  
   Blynk.notify("Alcohol Detected!");   
  }  
 }  

Github

https://github.com/ekstrand/ESP8266wifi

Github

https://github.com/blynkkk/blynk-library

Github

https://github.com/jfturcot/SimpleTimer

Credits

Techatronic

Techatronic

72 projects • 122 followers
Electronic engineer

Comments