Unable to get Eventor to work with my project

Hi

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);


}

Any suggestions?

thanks

mark

I have studied other projects and I have managed to get a lot done with very little coding experience.

i was asking for a little assistance as I had spent many hours trying different things and had finally decided to ask for help.

I found that the documentation for this section is a bit lacking…

Seems that now you don’t want to help…thanks !

This too big delay for Blynk. You need to move data() function code to separate timer method. Same for virtualWrite. Here is simple and good example of how you can achieve that - https://github.com/blynkkk/blynk-library/blob/master/examples/GettingStarted/PushData/PushData.ino

Dimitriy

Many thanks,

I have improved the code based around what I have learnt from that.

I have a value widget in my project, that is set to PUSH and it is receiving the data.

However I am still not able to get the notification side working in the app.

I have added Eventor settings, as so

When V8 is lower than 150, send notification: : “help”
and that is active.

I have added the Notification widget to the project
I have added Email widget and put in my email address

But I just do not get an email when the value is below 150

So I am wondering if there is something with the phone app that I am doing wrong or if there is an issue of some sort?

Mark

Please show your updated code again. (Don’t forget formatting please)

// 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);
}

Thanks

but then i get error message

invalid conversion from ‘int ()()’ to 'timer_callback {aka void ()()}’ [-fpermissive]

this relates to the line

timer.setInterval(1000L, data);

@tomsk63 void data() not int data().

It should be void as return type and not int for this function.

Ah brilliant. Thnaks

But still no notifications to my email !

I am running 3 arduino uno across one project all using the same auth code, is that ok?

Could that be why?

Or is there some other reason?

mark

Yes that is what it is!
Changed it and now all good!

What exactly you changed?

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?

Mark