Sending email when motion detected

Don’t you see problem here? I think you mean

if (digitalRead(motionsensor) == HIGH) {

1 Like

how did i miss that xD
thank you i will correct it and tell you the result

same results i dont get the notification or the email until i press another button on the dashboard

Well, I think you have something wrong with your program logic. If something doesn’t work as expected just separate it into small pieces. So first - remove all unnecessary code, than make sure you setup button on pin 2 correctly. Leave simple code like that :

void notifyOnButtonPress()
{
    Blynk.notify("warning motion is detected");
}

this is just for begging than add conditions one by one and check if all works for you.

1 Like

so i solved the code’s fault and now it seems to work but my arduino disconnects so frequently it keeps saying your arduino is not in network!!

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