NEED HELP with my Arduino simulation

greeting,
I need help for my project simulation. I have face problem with LED not light up, and Blynk dashboard said device is offline. I currently using example from arduino uno using Serial USB in Arduino IDE.

Thanks in advance

here is my code

#define BLYNK_PRINT DebugSerial

/* Fill-in your Template ID (only if using Blynk.Cloud) */
//#define BLYNK_TEMPLATE_ID   "YourTemplateID"
#define BLYNK_TEMPLATE_ID " "
#define BLYNK_DEVICE_NAME "LED"


// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX

#include <BlynkSimpleStream.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = " ";

//sensor pin declare
int Buzzer = 10;
int Led = 9;
int Led2 = 8;
int sensorPir = 7;
int sensorFlame = 6;

int pirValue = LOW; //Place to store read PIR Value
int flameValue = LOW; //Place to store read flame Value
int value1; 

void setup()
{
  // Debug console
  DebugSerial.begin(9600);

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);

  pinMode(sensorFlame,INPUT); 
  pinMode(sensorPir,INPUT);
  pinMode(Buzzer,OUTPUT);
  pinMode(Led,OUTPUT);
  pinMode (Led2,OUTPUT);
  SensorState();
}

BLYNK_WRITE(V0){
  value1 = param.asInt(); 
  digitalWrite (Led2, value1); 
}


void loop()
{
  Blynk.run();

}

void SensorState()
{ 
  
  pirValue = digitalRead (sensorPir); 
  if (pirValue == HIGH) 
  {
    Blynk.logEvent("intruder", "THERE SOMEONE IN YOUR HOUSE!") ;
    digitalWrite (Led, HIGH);
    digitalWrite (Buzzer, HIGH); 
  }  
  else {
     digitalWrite (Led, LOW);
    digitalWrite (Buzzer, LOW);   
  }

  
  flameValue = digitalRead (sensorFlame); 
  if (flameValue == HIGH) 
  {
    Blynk.logEvent("fire", "FIRE IN HOUSE!") ;
    digitalWrite (Led, HIGH);
    digitalWrite (Buzzer, HIGH);  
  } 
  else {
    digitalWrite (Led, LOW);
    digitalWrite (Buzzer, LOW);
  }

}```


here is my simulation schematic

and my blynk-ser.bat

Hey there,
You have to use a timer to call your void sensorstate function.
More details here

You are creating a SoftwareSerial port (pins 2 & 3) for debugging, and using the hardware UART (pins 0 and 1) for your Blynk connection.
But, you have nothing connected to pins 0 & 1

Pete.

1 Like

i have update my code but my blue-led that function along my sensor does not light up. however, my Blynk apps was connected.

#define BLYNK_PRINT DebugSerial
#include <SimpleTimer.h>

/* Fill-in your Template ID (only if using Blynk.Cloud) */
//#define BLYNK_TEMPLATE_ID   "YourTemplateID"
#define BLYNK_TEMPLATE_ID "TMPLwWIv0_z3"
#define BLYNK_DEVICE_NAME "LED"


// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX

#include <BlynkSimpleStream.h>

SimpleTimer timer;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YYHDn_l7dr1gyatOGCjGfIrMLPoEqEhs";

//sensor pin declare
int Buzzer = 10;
int Led = 9;
int Led2 = 8;
int sensorPir = 7;
int sensorFlame = 6;

int pirValue = LOW; //Place to store read PIR Value
int flameValue = LOW; //Place to store read flame Value
int value1; 

void setup()
{
  // Debug console
  DebugSerial.begin(9600);

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);

  pinMode(sensorFlame,INPUT); 
  pinMode(sensorPir,INPUT);
  pinMode(Buzzer,OUTPUT);
  pinMode(Led,OUTPUT);
  pinMode (Led2,OUTPUT);
  
  timer.setInterval(5000L, SensorState);
}

BLYNK_WRITE(V0){
  value1 = param.asInt(); 
  digitalWrite (Led2, value1); 
}


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

void SensorState()
{ 
  
  pirValue = digitalRead (sensorPir); 
  if (pirValue == HIGH) 
  {
    Blynk.logEvent("intruder", "THERE SOMEONE IN YOUR HOUSE!") ;
    digitalWrite (Led, HIGH);
    digitalWrite (Buzzer, HIGH); 
  }  
  else {
     digitalWrite (Led, LOW);
    digitalWrite (Buzzer, LOW);   
  }

  
  flameValue = digitalRead (sensorFlame); 
  if (flameValue == HIGH) 
  {
    Blynk.logEvent("fire", "FIRE IN HOUSE!") ;
    digitalWrite (Led, HIGH);
    digitalWrite (Buzzer, HIGH);  
  } 
  else {
    digitalWrite (Led, LOW);
    digitalWrite (Buzzer, LOW);
  }

}```

thank you very much. the led already light up but my LogEvent does not working as coded.

How is your event configured?

Pete.

type: warning
I have turn on send event to notification tab and send event to timeline

It’s the detail of how the event is configured that we need to see.

Where are you looking to check if the events are being logged?

Pete.

So basically I just want to get notified if when the motion and fire sensor is high as my coding below:

void SensorState()
{ 
  
  pirValue = digitalRead (sensorPir); 
  if (pirValue == HIGH) 
  {
    Blynk.logEvent("intruder", "THERE SOMEONE IN YOUR HOUSE!") ;
    digitalWrite (Led, HIGH);
    digitalWrite (Buzzer, HIGH); 
  }  
  else {
     digitalWrite (Led, LOW);
    digitalWrite (Buzzer, LOW);   
  }

  
  flameValue = digitalRead (sensorFlame); 
  if (flameValue == HIGH) 
  {
    Blynk.logEvent("fire", "FIRE IN HOUSE!") ;
    digitalWrite (Led, HIGH);
    digitalWrite (Buzzer, HIGH);  
  } 
  else {
    digitalWrite (Led, LOW);
    digitalWrite (Buzzer, LOW);
  }
}```

Yes, I’ve seen the coding, but not how your event is configured, and the associated notification, or where you are checking to see if the events are being logged.

Pete.

I’m sorry for not understanding the statement.

I have configure this event using blynk event that will send the notification to the user device. The smartphone screen will go notified when the event is true. hope to answer your statement.
my apologies.
:pray: :pray:

Post a screenshot like this

Sorry for misunderstanding

Everything is okay.
Can you see anything in the timeline ?

There is no event at all… It is

so frustrated

Okay, try to trigger the event manually using api.
https://docs.blynk.io/en/blynk.cloud/trigger-events

Have you tried adding another serial device to use as your debug monitor?
If so, what does it show?

Are you sure that the flame sensor portion of the sketch is actually being triggered?

Pete.

I had some lcd last time, but my proteus cannot running in time. So i decided to delete it since this project is an iot project. I willing to get notified thru smartphone screen. After i delete the lcd, the flame sensor and the motion sensor both doesn’t trigger my LED to turn on. I don’t have a clue is it on my code or my software