Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: M2XStreamClient MMA8451Q SocketModem jsonlite mbed
Fork of M2X_MTS_Accel by
Revision 2:93ca5135c262, committed 2014-08-21
- Comitter:
- mikeflores2000
- Date:
- Thu Aug 21 22:45:33 2014 +0000
- Parent:
- 1:f6254f28c89c
- Child:
- 3:3aa188afd648
- Commit message:
- version 1.0
Changed in this revision
--- a/M2XStreamClient.lib Wed Jul 16 16:17:03 2014 +0000 +++ b/M2XStreamClient.lib Thu Aug 21 22:45:33 2014 +0000 @@ -1,1 +1,1 @@ -https://mbed.org/teams/ATT-M2X-team/code/M2XStreamClient/#f479e4f4db0e +https://mbed.org/teams/ATT-M2X-team/code/M2XStreamClient/#4d7109bae9cf
--- a/SocketModem.lib Wed Jul 16 16:17:03 2014 +0000 +++ b/SocketModem.lib Thu Aug 21 22:45:33 2014 +0000 @@ -1,1 +1,1 @@ -https://mbed.org/teams/Multi-Hackers/code/SocketModem/#efc4db23a564 +https://mbed.org/teams/Multi-Hackers/code/SocketModem/#e0a437f61854
--- a/main.cpp Wed Jul 16 16:17:03 2014 +0000
+++ b/main.cpp Thu Aug 21 22:45:33 2014 +0000
@@ -18,17 +18,17 @@
using namespace mts;
-const char key[] = "<key>"; // Replace with your M2X user account master key
-const char feed[] = "<feed>"; // Replace with your blueprint feed ID
-const char stream[] = "<stream>"; // Replace with your stream name
+const char key[] = "7a453ac1769a6f027e20fa4460f3934a"; // Replace with your M2X user account master key
+const char feed[] = "c34e9db73edb0b171fa3e92bbad63d86"; // Replace with your blueprint feed ID
+const char stream[] = "tilt"; // Replace with your stream name
// set to 1 for cellular shield board
// set to 0 for wifi shield board
#define CELL_SHIELD 0
// ssid and phrase for wifi
-std::string ssid = "<ssid>"; // Replace with your Wifi ID (SSID)
-std::string phrase = "<password>"; // Replace with your Wifi phrase (password)
+std::string ssid = "DevLab"; // Replace with your Wifi ID (SSID)
+std::string phrase = "MultiTech"; // Replace with your Wifi phrase (password)
Wifi::SecurityType security_type = Wifi::WPA; // Replace with your Wifi security type
int main()
@@ -113,6 +113,23 @@
printf("MMA8451 ID: %d\n", acc.getWhoAmI());
// Add code here to read accelerometer data and post to M2X stream
- // ...
+ while (true) {
+// Get accelerometer data
+float x, y, z;
+x = acc.getAccX();
+y = acc.getAccY();
+z = acc.getAccZ();
+printf("Accel X: %1.2f, Y: %1.2f, Z: %1.2f\n\r", x, y, z);
+// Calculate pitch and roll. Find the maximum tilt angle. float pitch = atan(x / sqrt(y * y + z * z));
+float roll = atan(y / sqrt(x * x + z * z));
+float maxTilt =
+max(abs(roll), abs(pitch)) * 180.0 / 3.14159; printf("pitch: %5.1f roll: %5.1f maxTilt: %5.1f\n\r",
+pitch, roll, maxTilt);
+// If the maximum title is over 20 degrees, then send // data to stream
+if (maxTilt > 20) {
+ret = m2xClient.post(feed, stream, maxTilt);
+printf("send() returned %d\r\n", ret);
+wait(1);
+} }
}
\ No newline at end of file
--- a/mbed.bld Wed Jul 16 16:17:03 2014 +0000 +++ b/mbed.bld Thu Aug 21 22:45:33 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file
