MQTT on Wizwiki 7500 with DHT11 sensor example

Dependencies:   DHT MQTT WIZnetInterface mbed-src

Fork of w7500-paho-mqtt by Bohyun Bang

Files at this revision

API Documentation at this revision

Comitter:
jamesabruce
Date:
Sat Oct 03 10:54:52 2015 +0000
Parent:
11:226df68b1d50
Commit message:

Changed in this revision

MQTT.lib Show annotated file Show diff for this revision Revisions of this file
WIZnetInterface.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-src.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 226df68b1d50 -r 4f0489448955 MQTT.lib
--- a/MQTT.lib	Mon Jun 29 01:55:45 2015 +0000
+++ b/MQTT.lib	Sat Oct 03 10:54:52 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/bangbh/code/MQTT/#b7cebc104c6c
+https://developer.mbed.org/users/jamesabruce/code/MQTT/#d3feba7f242a
diff -r 226df68b1d50 -r 4f0489448955 WIZnetInterface.lib
--- a/WIZnetInterface.lib	Mon Jun 29 01:55:45 2015 +0000
+++ b/WIZnetInterface.lib	Sat Oct 03 10:54:52 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/#c830d2e7e0f5
+http://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/#bda61525ac71
diff -r 226df68b1d50 -r 4f0489448955 main.cpp
--- a/main.cpp	Mon Jun 29 01:55:45 2015 +0000
+++ b/main.cpp	Sat Oct 03 10:54:52 2015 +0000
@@ -2,10 +2,7 @@
 #include "DHT.h"
 #include "MQTTEthernet.h"
 #include "MQTTClient.h"
-
 #define ECHO_SERVER_PORT   7
-
-#include "mbed.h"
  
 int arrivedcount = 0;
  
@@ -25,15 +22,14 @@
 int main (void)
 {
     DHT sensor(D4, DHT11);
-    AnalogIn ain(A1);
     baud(115200);
     printf("Wait a second...\r\n");
-    char* topic = "hello/wiznet";
+    char* topic = "openhab/parents/command";
     MQTTEthernet ipstack = MQTTEthernet();
     
     MQTT::Client<MQTTEthernet, Countdown> client = MQTT::Client<MQTTEthernet, Countdown>(ipstack);
     
-    char* hostname = "104.199.146.45";
+    char* hostname = "192.168.1.99";
     int port = 1883;
     
     int rc = ipstack.connect(hostname, port);
@@ -44,9 +40,7 @@
     
     MQTTPacket_connectData data = MQTTPacket_connectData_initializer;       
     data.MQTTVersion = 3;
-    data.clientID.cstring = "WIZwiki-W7500";
-    data.username.cstring = "testuser";
-    data.password.cstring = "testpassword";  
+    data.clientID.cstring = "parents";
 
     if ((rc = client.connect(data)) != 0)
         printf("rc from MQTT connect is %d\n", rc);
@@ -70,17 +64,14 @@
         message.retained = false;
         message.dup = false;
         message.payload = (void*)buf;
-        message.payloadlen = strlen(buf)+1;
-        rc = client.publish("wiznet/hum", message);
+        message.payloadlen = strlen(buf);
+        rc = client.publish("openhab/parents/humidity", message);
         sprintf(buf, "%3.1f", temp);
         message.payload = (void*)buf;
-        message.payloadlen = strlen(buf)+1;
-        rc = client.publish("wiznet/temp", message);
-        sprintf(buf, "%3.1f", ain.read()*100.0f);
-        message.payload = (void*)buf;
-        message.payloadlen = strlen(buf)+1;
-        rc = client.publish("wiznet/cds", message);
-        client.yield(1000);
+        message.payloadlen = strlen(buf);
+        rc = client.publish("openhab/parents/temperature", message);
+        
+        client.yield(60000);
     }
 }
 
diff -r 226df68b1d50 -r 4f0489448955 mbed-src.lib
--- a/mbed-src.lib	Mon Jun 29 01:55:45 2015 +0000
+++ b/mbed-src.lib	Sat Oct 03 10:54:52 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-src/#30f9462b5296
+http://mbed.org/users/mbed_official/code/mbed-src/#2d5fc5624619