phpoc_man
Published © GPL3+

Arduino, Monitoring Door-Opening via Gmail

When the door is opened, Arduino sends a notification via Gmail. Magnetic Sensor is used to detect the door open. It can be used with IPv6.

BeginnerFull instructions provided57,936
Arduino, Monitoring Door-Opening via Gmail

Things used in this project

Story

Read more

Schematics

Things we need

Assembly

1. Stack PHPoC Shield on Arduino
2. Connect LAN cable or USB wifi Dongle to the shield for Ethernet
3. Pin wiring between Arduino and Sensor.
----5V--------red pin
----A0-------black pin

Code

Source Code

Arduino
#include <Phpoc.h>
#include <ezButton.h>

PhpocEmail email;
ezButton button(A0);  // create Button object that attach to pin A0;

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

  Phpoc.begin(PF_LOG_SPI | PF_LOG_NET | PF_LOG_APP);

  //Phpoc.beginIP6(); uncomment this line if you are going to use IPv6

  button.setDebounceTime(100); // set debounce time to 100 milliseconds
}

void loop() {
  button.loop(); // MUST call the loop() function first

  if(button.isPressed()) {    // if door is opened...
    email.setOutgoingServer("smtp.gmail.com", 587);
    email.setOutgoingLogin("Google ID", "Google Password");
 
    email.setFrom("Gmail address ", "Sender Name");
    email.setTo("Receiver email address", "Receiver Name");
    
    email.setSubject("Door is opened. [#905]");  // Mail Subject
    
    // Mail Contents
    email.beginMessage();
    email.println("#905");
    email.println("");
    email.println("Door is opened.");
    email.endMessage();                
 
    if (email.send() > 0)  // Send Email
      Serial.println("Your Mail has been sent successfully");
    else
      Serial.println("Your Mail is not sent");
  } else if (button.isReleased()) { // if door is closed...
        // Write codes in the same way
  }
}

PHPoC library for Arduino

This library communicates with PHPoC Shield to connect to the Internet. It's also contains Gmail library. How to install library: http://www.phpoc.com/support/manual/phpoc_shield_for_arduino/

Credits

phpoc_man

phpoc_man

62 projects • 408 followers

Comments