Tharrun Kumar NT
Published © GPL3+

IoT Smart Safe Securiy

An alert system that sends a notification to your mobile phone when anyone accesses the safe.

IntermediateFull instructions provided4 hours3
IoT Smart Safe Securiy

Things used in this project

Hardware components

Photon
Particle Photon
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
power brick 5V 1A
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Blynk
Blynk

Story

Read more

Code

Send_Data_to_Blynk

C/C++
It sends the data to blynk cloud which can be accesed via mobile app
// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>

#define echoPin 2 // attach pin D2 Arduino to pin Echo of HC-SR04
#define trigPin 3 //attach pin D3 Arduino to pin Trig of HC-SR04
#define BLYNK_PRINT Serial

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


// defines variables
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement

void setup() {
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
  pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
  Serial.begin(9600); // // Serial Communication is starting with 9600 of baudrate speed
  // Debug console

  delay(5000); // Allow board to settle
  Blynk.begin(auth);


}
void loop() {
  // Clears the trigPin condition
  digitalWrite(trigPin, LOW);

  // Sets the trigPin HIGH (ACTIVE) for 10 microseconds
  digitalWrite(trigPin, HIGH);

  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; // Speed of sound wave divided by 2 (go and back)
  // Displays the distance on the Serial Monitor
  Particle.publish("Distance",String (distance),60,PRIVATE);
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
  delay(300);
  Blynk.run();
  
  if (distance>30) {
    Serial.println("Button is pressed.");

    // Note:
    //   We allow 1 notification per 5 seconds for now.
    Blynk.notify("Access Is done");
    }
}

Credits

Tharrun Kumar NT

Tharrun Kumar NT

2 projects • 2 followers

Comments

Add projectSign up / Login