David Escobar
Published © GPL3+

Christmas Presents Intruder Detector

See when your kids move their presents! Detector sets off an audio alarm and sends an alert directly to your phone!

IntermediateFull instructions provided4,376

Things used in this project

Hardware components

Arduino MKR1000
Arduino MKR1000
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Adafruit Piezo
×1
Adafruit Lipo Battery 1200mAh
×1

Software apps and online services

Arduino Web Editor
Arduino Web Editor
Ubidots
Ubidots

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Present Detector Diagram

Code

Present Detector

Arduino
/*
Project: Present Detector
Created by: David Escobar
*Check out my site escobartechnologies.com*

MKR1000 board
Ubidots Account
*/

#include <SPI.h>
#include <WiFi101.h>
#include <UbidotsArduino.h>
#include <Wire.h>
#include <Adafruit_MMA8451.h>
#include <Adafruit_Sensor.h>
#define ID "Variable ID"
#define TOKEN "Ubidots Token"

char ssid[] = "Enter Network Name"; //  your network SSID (name)
char pass[] = "Enter Network Password";    // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;

unsigned int freq = 5000; //freq for piezo sound, change if higher volume needed
unsigned long time = 3000; //current time is 3 seconds

Ubidots client(TOKEN);
Adafruit_MMA8451 mma = Adafruit_MMA8451();

void setup() {
    Serial.begin(9600);
    //mma.begin();
    if (! mma.begin()) {
    Serial.println("Couldnt start");
    while (1);
    }
    
    mma.setRange(MMA8451_RANGE_8_G);
    
    Serial.println("MMA8451 found!");
    while (status != WL_CONNECTED) {
        Serial.print("Attempting to connect to SSID: ");
        Serial.println(ssid);
        status = WiFi.begin(ssid, pass);
        // wait 10 seconds for connection:
        delay(10000);
    }
}

void loop() {
    mma.read();
    sensors_event_t event; //get sensor data
    mma.getEvent(&event);
    // uncomment serial lines if needed
    /*
    Serial.print("Accelleration: ");
    Serial.print(event.acceleration.z);
    Serial.println();
    */
    client.add(ID,event.acceleration.z);
    client.sendAll(); //send data to ubidots
   
   if(event.acceleration.z > 10.0){
        tone(8,freq,time);
    }
    delay(1000); //wait 1 second 
}

Credits

David Escobar

David Escobar

7 projects • 37 followers
Healthcare Simulation Specialist. 9+ years in healthcare.I have been actively involved with 3D printing and electronics for the past 2 years

Comments