20170825 Test
Dependencies: DHT11 NetworkSocketAPI WizFi310Interface mbed
Fork of WizFi310_STATION_HelloWorld by
Diff: main.cpp
- Revision:
- 3:4e4f243253e1
- Parent:
- 2:a4fe5b857755
- Child:
- 4:44aab68826b5
diff -r a4fe5b857755 -r 4e4f243253e1 main.cpp --- 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