This program connects to a few sensors via I2C and sends the data collected to a WNC Cellular Module which is located on an Avnet WNC-Shield card.

Dependencies:   FXOS8700CQ MODSERIAL mbed

/media/uploads/kevinkeryk/avnet_logo_tagline_rgb.png

Avnet Cellular IoT Instructions

  • One problematic area is setting the MY_SERVER_URL. When you copy the URL from the flow, you must make sure the MY_SERVER_URL is also set to the appropriate server. It can be either "run-east.att.io" or "run-west.att.io".

Useful Links

Adding Additional Sensors

The FLOW_DEVICE_NAME field must contain the name of the instance of the Virtual Starter Kit in FLOW you will be communicating with. Usually this is "vstarterkit001", but if you have problems communicating you can verify this is correct. Note: This device will not be created until you click the “Initialize” input on the Virtual Device tab of the Starter Kit project in FLOW. At that point, it becomes available in M2X and you can see it as the DEVICE SERIAL field under Devices as in the image below. /media/uploads/JMF/vstarterkit.png

Sensors: When executing, the FRDM-K64F board uploads sensor measurements to AT&T’s Flow environment every 5 seconds, using the Cellular shield board. You can adjust how often you want to do this by editing the SENSOR_UPDATE_INTERVAL_MS value in the header file.

Temperature and humidity: By default, the board reports readings from the HTS221 temperature and humidity sensor. These two values are sent to the HTTP IN /climate port in FLOW with field names “temp” and “humidity”. Temperature is in degrees Fahrenheit and humidity is a %. This default assignment is: iSensorsToReport = TEMP_HUMIDITY_ONLY;

Accelerometer: If you want to expand and use the onboard motion sensor, you can also send 3-axis accelerometer information from the board as “accelX”, “accelY”, and “accelZ”. This is useful if you want to know the stationary position of the board with regards to gravity, or whether it is in motion. These readings are in g’s. To send these values, change the assignment to: iSensorsToReport = TEMP_HUMIDITY_ACCELEROMETER;

PMOD Sensors: If you have a Silicon Labs sensor module that can plug into the PMOD connector on the Cellular shield, you are able to measure proximity, UV light, ambient visible and infrared light from the Si1145 sensor. This PMOD also has a temperature and humidity sensor, but in this case it is redundant. When enabled, the fields “proximity”, “light_uv”, “light_vis” and “light_ir” are also sent. To enable all these sensors, change the assignment to: iSensorsToReport = TEMP_HUMIDITY_ACCELEROMETER_PMODSENSORS;

Connecting the PMOD sensors: Because the pinouts do not align, the SiLabs PMOD sensor board cannot be plugged into the J10 PMOD receptacle on the shield directly. The following wiring instructions must be followed:

SignalJ10ShieldPMOD Color in the image below
VCCPin 6Pin 6Red
GNDPin 5Pin 5Black
SDAPin4Pin 3Green
SCLPin3Pin 2Yellow

/media/uploads/JMF/xyz.jpg

AT&T M2X and FLOW Instructions

M2X & FLOW Instructions

Link to AT&T M2X

M2X

Link to AT&T Flow

FLOW

Avnet WNC-Shield Information

Getting Started with the Avnet WNC-Shield Software

  • This project uses Revision 119 of the MBED library because of I2C implementation differences with the tip (Revision 121).
  • This project uses Revision 4 of the FXOS8700CQ library for sensors.

Easily Modifiable Parameters

