20170825 Test

Dependencies:   DHT11 NetworkSocketAPI WizFi310Interface mbed

Fork of WizFi310_STATION_HelloWorld by WIZnet

Files at this revision

API Documentation at this revision

Comitter:
cliff1
Date:
Thu Aug 24 23:30:40 2017 +0000
Parent:
2:a4fe5b857755
Child:
4:44aab68826b5
Commit message:
20170825 WizFi310 Sensor Test

Changed in this revision

DHT11.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DHT11.lib	Thu Aug 24 23:30:40 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/cliff1/code/DHT11/#282ebbb6d78d
--- a/main.cpp	Tue Apr 11 03:57:48 2017 +0000
+++ b/main.cpp	Thu Aug 24 23:30:40 2017 +0000
@@ -19,31 +19,46 @@
 
 #include <stdio.h>
 #include "mbed.h"
+#include "Dht11.h"
 #include "WizFi310Interface.h"
 
-
-//#define AP_SSID "<SSID>" // Input SSID
-//#define AP_PASSWORD "<PW>" // Input PW
-#define AP_SECURITY NSAPI_SECURITY_WPA2
+#define CDS_SENSOR CDS_SENSOR
+#define DHT_SENSOR DHT_SENSOR
 
 #if defined(TARGET_WIZwiki_W7500)
 Serial pc(USBTX, USBRX);
 WizFi310Interface wifi(D1, D0, D7, D6, D9, NC, 115200);
+
+AnalogIn myLux( CDS_SENSOR );
+Dht11 myTemp  ( DHT_SENSOR );
 #endif
 
-
-/**
- *  \brief Hello World
- *  \param none
- *  \return int
- */
 int main()
 {
+    int error = 0;
+    char str[50] = "";
+        
     pc.baud(115200);
  
-    printf("WizFi310 Hello World demo. \r\n");
-    if ( wifi.connect(AP_SSID, AP_PASSWORD, AP_SECURITY))     return -1;
-    printf("IP Address is %s\r\n", wifi.get_ip_address());
-    
-    wifi.disconnect();
+    printf("WizFi310 Shield Test. \r\n");
+
+    while(true)
+    {
+        error = myTemp.read();
+        if( error != 0 )
+        {
+            printf("Connection failed\r\n\r\n");
+            break;
+        }
+        
+        sprintf((char *)str, "{\"lux value\": %d}", (int)(myLux.read()*1000));
+        printf("%s\r\n", str);
+            
+        sprintf((char *)str, "{\"temp value\": %.1lf, \"humidity value\": %d}"
+                ,(double)(myTemp.getFahrenheit()), myTemp.getHumidity());
+                
+        printf("%s\r\n\r\n", str);
+        
+        wait_ms(5000);
+    }
 }
\ No newline at end of file
--- a/mbed.bld	Tue Apr 11 03:57:48 2017 +0000
+++ b/mbed.bld	Thu Aug 24 23:30:40 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5
\ No newline at end of file
+https://mbed.org/users/mbed_official/code/mbed/builds/e2bfab296f20
\ No newline at end of file