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);
}
}```
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
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);
}
}```
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.
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.
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