Inside the mbed Avnet_ATT_Cellular_IOT project, the parameters needed to customize your board are in the config_me.h file.

  • FLOW parameters: This project assumes you are using a fork of the Starter Kit Base project, which is a reference design created using AT&T’s FLOW (https://flow.att.com) that allows the creation of online virtualization and other IoT functionality. The default parameters in the config_me.h file are done for a specific instance of this project. When you fork the original project, you get your own instance and it will have its own base address. At the bottom of the FLOW environment, when you click on the Endpoints tab, URL information that is specific to your instance is displayed. Of note is the Base URL. In the example below (as in the default mbed project), the Base URL is: https://run-west.att.io/1e464b19cdcde/774c88d68202/86694923d5bf28a/in/flow You have to take note of two parts of this address. The run-west.att.io part is the server URL, and you have to make sure the
  • MY_SERVER_URL field in config_me.h matches this. The rest of the base URL, in green above, needs to be pasted into the FLOW_BASE_URL field.

There is also a FLOW_INPUT_NAME field. This should match the name of the HTTP IN port in the FLOW project that you want to send sensor data to. The default is "/climate", as in the FLOW image below.

/media/uploads/JMF/sf.png

Where is the Binary I compiled

When the COMPILE button is pressed, it compiles your project and links it. The result is placed in the DOWNLOAD folder you use when downloading files from the Internet. It will be called AvnetATT_shape_hackathon_K64F.bin.

Additional Information on Compiling/Configuring

Comprehensive instructions can be found at: Quick Start Instructions

Revision:
67:11db02bb93e1
Parent:
66:b2425419b0cc
Child:
68:6e311c747045
--- a/wnc_control.cpp	Thu Aug 04 05:48:20 2016 +0000
+++ b/wnc_control.cpp	Thu Aug 04 16:24:13 2016 +0000
@@ -35,13 +35,13 @@
  // Temp put here to fix new boards needing init,
  //  the check for on the cellular network was preventing the PDNSET from happening!!!!
  {  
-    pc.puts("SET APN STRING!\r\n");
+    PUTS("SET APN STRING!\r\n");
     string * pRespStr;
     string cmd_str("AT%PDNSET=1,");
     cmd_str += MY_APN_STR;
     cmd_str += ",IP";
     at_send_wnc_cmd(cmd_str.c_str(), &pRespStr, 4*WNC_TIMEOUT_MS); // Set APN, cmd seems to take a little longer sometimes
-    pc.puts(cmd_str.c_str());
+    PUTS(cmd_str.c_str());
  }   
 
   static bool reportStatus = true;
@@ -51,7 +51,7 @@
       {
           if (reportStatus == false)
           {
-              puts("Re-connected to cellular network!\n\r");
+              PUTS("Re-connected to cellular network!\n\r");
               reportStatus = true;
           }
     
@@ -71,12 +71,12 @@
       {
           if (reportStatus == true)
           {
-               puts("Not connected to cellular network!\n\r");
+               PUTS("Not connected to cellular network!\n\r");
                reportStatus = false;
           }
      // Atempt to re-register
 //     string * pRespStr;
-//     pc.puts("Force re-register!\r\n");
+//     PUTS("Force re-register!\r\n");
 //     at_send_wnc_cmd("AT+CFUN=0,0", &pRespStr, WNC_TIMEOUT_MS);
 //     wait_ms(31000);
 //     at_send_wnc_cmd("AT+CFUN=1,0", &pRespStr, WNC_TIMEOUT_MS);
@@ -98,7 +98,7 @@
       }
       else if (WNC_MDM_ERR == WNC_CMD_ERR)
       {
-        pc.puts("Bad URL!!!!!!\r\n");
+        PUTS("Bad URL!!!!!!\r\n");
       }
     } while (WNC_MDM_ERR != WNC_OK);
     
@@ -116,7 +116,7 @@
         software_init_mdm();
       }
       else if (WNC_MDM_ERR == WNC_CMD_ERR)
-        pc.puts("Socket open fail!!!!\r\n");
+        PUTS("Socket open fail!!!!\r\n");
       else
         socketOpen = 1;
     } while (WNC_MDM_ERR != WNC_OK);
@@ -132,18 +132,18 @@
       at_sockwrite_wnc(s);
       if (WNC_MDM_ERR == WNC_NO_RESPONSE)
       {
-        pc.puts("Sock write no response!\r\n");
+        PUTS("Sock write no response!\r\n");
         software_init_mdm();
       }
       else if (WNC_MDM_ERR == WNC_CMD_ERR)
       {
-        pc.puts("Socket Write fail!!!\r\n");
+        PUTS("Socket Write fail!!!\r\n");
         software_init_mdm();
       }
     } while (WNC_MDM_ERR != WNC_OK);
     }
     else
