i have a working project that I am trying to expand.
I have added email to my project with correct email address
I have added eventor to the project.
I have then done the following
Event1
When V8 is lower than or equal to 150, send notification: "Alert distance is less than /pin/cm
But nothing happens, even when the value is 150 or less.
code is
// defines pins numbers
const int trigPin = 5;
const int echoPin = 6;
// defines variables
long duration;
int distance;
float h;
#define BLYNK_PRINT Serial
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>
#include <SPI.h>
char auth[] = "";
byte mac[] = { 0xDF, 0xAE, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 20, 91 }; // ip in lan (that's what you need to use in your browser. ("192.168.1.178")
byte gateway[] = { 192, 168, 20, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
Blynk.begin(auth);
}
int data()
{
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration * 0.034 / 2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
delay(10000);
//Blynk.virtualWrite(8, distance);
return (distance);
}
void loop()
{
Blynk.run();
data();
Blynk.virtualWrite(8, distance);
}
// defines pins numbers
const int trigPin = 5;
const int echoPin = 6;
// defines variables
long duration;
int distance;
//float h;
#define BLYNK_PRINT Serial
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>
#include <SPI.h>
char auth[] = "";
byte mac[] = { 0xDF, 0xAE, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 20, 91 }; // ip in lan (that's what you need to use in your browser. ("192.168.1.178")
byte gateway[] = { 192, 168, 20, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
SimpleTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(8,distance);
}
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
Blynk.begin(auth);
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
}
int data()
{
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration * 0.034 / 2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
delay(1000);
//return (distance);
}
void loop()
{
Blynk.run();
data();
timer.run(); // Initiates SimpleTimer
}
@tomsk63 you can also move data() to timer as well as you did for virtualWrite and you’ll not need delay in that case.
Better to use
easier to understand. All other things seems ok. I think that your eventor was triggered already.
Please try to :
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
Blynk.begin(auth);
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
timer.setInterval(1000L, data);
Blynk.virtualWrite(V8, 200);
}
although only getting in app notification, not an email…
I created new project, so new auth code. replaced that in the code. and then set up the value widget for V8 in new project added eventor with same logic as before, and added the notification and email widgets.
Now it works blynk gives notifivation, but still not getting an email?