Use the STM32F411 Nucleo Board, Nucleo Sensor Shield, WIZnet5500 Ethernet to upload temperature data to M2X

Dependencies:   M2XStreamClient Nucleo_Sensor_Shield WIZnet_Library jsonlite mbed

Fork of M2X_Nucleo411_ESP8266-wifi by AT&T Developer Summit Hackathon 2016

Files at this revision

API Documentation at this revision

Comitter:
mbedAustin
Date:
Fri Dec 11 00:37:37 2015 +0000
Parent:
4:3c1d712dcc48
Child:
6:694279899cf2
Commit message:
changed settings for Nucleo 411 board

Changed in this revision

FXOS8700Q.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/FXOS8700Q.lib	Fri Dec 11 00:25:01 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/JimCarver/code/FXOS8700Q/#5553a64d0762
--- a/main.cpp	Fri Dec 11 00:25:01 2015 +0000
+++ b/main.cpp	Fri Dec 11 00:37:37 2015 +0000
@@ -1,26 +1,19 @@
 #include "mbed.h"
-#include "FXOS8700Q.h"
 #include "M2XStreamClient.h"
 #include "ESP8266Interface.h"
 #include "TCPSocketConnection.h"
 
-
-#ifndef MAX
-#define max(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
-#endif
-
-#ifndef MIN
-#define min(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
-#endif
-
+//
+// Fill these field in from you ATT M2X Account
+//
 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
 
 /*
-*  ESP8266 Wifi Config, connect it to D0 on Seeed Grove shield
+*  ESP8266 Wifi Config for nucleo 411
 */
-ESP8266Interface wifi(D1,D0,D3,"wifi-name","wifi-password",115200); // TX,RX,Reset,SSID,Password,Baud 
+ESP8266Interface wifi(D8,D2,D3,"wifi-name","wifi-password",115200); // TX,RX,Reset,SSID,Password,Baud 
 
 int main()
 {
@@ -33,37 +26,16 @@
 
     // Initialize the M2X client
     Client client;
-    M2XStreamClient m2xClient(&client, m2xKey,1,"52.22.150.98");
+    M2XStreamClient m2xClient(&client, m2xKey,1,"52.22.150.98"); // api-m2x.att.com
+    
     int ret;
-
-    // Create an accelerometer instance
-    FXOS8700Q_acc acc( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // Proper Ports and I2C Address for K64F Freedom board
-    acc.enable();
-    printf("\r\n\nFXOS8700Q Who Am I= %X\r\n", acc.whoAmI());
+    volatile int randomNumber = 0;
 
     while (true) {
-
-        float x, y, z;
-        acc.getX(&x);
-        acc.getY(&y);
-        acc.getZ(&z);
-
-        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
-        
-            ret = m2xClient.updateStreamValue(deviceId, streamName, maxTilt);
-            printf("send() returned %d\r\n", ret);
-            wait(1.0);
-        
+        // send a random number to M2X every 5 seconds
+        randomNumber = rand();
+        ret = m2xClient.updateStreamValue(deviceId, streamName, randomNumber);
+        printf("send() returned %d\r\n", ret);
+        wait(5.0);
     }
 }
\ No newline at end of file