-      puts("Socket is closed for write!\r\n");
+      PUTS("Socket is closed for write!\r\n");
 }
 
 unsigned sockread_mdm(string * sockData, int len, int retries)
@@ -161,15 +161,15 @@
         if (n == 0)
             software_init_mdm();
         else
-            puts("Sock read partial data!!!\r\n");
+            PUTS("Sock read partial data!!!\r\n");
       }
       else if (WNC_MDM_ERR == WNC_CMD_ERR)
-        puts("Sock read fail!!!!\r\n");
+        PUTS("Sock read fail!!!!\r\n");
     } while (WNC_MDM_ERR == WNC_NO_RESPONSE);
     }
     else
     {
-      puts("Socket is closed for read\r\n");
+      PUTS("Socket is closed for read\r\n");
       sockData->erase();
     }
       
@@ -191,7 +191,7 @@
         software_init_mdm();
       }
       else if (WNC_MDM_ERR == WNC_CMD_ERR)
-        puts("Sock close fail!!!\r\n");
+        PUTS("Sock close fail!!!\r\n");
     } while (WNC_MDM_ERR != WNC_OK);
 }
 
@@ -242,7 +242,7 @@
     int cmdRes1, cmdRes2;
 
 #ifdef WNC_CMD_DEBUG_ON_VERBOSE
-    pc.puts("<-------- Begin Cell Status ------------\r\n");
+    PUTS("<-------- Begin Cell Status ------------\r\n");
 #endif
     cmdRes1 = at_send_wnc_cmd("AT+CSQ", &pRespStr, WNC_TIMEOUT_MS);       // Check RSSI,BER
     cmdRes2 = at_send_wnc_cmd("AT+CPIN?", &pRespStr, WNC_TIMEOUT_MS);      // Check if SIM locked
@@ -250,7 +250,7 @@
     if ((cmdRes1 != 0) && (cmdRes2 != 0))
     {
 #ifdef WNC_CMD_DEBUG_ON_VERBOSE
-        pc.puts("------------ WNC No Response! --------->\r\n");
+        PUTS("------------ WNC No Response! --------->\r\n");
 #endif
         return (-2);      
     }
@@ -259,7 +259,7 @@
     if (pRespStr->find("CPIN: READY") == string::npos)
     {
 #ifdef WNC_CMD_DEBUG_ON_VERBOSE
-        pc.puts("------------ WNC SIM Problem! --------->\r\n");
+        PUTS("------------ WNC SIM Problem! --------->\r\n");
 #endif
         return (-1);
     }
@@ -276,14 +276,14 @@
         if ((regSts != 1) && (regSts != 5))
         {
 #ifdef WNC_CMD_DEBUG_ON_VERBOSE
-            pc.puts("------------ WNC Cell Link Down! ------>\r\n");
+            PUTS("------------ WNC Cell Link Down! ------>\r\n");
 #endif
             return (-2);
         }
     }
 
 #ifdef WNC_CMD_DEBUG_ON_VERBOSE
-    pc.puts("------------ WNC Ready ---------------->\r\n");
+    PUTS("------------ WNC Ready ---------------->\r\n");
 #endif
   
     return (0);
@@ -299,16 +299,16 @@
      static string noRespStr;
 
 #ifdef WNC_CMD_DEBUG_ON
-     pc.puts("FAIL send cmd: ");
+     PUTS("FAIL send cmd: ");
      #ifdef WNC_CMD_DEBUG_ON_VERBOSE
-     pc.puts(s);
+     PUTS(s);
      #else
      string truncStr(s, 50);
      truncStr += "\r\n";
-     pc.puts(truncStr.c_str());
+     PUTS(truncStr.c_str());
      #endif
 #else
