1
10
11#include
12 <SPI.h>
13#include <WiFi101.h>
14#include <UbidotsArduino.h>
15#include <Wire.h>
16#include
17 <Adafruit_MMA8451.h>
18#include <Adafruit_Sensor.h>
19#define ID "Variable ID"
20#define
21 TOKEN "Ubidots Token"
22
23char ssid[] = "Enter Network Name";
24 SSID (name)
25char pass[] = "Enter Network Password";
26 (use for WPA, or use as key for WEP)
27int status = WL_IDLE_STATUS;
28
29unsigned
30 int freq = 5000;
31unsigned
32 long time = 3000;
33
34Ubidots client(TOKEN);
35Adafruit_MMA8451
36 mma = Adafruit_MMA8451();
37
38void setup() {
39 Serial.begin(9600);
40
41
42 if (! mma.begin()) {
43 Serial.println("Couldnt start");
44 while
45 (1);
46 }
47
48 mma.setRange(MMA8451_RANGE_8_G);
49
50 Serial.println("MMA8451
51 found!");
52 while (status != WL_CONNECTED) {
53 Serial.print("Attempting
54 to connect to SSID: ");
55 Serial.println(ssid);
56 status = WiFi.begin(ssid,
57 pass);
58
59 delay(10000);
60
61 }
62}
63
64void loop() {
65 mma.read();
66 sensors_event_t event;
67
68 mma.getEvent(&event);
69
70 if needed
71
77 client.add(ID,event.acceleration.z);
78
79 client.sendAll();
80
81 if(event.acceleration.z
82 > 10.0){
83 tone(8,freq,time);
84 }
85 delay(1000);
86
87}
88