AT&T M2X example featuring FRDM-K64F and Seed Grove Wifi to stream the Accelerometer X, Y, Z-axis values
Dependencies: ESP8266Interface FXOS8700Q M2XStreamClient jsonlite mbed
Fork of frdm-k64F_Wifi_M2X_Acc by
Revision 5:2f6125e8ee48, committed 2016-10-17
- Comitter:
- GregC
- Date:
- Mon Oct 17 21:07:48 2016 +0000
- Parent:
- 4:3c1d712dcc48
- Child:
- 6:ec30a917efa8
- Commit message:
- AT&T M2X example featuring FRDM-K64F and Seed Grove Wifi to stream the Accelerometer X, Y, Z-axis values
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Dec 11 00:25:01 2015 +0000 +++ b/main.cpp Mon Oct 17 21:07:48 2016 +0000 @@ -13,14 +13,14 @@ #define min(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; }) #endif -char deviceId[] = "<device id>"; // Device you want to push to -char streamName[] = "<stream name>"; // Stream you want to push to -char m2xKey[] = "<m2x api key>"; // Your M2X API Key or Master API Key +char deviceId[] = "<deviceId>"; // Device you want to push to +char streamName[] = "<streamName>"; // Stream you want to push to +char m2xKey[] = "<m2xKey>"; // Your M2X API Key or Master API Key /* * ESP8266 Wifi Config, connect it to D0 on Seeed Grove shield */ -ESP8266Interface wifi(D1,D0,D3,"wifi-name","wifi-password",115200); // TX,RX,Reset,SSID,Password,Baud +ESP8266Interface wifi(D1,D0,D3,"iPhone6S","12051978",115200); // TX,RX,Reset,SSID,Password,Baud int main() { @@ -50,18 +50,11 @@ 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 + // Send data to stream - ret = m2xClient.updateStreamValue(deviceId, streamName, maxTilt); + ret = m2xClient.updateStreamValue(deviceId, streamName, x); + ret = m2xClient.updateStreamValue(deviceId, streamName, y); + ret = m2xClient.updateStreamValue(deviceId, streamName, z); printf("send() returned %d\r\n", ret); wait(1.0);