-     pc.puts("FAIL send cmd!\r\n");
+     PUTS("FAIL send cmd!\r\n");
 #endif
 
      WNC_MDM_ERR = WNC_CELL_LINK_DOWN;
@@ -319,12 +319,12 @@
 
 #ifdef WNC_CMD_DEBUG_ON
   #ifdef WNC_CMD_DEBUG_ON_VERBOSE
-  pc.puts("[---------- Network Status -------------\r\n");
+  PUTS("[---------- Network Status -------------\r\n");
   #endif
   string * pRespStr;
   at_send_wnc_cmd("AT@SOCKDIAL?", &pRespStr, 5000);
   #ifdef WNC_CMD_DEBUG_ON_VERBOSE
-  pc.puts("---------------------------------------]\r\n");
+  PUTS("---------------------------------------]\r\n");
   #endif
 #endif
 
@@ -370,19 +370,19 @@
   {
 
 #ifdef WNC_CMD_DEBUG_ON   
-      pc.puts("[");
+      PUTS("[");
       #ifdef WNC_CMD_DEBUG_ON_VERBOSE
-      pc.puts(wncStr.c_str());
-      pc.puts("]\r\n");
+      PUTS(wncStr.c_str());
+      PUTS("]\r\n");
       #else
       if (wncStr.size() < 51)
-          pc.puts(wncStr.c_str());
+          PUTS(wncStr.c_str());
       else
       {
           string truncStr = wncStr.substr(0,50) + "...";
-          pc.puts(truncStr.c_str());
+          PUTS(truncStr.c_str());
       }
-      pc.puts("]\r\n");
+      PUTS("]\r\n");
       #endif
 #endif
 
@@ -393,7 +393,7 @@
   }
   else
   {
-      pc.puts("No response from WNC!\n\r");
+      PUTS("No response from WNC!\n\r");
       return -2;
   }
 }
@@ -415,13 +415,13 @@
   
   if (hardReset == true)
   {
-      pc.puts("Hard Reset!\r\n");
+      PUTS("Hard Reset!\r\n");
       pdnSet = false;
       intSet = false;
       sockDialSet = false;
   }
   
-  pc.puts("Start AT init of WNC:\r\n");
+  PUTS("Start AT init of WNC:\r\n");
   // Quick commands below do not need to check cellular connectivity
   cmdRes = at_send_wnc_cmd("AT", &pRespStr, WNC_TIMEOUT_MS);             // Heartbeat?
   cmdRes += at_send_wnc_cmd("ATE0", &pRespStr, WNC_TIMEOUT_MS);           // Echo Off
@@ -467,7 +467,7 @@
   else
     return ;
   
-  pc.puts("SUCCESS: AT init of WNC!\r\n");
+  PUTS("SUCCESS: AT init of WNC!\r\n");
 }
 
 void at_sockopen_wnc(const string & ipStr, const char * port )
@@ -506,13 +506,13 @@
           return 1;
         }
         else
-          pc.puts("URL Resolve fail, substr Err\r\n");
+          PUTS("URL Resolve fail, substr Err\r\n");
     }
     else
-      pc.puts("URL Resolve fail, no quotes\r\n");
+      PUTS("URL Resolve fail, no quotes\r\n");
   }
   else
-    pc.puts("URL Resolve fail, WNC cmd fail\r\n");
+    PUTS("URL Resolve fail, WNC cmd fail\r\n");
   
   *ipStr = "192.168.0.1";
   
@@ -546,7 +546,7 @@
     send_wnc_cmd(cmd_str.c_str(), &pRespStr, 120000);
   }
   else
-    pc.puts("sockwrite Err, string to long\r\n");
+    PUTS("sockwrite Err, string to long\r\n");
 }
 
 unsigned at_sockread_wnc(string * pS, unsigned n, unsigned retries = 0)
@@ -599,7 +599,7 @@
     }
   }
   else
-    pc.puts("sockread Err, to many to read\r\n");
+    PUTS("sockread Err, to many to read\r\n");
   
   return (numBytes);
 }