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

Committer:
mbedAustin
Date:
Fri Dec 11 00:58:10 2015 +0000
Revision:
6:694279899cf2
Parent:
5:b3bcb048a5a5
Child:
7:72e29cb05e2b
made changes for Nucleo 411 with ESP8266

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jb8414 0:ece599ab76bb 1 #include "mbed.h"
jb8414 0:ece599ab76bb 2 #include "M2XStreamClient.h"
mbedAustin 3:694a1a67b156 3 #include "ESP8266Interface.h"
mbedAustin 3:694a1a67b156 4 #include "TCPSocketConnection.h"
jb8414 0:ece599ab76bb 5
jb8414 0:ece599ab76bb 6
mbedAustin 3:694a1a67b156 7 /*
mbedAustin 5:b3bcb048a5a5 8 * ESP8266 Wifi Config for nucleo 411
mbedAustin 3:694a1a67b156 9 */
mbedAustin 6:694279899cf2 10 ESP8266Interface wifi(D8,D2,D3,"wifiName","wifiPassword",115200); // TX,RX,Reset,SSID,Password,Baud
mbedAustin 6:694279899cf2 11
mbedAustin 6:694279899cf2 12 //
mbedAustin 6:694279899cf2 13 // Fill these field in from you ATT M2X Account
mbedAustin 6:694279899cf2 14 //
mbedAustin 6:694279899cf2 15 char deviceId[] = "<deviceID>"; // Device you want to push to
mbedAustin 6:694279899cf2 16 char streamName[] = "<streamID>"; // Stream you want to push to
mbedAustin 6:694279899cf2 17 char m2xKey[] = "<deviceAPIKey>"; // Your M2X API Key or Master API Key
mbedAustin 3:694a1a67b156 18
jb8414 0:ece599ab76bb 19 int main()
jb8414 0:ece599ab76bb 20 {
mbedAustin 3:694a1a67b156 21 printf("Starting...\r\n");
mbedAustin 3:694a1a67b156 22
mbedAustin 3:694a1a67b156 23 // connect to wifi
mbedAustin 3:694a1a67b156 24 wifi.init(); //Reset
mbedAustin 3:694a1a67b156 25 wifi.connect(); //Use DHCP
mbedAustin 3:694a1a67b156 26 printf("IP Address is %s \n\r", wifi.getIPAddress());
jb8414 0:ece599ab76bb 27
jb8414 0:ece599ab76bb 28 // Initialize the M2X client
jb8414 0:ece599ab76bb 29 Client client;
mbedAustin 5:b3bcb048a5a5 30 M2XStreamClient m2xClient(&client, m2xKey,1,"52.22.150.98"); // api-m2x.att.com
mbedAustin 5:b3bcb048a5a5 31
jb8414 0:ece599ab76bb 32 int ret;
mbedAustin 5:b3bcb048a5a5 33 volatile int randomNumber = 0;
jb8414 0:ece599ab76bb 34
jb8414 0:ece599ab76bb 35 while (true) {
mbedAustin 5:b3bcb048a5a5 36 // send a random number to M2X every 5 seconds
mbedAustin 5:b3bcb048a5a5 37 randomNumber = rand();
mbedAustin 5:b3bcb048a5a5 38 ret = m2xClient.updateStreamValue(deviceId, streamName, randomNumber);
mbedAustin 5:b3bcb048a5a5 39 printf("send() returned %d\r\n", ret);
mbedAustin 5:b3bcb048a5a5 40 wait(5.0);
jb8414 0:ece599ab76bb 41 }
jb8414 0:ece599ab76bb 42 }