Thinger IO Cloude Service Test Example with WIZwiki-W7500

Dependencies:   DHT WIZnetInterface mbed-src

Smart WIZwiki_W7500 IoT platform with the Open source IoT Cloud server thinger.io

http://wiznetmuseum.com/wp/wp-content/uploads/2015/09/WIZwiki_W7500_thingerio.png

Overview

This project is based on mbed WIZwiki-W7500 platform launced by WIZnet. WIZwiki-W7500 can connect to the smart IoT cloud server called thinger.io.

Demos

Video

For more detail

http://midnightcow.tistory.com/entry/mbed-WIZwikiW7500-platform-with-Smart-IoT-Cloud-Server-Thingerio

Revision:
1:fa957f28633b
Parent:
0:58cf74f2fc63
Child:
2:78d9cbb888c9
--- a/main.cpp	Mon Sep 21 07:27:24 2015 +0000
+++ b/main.cpp	Tue Sep 22 20:56:57 2015 +0000
@@ -3,8 +3,8 @@
 #include "DHT.h"
 
 #include "TCPSocketConnectionArdu.h"
-#include "ThingerEthernet.h"
-#include "ThingerClient.h"
+#include "ThingerMBedEthernet.h"
+#include "ThingerMBedClient.h"
 
 
 /* ThingerIO Define */
@@ -33,69 +33,65 @@
 DigitalOut myrled(myRLED);
 DigitalOut mygled(myGLED);
 DigitalOut mybled(myBLED);
+DigitalOut myBuzz(myBUZZ);
 
 AnalogIn   mylight(myLIGHT);
 
 DHT myTempHumm(myTEMPHUMM, DHT11);
 
 
-ThingerEthernet thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
 
-void setup() {
-    // resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
-    thing["myled1"] << [](pson& in){ myled1 = (in) ? 0 : 1; };
+void my_led1(pson& in)
+{
+    myled1 = (in) ? 1 : 0;
+}
+
+void my_led2(pson& in)
+{
+    myled2 = (in) ? 1 : 0;
+}
 
-    // resource output example (i.e. reading a sensor value)
-//    thing["millis"] >> [](pson& out){ out = millis(); };
+void my_TempHumm(pson& out)
+{
+    if(myTempHumm.readData() == 0)
+    {
+        out["Cecelcius"] = myTempHumm.ReadTemperature(CELCIUS);
+        out["Humidity"]  = myTempHumm.ReadHumidity();        
+    }
+    else
+    {
+        out["Cecelcius"] = 65535;
+        out["Humidity"]  = 65535;
+    }
+}
 
-    // resource input/output example (i.e. passing input values and do some calculations)
-//   thing["in_out"] = [](pson& in, pson& out){
-//      out["sum"] = (long)in["value1"] + (long)in["value2"];
-//      out["mult"] = (long)in["value1"] * (long)in["value2"];
-//    };
+/*
+void my_rgbled(pson& in)
+{
+    myrled = (in["Red"])   ?  1 : 0;
+    mygled = (in["Green"]) ?  1 : 0;
+    mybled = (in["Blue"])  ?  1 : 0;    
 }
+*/
 
 
 int main() {
-    int err;
-    while(1) {
-        myled1 = 1;
-        wait(0.2);
-        myled1 = 0;
-        wait(0.2);
-        myled2 = 1;
-        wait(0.2);
-        myled2 = 0;
-        wait(0.2);
-        myrled = 0;
-        mygled = 0;
-        mybled = 0;
-        wait(0.5);
-        myrled = 0;
-        mygled = 1;
-        mybled = 1;
-        wait(0.5);
-        myrled = 1;
-        mygled = 0;
-        mybled = 1;
-        wait(0.5);
-        myrled = 1;
-        mygled = 1;
-        mybled = 0;
-        wait(0.5);
+
+    EthernetInterface eth;
+
+    ThingerEthernet thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
+
+    myled1 = 1;
+    myled2 = 1;
 
-        err = myTempHumm.readData();
-        if (err == 0) {
-            printf("Temperature is %4.2f C \r\n", myTempHumm.ReadTemperature(CELCIUS));
-            printf("Temperature is %4.2f F \r\n", myTempHumm.ReadTemperature(FARENHEIT));
-            printf("Humidity is %4.f % \r\n", myTempHumm.ReadHumidity());
-            printf("Dew point is %4.2f  \r\n",myTempHumm.CalcdewPoint(myTempHumm.ReadTemperature(CELCIUS), myTempHumm.ReadHumidity()));
-            printf("Dew point (fast) is %4.2f  \r\n\n",myTempHumm.CalcdewPointFast(myTempHumm.ReadTemperature(CELCIUS), myTempHumm.ReadHumidity()));
-        }
-        else {
-            printf("\r\nErr %i \n", err);    
-        }
-        wait(1);
+    // resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
+    thing["myled1"] << my_led1;
+    thing["myled2"] << my_led2;
+    thing["mySensor"] >> my_TempHumm;
+    //thing["myRGB"] << my_rgbled;
+    
+    while(1)
+    {
         thing.handle();
     }
 }