Sending email when motion detected

What kind of network connection do you use? Wifi or Ethernet? And if Wifi, have you got it powered using an external source or via the Arduino?

Ok, show your code. most probably you have this problem.

i am using ethernet shield

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>

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

SimpleTimer timer;

void setup()
{
Serial.begin(9600);
Blynk.begin(auth);

while (Blynk.connect() == false) {
// Wait until connected
}

// Notify immediately on startup
Blynk.notify(“Device started”);

// Setup a function to be called every minute

// Setup notification button on pin 2
pinMode(2, INPUT);
// Attach pin 2 interrupt to our handler
attachInterrupt(digitalPinToInterrupt(2), notifyOnButtonPress, CHANGE);
}

void notifyUptime()
{
long uptime = millis() / 60000L;

// Actually send the message.
// Note:
// We allow 1 notification per minute for now.
Blynk.notify(String("Running for “) + uptime + " minutes.”);
}

void notifyOnButtonPress()
{
// Invert state, since button is “Active LOW”
if (digitalRead(2)==HIGH)
{

Blynk.notify("warning motion is detected");

}
}

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

but i am thinking about doing it via cc3000 module should i power it via arduino or external source?

Please always wrap your code to make it readable!

sorry

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>

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

SimpleTimer timer;

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth);

  while (Blynk.connect() == false) {
    // Wait until connected
  }

  // Notify immediately on startup
  Blynk.notify("Device started");

  // Setup a function to be called every minute
 

  // Setup notification button on pin 2
  pinMode(2, INPUT);
  // Attach pin 2 interrupt to our handler
  attachInterrupt(digitalPinToInterrupt(2), notifyOnButtonPress, CHANGE);
}

void notifyUptime()
{
  long uptime = millis() / 60000L;

  // Actually send the message.
  // Note:
  //   We allow 1 notification per minute for now.
  Blynk.notify(String("Running for ") + uptime + " minutes.");
}

void notifyOnButtonPress()
{
  // Invert state, since button is "Active LOW"
  if (digitalRead(2)==HIGH)
  {
   
    
    Blynk.notify("warning motion is detected");
  }
}

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

Looks like a flood issue. You don;t define how long your timer runs I think. I’m not sure what it does default, but you should put that in somewhere in your setup. I think it’s expressed in ms.

You can refer to the PushData example. It uses the simpletimer lib.

Can I have multiple email notifications in my project? One says motion detected, one says temperature too high and one says door open?

I understand it will only handle one message every 60 seconds. Any plans to change that to less then 60 seconds?

Thank you
Brian

Yes, you can have as many emails as you want. But limit is 1 per minute.
You can change the frequency if you install and configure Local Blynk Server.

Thanks for your reply. I cannot run my project on local blynk server as the project and phone are not anywhere near each other. The only common connection is the internet. So, I guess I will be using one message per minute.

Thanks

Your local server can perform the same functionality as Blynk Cloud. The only difference is that you can configure it for yourself.

Take a look: http://docs.blynk.cc/#blynk-server

I will have to reread that. I dont understand it but thanks for pointing it out to me. Can I send the email message to more then one recipient by using a , or : between the address?

Thanks Pavel

Brian

Just use a different Blynk.email()

BTW, running local server is just 5 minutes :wink: Some time for configuring would be needed of course
@Dmitriy could help

1 Like

Do I only need to add one email widget to the dashboard or one email widget per message? Example, 3 different messages, 3 email widgets.

Thank you

You can’t even place 3 email widgets :smile:
One is enough. It just lets our server know that you will use emails

I plan on building a project that will be used by many people. They will all monitor conditions that are unique to them. If I understand the local server doc, I can change the frequency of the emails and generate tokens. So, then each person should be able to have their own token to connect to the local server and receive email messages. Which I would think I could create the messages in the server and just point each instance of the project to the correct message as it is called for.

Hope that makes sense! :confused:

I think right now it’s not a trivial task.
We are implementing app sharing with other people, so we will think about handling use cases like this.

Thanks for telling us. How many users will be using this app, BTW?

Right now I do not know how many people. I am still in the process of building the project. My issues are that all messaging services (twilio, temboo, thingspeak) all place limits on the amount and frequency of calls. For instance, Temboo only allows 250 calls a month on the free account. I have no clue if that will be enough or not (no crystal ball here) or twitter has restrictions on how often you can post messages to their system. I understand why there are restrictions, I am not complaining. I am just trying to find the best solution available. So, if I could build local server and have Blynk work like it does now with blynk server and remove the restriction of 1 call per minute (which may or may not be enough), I would look at doing that. Hope that is explained well. Anyway, I estimate having several hundred users for my project. Time will tell! :grin:

@baga I am trying to use email notification. Did you need to download the server for email notifcation?