Need help with my NodeMCU V3

Untitled

this?

yes !

hmm so what should i do ?

9600 is ok

so I don’t know why you can’t see

hmm should i re flash my nodemcu again ?

yes try again, you have to flash it every time you modify your code

Its not working too :sob: can i use virtual pin in blynk like this ? To send noti

ehh

#include <ESP8266WiFi.h>;

must have semicolon at the end ?

no semicolon after include

alright @Blynk_Coeur i want to tell you that my coding works , buzzer led all works, im using this coding

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

const int gasPin=A0;
int gasValue=0;
const int buzpin=5;
const int threshold=100;
const int ledPin=4;

char auth[] = "e34ebc75567b4a098cc183acf7e84495";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "babablacksheep";
char pass[] = "taikmu123";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode (gasPin,INPUT);
  pinMode (buzpin,OUTPUT);
  pinMode  (ledPin, OUTPUT);  
}
   

void loop()
{
  gasValue=analogRead(gasPin);
  Serial.println(gasValue);
  delay(200);

  
  if (gasValue>150)
  {
    digitalWrite (2,HIGH);
    tone (buzpin,100);
    digitalWrite (ledPin, HIGH);
    delay(100); 
    Blynk.virtualWrite(V4, gasValue);
    delay(100);
    Blynk.run();
    
  }
  
      else
   {
        digitalWrite (2,LOW);
        noTone(buzpin); 
        digitalWrite (ledPin, LOW);
   }  
  }

it send noti to my blynk app but it only send one noti only. after i try again to put gas to my gas sensor then it didnt send anymore hmm i dont know why

Hi @Ash_Twi,
Please, review the use of Blynktimer and change your code accordingly.

Your loop is Arduino style and you MUST learn and use Blynk style instead.

but i already used blynk style and i cant connect with my blynk app, hmm its okay now i will try again

I’m afraid using that loop you are far away from Blynk style…

Check the docs and learn about a nice loop using Blynk and the use of timers.

Don’t put any command inside void loop()-
it will cause reconnection to blynk server!

ok i change to blynk style , it is correct ? this sketch can connect to blynk app but my gas sensor didnt works so it cant send the noti

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

const int gasPin=A0;
int gasValue=0;
const int buzpin=5;
const int threshold=100;
const int ledPin=4;
BlynkTimer timer;


char auth[] = "e34ebc75567b4a098cc183acf7";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxxxxxxxxx";
char pass[] = "xxxx";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode (gasPin,INPUT);
  pinMode (buzpin,OUTPUT);
  pinMode  (ledPin, OUTPUT);  
  timer.setInterval(120000L, gas);  // check every 120s
}

void gas()
{
  gasValue=analogRead(gasPin);
  Serial.println(gasValue);
  delay(200);

  
  if (gasValue>150)
  {
    digitalWrite (2,HIGH);
    Blynk.virtualWrite(V4, gasValue);
    delay(100);
    tone (buzpin,100);
    digitalWrite (ledPin, HIGH);
    delay(100); 
    
    
  }
  
      else
   {
        digitalWrite (2,LOW);
        noTone(buzpin); 
        digitalWrite (ledPin, LOW);
   }  
}
   

void loop()
{
   timer.run();
   Blynk.run();
  }

yes this code is good

but why it cant detect the gas or it is slow to detect the gas because i put delay(100) ?

as you have a timer, you don’t need delay()

sorry I have not gas sensor, I can’t help you :face_with_raised_eyebrow:

1 Like

Reduce your interval to 1000L for instance and check results.

Delete this delay

It looks like Blynk style… :wink:

2 Likes