Devices & Components
Solderless Breadboard Half Size
Jumper wires (generic)
Lipo Battery 1200mAh
Arduino MKR1000
Piezo
Hardware & Tools
Soldering iron (generic)
Software & Tools
Ubidots
Arduino Web Editor
Project description
Code
Present Detector
arduino
1/* 2Project: Present Detector 3Created by: David Escobar 4*Check out my site escobartechnologies.com* 5 6MKR1000 board 7Ubidots Account 8*/ 9 10#include <SPI.h> 11#include <WiFi101.h> 12#include <UbidotsArduino.h> 13#include <Wire.h> 14#include <Adafruit_MMA8451.h> 15#include <Adafruit_Sensor.h> 16#define ID "Variable ID" 17#define TOKEN "Ubidots Token" 18 19char ssid[] = "Enter Network Name"; // your network SSID (name) 20char pass[] = "Enter Network Password"; // your network password (use for WPA, or use as key for WEP) 21int status = WL_IDLE_STATUS; 22 23unsigned int freq = 5000; //freq for piezo sound, change if higher volume needed 24unsigned long time = 3000; //current time is 3 seconds 25 26Ubidots client(TOKEN); 27Adafruit_MMA8451 mma = Adafruit_MMA8451(); 28 29void setup() { 30 Serial.begin(9600); 31 //mma.begin(); 32 if (! mma.begin()) { 33 Serial.println("Couldnt start"); 34 while (1); 35 } 36 37 mma.setRange(MMA8451_RANGE_8_G); 38 39 Serial.println("MMA8451 found!"); 40 while (status != WL_CONNECTED) { 41 Serial.print("Attempting to connect to SSID: "); 42 Serial.println(ssid); 43 status = WiFi.begin(ssid, pass); 44 // wait 10 seconds for connection: 45 delay(10000); 46 } 47} 48 49void loop() { 50 mma.read(); 51 sensors_event_t event; //get sensor data 52 mma.getEvent(&event); 53 // uncomment serial lines if needed 54 /* 55 Serial.print("Accelleration: "); 56 Serial.print(event.acceleration.z); 57 Serial.println(); 58 */ 59 client.add(ID,event.acceleration.z); 60 client.sendAll(); //send data to ubidots 61 62 if(event.acceleration.z > 10.0){ 63 tone(8,freq,time); 64 } 65 delay(1000); //wait 1 second 66} 67
Downloadable files
Present Detector Diagram
Present Detector Diagram

Present Detector Diagram
Present Detector Diagram

Comments
Only logged in users can leave comments