This is a SLIP interface for the STM32F446RE Nucleo Board. It is designed to work specifically with the esp-link software for the ESP8266. The program is an example of a rest command.

Dependencies:   mbed DHT Matrix

Revision:
10:ae1d07ffddea
Parent:
9:bd7f083d55ad
Child:
11:0b6425f59e17
--- a/main.cpp	Wed Aug 17 21:14:04 2016 +0000
+++ b/main.cpp	Wed Aug 24 16:29:18 2016 +0000
@@ -2,6 +2,7 @@
  * Simple example to demo the STM-Client REST calls
  */
 #include "mbed.h"
+#include "DHT.h"
 
 #include <STMClient.h>
 #include <STMClientRest.h>
@@ -20,6 +21,9 @@
 DigitalOut led2(LED2);       
 DigitalOut LCD_D7(D7);
 
+//Initialize the sensors
+DHT DHTsensor(D4, DHT11);
+AnalogIn Lsensor(A2);
 // Initialize a connection to esp-link using the normal hardware serial port both for
 // SLIP and for debug messages.
 STMClient esp(&espSerial, &debugSerial);
@@ -32,13 +36,15 @@
 bool posted = false;
 bool ESPisAsleep = false;
 
+//in the future pass the wait time and the number of flashes per command
 void toggleLEDSuccess(){
+        
+    for(int ii =0; ii > 3; ii++){    
         led2 = 1;
-        wait(0.25);
+        wait(0.25);        
         led2 = 0;
         wait(0.25);
-        led2 = 1;
-        wait(0.25);
+    }
 }
         
 // Callback made from esp-link to notify of wifi status changes
@@ -135,7 +141,6 @@
     return result;
  }
 
-
 #define BUFLEN 100
 char response[BUFLEN];
 
@@ -178,19 +183,53 @@
     //this is where the calls to the sensor drivers should go.
     //ideally they will be blocking so they don't return a value and allow the program to move on until each
     //function is complete    
+    
+    int error = 0;
+    float l = 0.0f, h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f;
+    float lnow = 0.0f, lmax = 50.00, lmin = 20.00;
+    wait(2.0f);
+    error = DHTsensor.readData();
+    if (0 == error) {
+        //c   = sensor.ReadTemperature(CELCIUS);
+        f   = DHTsensor.ReadTemperature(FARENHEIT);
+        //k   = sensor.ReadTemperature(KELVIN);
+        h   = DHTsensor.ReadHumidity();
+        lnow = Lsensor.read()*100; //random_number(0, 99);
+        
+        if(lnow > lmax)
+        {
+            lmax = lnow;
+        }
+        if(lnow < lmin){
+            lmin = lnow;                
+        }
+        
+        l = (lnow - lmin)/(lmax-lmin);
+        
+        //dp  = sensor.CalcdewPoint(c, h);
+        //dpf = sensor.CalcdewPointFast(c, h);
+        debugSerial.printf("Temperature in Farenheit %2.2f\n\r", f);
+        debugSerial.printf("Humidity is %2.2f\n\r", h);
+    } else {
+        debugSerial.printf("Error: %d\n", error);
+    }
+    
+    
     debugSerial.printf("geting measurements...\n\r");
-    int Tint = random_number(65, 99);
-    int Lint = random_number(0, 99);
-    int Hint = random_number(20, 25);
+    //int Tint = random_number(65, 99);
+    
+    //int Hint = random_number(20, 25);
 
-    char T[2];
-    sprintf(T, "%d", Tint);
-    char L[2];
-    sprintf(L, "%d", Lint);
-    char H[2];
-    sprintf(H, "%d", Hint);
-    //debugSerial.printf("H: %s \n\r",H); //check to make sure the value is the same
-        
+    char T[5];
+    sprintf(T, "%2.2f", f);
+    char L[5];
+    sprintf(L, "%2.2f", l);
+    char H[5];
+    sprintf(H, "%2.2f", h);
+    debugSerial.printf("T: %s \n\r",T); //check to make sure the value is the same
+    debugSerial.printf("L: %s \n\r",L); //check to make sure the value is the same
+    debugSerial.printf("H: %s \n\r",H); //check to make sure the value is the same
+            
     /**make sure that the size of this array is consistent with the input string**/ 
     const char* body = "";    
     char output [62];