20170825 Test

Dependencies:   DHT11 NetworkSocketAPI WizFi310Interface mbed

Fork of WizFi310_STATION_HelloWorld by WIZnet

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002  * Copyright (C) 2015 Wiznet, MIT License
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00005  * and associated documentation files (the "Software"), to deal in the Software without restriction,
00006  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00007  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00008  * furnished to do so, subject to the following conditions:
00009  *
00010  * The above copyright notice and this permission notice shall be included in all copies or
00011  * substantial portions of the Software.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00014  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00015  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00016  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00017  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018  */
00019 
00020 #include <stdio.h>
00021 #include "mbed.h"
00022 #include "Dht11.h"
00023 #include "WizFi310Interface.h"
00024 
00025 #define DHT_SENSOR DHT_SENSOR
00026 
00027 #if defined(TARGET_WIZwiki_W7500)
00028 Serial pc(USBTX, USBRX);
00029 WizFi310Interface wifi(D1, D0, D7, D6, D9, NC, 115200);
00030 
00031 Dht11 myTemp  ( DHT_SENSOR );
00032 #endif
00033 
00034 int main()
00035 {
00036     int error = 0;
00037     char str[50] = "";
00038         
00039     pc.baud(115200);
00040  
00041     printf("WizFi310 Shield Test. \r\n");
00042 
00043     while(true)
00044     {
00045         error = myTemp.read();
00046         if( error != 0 )
00047         {
00048             printf("Connection failed\r\n\r\n");
00049             break;
00050         }
00051                    
00052         sprintf((char *)str, "{\"temp value\": %.1lf(c), \"humidity value\": %d(%%)}"
00053                 ,(double)(myTemp.getCelsius()), myTemp.getHumidity());
00054                 
00055         printf("%s\r\n\r\n", str);
00056         
00057         wait_ms(5000);
00058     }
00059 }