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
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
For more detail
main.cpp@5:c4c405bc6e6d, 2015-09-24 (annotated)
- Committer:
- MidnightCow
- Date:
- Thu Sep 24 01:02:46 2015 +0000
- Revision:
- 5:c4c405bc6e6d
- Parent:
- 2:78d9cbb888c9
Code refined.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MidnightCow | 0:58cf74f2fc63 | 1 | #include "mbed.h" |
MidnightCow | 0:58cf74f2fc63 | 2 | #include "EthernetInterface.h" |
MidnightCow | 0:58cf74f2fc63 | 3 | #include "DHT.h" |
MidnightCow | 0:58cf74f2fc63 | 4 | |
MidnightCow | 0:58cf74f2fc63 | 5 | #include "TCPSocketConnectionArdu.h" |
MidnightCow | 1:fa957f28633b | 6 | #include "ThingerMBedEthernet.h" |
MidnightCow | 1:fa957f28633b | 7 | #include "ThingerMBedClient.h" |
MidnightCow | 0:58cf74f2fc63 | 8 | |
MidnightCow | 0:58cf74f2fc63 | 9 | |
MidnightCow | 0:58cf74f2fc63 | 10 | /* ThingerIO Define */ |
MidnightCow | 0:58cf74f2fc63 | 11 | #define USERNAME "MidnightCow" |
MidnightCow | 0:58cf74f2fc63 | 12 | #define DEVICE_ID "WIZwiki_W7500_mbed_01" |
MidnightCow | 2:78d9cbb888c9 | 13 | #define DEVICE_CREDENTIAL "Your Access Key" |
MidnightCow | 0:58cf74f2fc63 | 14 | |
MidnightCow | 0:58cf74f2fc63 | 15 | /* YUROBOT SHILED1 PIN Define*/ |
MidnightCow | 0:58cf74f2fc63 | 16 | #define myLED1 D13 |
MidnightCow | 0:58cf74f2fc63 | 17 | #define myLED2 D12 |
MidnightCow | 0:58cf74f2fc63 | 18 | |
MidnightCow | 0:58cf74f2fc63 | 19 | #define myRLED D9 |
MidnightCow | 0:58cf74f2fc63 | 20 | #define myGLED D10 |
MidnightCow | 0:58cf74f2fc63 | 21 | #define myBLED D11 |
MidnightCow | 0:58cf74f2fc63 | 22 | |
MidnightCow | 0:58cf74f2fc63 | 23 | #define myBUZZ D5 |
MidnightCow | 0:58cf74f2fc63 | 24 | |
MidnightCow | 0:58cf74f2fc63 | 25 | #define myTEMPHUMM D4 |
MidnightCow | 0:58cf74f2fc63 | 26 | |
MidnightCow | 0:58cf74f2fc63 | 27 | #define myLIGHT A1 |
MidnightCow | 0:58cf74f2fc63 | 28 | |
MidnightCow | 0:58cf74f2fc63 | 29 | //using namespace std; |
MidnightCow | 0:58cf74f2fc63 | 30 | DigitalOut myled1(myLED1); |
MidnightCow | 0:58cf74f2fc63 | 31 | DigitalOut myled2(myLED2); |
MidnightCow | 0:58cf74f2fc63 | 32 | |
MidnightCow | 0:58cf74f2fc63 | 33 | DigitalOut myrled(myRLED); |
MidnightCow | 0:58cf74f2fc63 | 34 | DigitalOut mygled(myGLED); |
MidnightCow | 0:58cf74f2fc63 | 35 | DigitalOut mybled(myBLED); |
MidnightCow | 1:fa957f28633b | 36 | DigitalOut myBuzz(myBUZZ); |
MidnightCow | 0:58cf74f2fc63 | 37 | |
MidnightCow | 0:58cf74f2fc63 | 38 | AnalogIn mylight(myLIGHT); |
MidnightCow | 0:58cf74f2fc63 | 39 | |
MidnightCow | 0:58cf74f2fc63 | 40 | DHT myTempHumm(myTEMPHUMM, DHT11); |
MidnightCow | 0:58cf74f2fc63 | 41 | |
MidnightCow | 0:58cf74f2fc63 | 42 | |
MidnightCow | 0:58cf74f2fc63 | 43 | |
MidnightCow | 1:fa957f28633b | 44 | void my_led1(pson& in) |
MidnightCow | 1:fa957f28633b | 45 | { |
MidnightCow | 1:fa957f28633b | 46 | myled1 = (in) ? 1 : 0; |
MidnightCow | 1:fa957f28633b | 47 | } |
MidnightCow | 1:fa957f28633b | 48 | |
MidnightCow | 1:fa957f28633b | 49 | void my_led2(pson& in) |
MidnightCow | 1:fa957f28633b | 50 | { |
MidnightCow | 1:fa957f28633b | 51 | myled2 = (in) ? 1 : 0; |
MidnightCow | 1:fa957f28633b | 52 | } |
MidnightCow | 0:58cf74f2fc63 | 53 | |
MidnightCow | 1:fa957f28633b | 54 | void my_TempHumm(pson& out) |
MidnightCow | 1:fa957f28633b | 55 | { |
MidnightCow | 1:fa957f28633b | 56 | if(myTempHumm.readData() == 0) |
MidnightCow | 1:fa957f28633b | 57 | { |
MidnightCow | 1:fa957f28633b | 58 | out["Cecelcius"] = myTempHumm.ReadTemperature(CELCIUS); |
MidnightCow | 1:fa957f28633b | 59 | out["Humidity"] = myTempHumm.ReadHumidity(); |
MidnightCow | 1:fa957f28633b | 60 | } |
MidnightCow | 1:fa957f28633b | 61 | else |
MidnightCow | 1:fa957f28633b | 62 | { |
MidnightCow | 1:fa957f28633b | 63 | out["Cecelcius"] = 65535; |
MidnightCow | 1:fa957f28633b | 64 | out["Humidity"] = 65535; |
MidnightCow | 1:fa957f28633b | 65 | } |
MidnightCow | 1:fa957f28633b | 66 | } |
MidnightCow | 0:58cf74f2fc63 | 67 | |
MidnightCow | 1:fa957f28633b | 68 | /* |
MidnightCow | 1:fa957f28633b | 69 | void my_rgbled(pson& in) |
MidnightCow | 1:fa957f28633b | 70 | { |
MidnightCow | 1:fa957f28633b | 71 | myrled = (in["Red"]) ? 1 : 0; |
MidnightCow | 1:fa957f28633b | 72 | mygled = (in["Green"]) ? 1 : 0; |
MidnightCow | 1:fa957f28633b | 73 | mybled = (in["Blue"]) ? 1 : 0; |
MidnightCow | 0:58cf74f2fc63 | 74 | } |
MidnightCow | 1:fa957f28633b | 75 | */ |
MidnightCow | 0:58cf74f2fc63 | 76 | |
MidnightCow | 0:58cf74f2fc63 | 77 | |
MidnightCow | 0:58cf74f2fc63 | 78 | int main() { |
MidnightCow | 1:fa957f28633b | 79 | |
MidnightCow | 1:fa957f28633b | 80 | EthernetInterface eth; |
MidnightCow | 1:fa957f28633b | 81 | |
MidnightCow | 1:fa957f28633b | 82 | ThingerEthernet thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); |
MidnightCow | 1:fa957f28633b | 83 | |
MidnightCow | 1:fa957f28633b | 84 | myled1 = 1; |
MidnightCow | 1:fa957f28633b | 85 | myled2 = 1; |
MidnightCow | 0:58cf74f2fc63 | 86 | |
MidnightCow | 1:fa957f28633b | 87 | // resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc) |
MidnightCow | 1:fa957f28633b | 88 | thing["myled1"] << my_led1; |
MidnightCow | 1:fa957f28633b | 89 | thing["myled2"] << my_led2; |
MidnightCow | 1:fa957f28633b | 90 | thing["mySensor"] >> my_TempHumm; |
MidnightCow | 1:fa957f28633b | 91 | //thing["myRGB"] << my_rgbled; |
MidnightCow | 1:fa957f28633b | 92 | |
MidnightCow | 1:fa957f28633b | 93 | while(1) |
MidnightCow | 1:fa957f28633b | 94 | { |
MidnightCow | 0:58cf74f2fc63 | 95 | thing.handle(); |
MidnightCow | 0:58cf74f2fc63 | 96 | } |
MidnightCow | 0:58cf74f2fc63 | 97 | } |