This is RPC_HTTP Example for using WIZnetInterface

Dependencies:   HTTPServer WIZnetInterface mbed-rpc DHT mbed-src

I want to make example which can use mbed RPC library and Python interface so I made this project. This project is led controller and temperature/humidity checker with android application. In brief, This project has function as below.

  • Controlling tri-color led in the mbed platform ( On/Off )
  • Checking current led status ( It can check led color using TTS(Text to Speech) on Android)
  • Checking temperature and humidity information using Android

This example used mbed RPC library to control WIzwiki-W7500 board with Android and Android application is made using kivy library of Python.

https://farm1.staticflickr.com/470/20036515102_d298ed0b5f_o.png

Simple Application in Android

I explain how to make android application using kivy library of Python. This android application can control mbed device and get information from mbed device. For implementation and operation this application, you have to have step as below.

https://farm1.staticflickr.com/297/19891752250_3853ef53aa_z.jpg

Demo Video

For more detailed information, refer to this URL.

http://www.life4iot.com/2015/07/28/remote-temperaturehumidity-checker-led-controller-using-mbed-rpc/?lang=en

Revision:
1:cffa64d79a8b
Parent:
0:ca442200bc8a
--- a/main.cpp	Wed Jul 22 09:41:02 2015 +0000
+++ b/main.cpp	Thu Jul 30 02:31:11 2015 +0000
@@ -2,16 +2,44 @@
 #include "EthernetInterface.h"
 #include "HTTPServer.h"
 #include "mbed_rpc.h"
+#include "DHT.h"
+ 
+RpcDigitalOut led1(D9,"led1");
+RpcDigitalOut led2(D10,"led2");
+RpcDigitalOut led3(D11,"led3");
 
-RpcDigitalOut led1(LED1,"led1");
+//RPCVarialbe<float> RPCTemperature(&GetTemperature, "Temperature");
+//RPCVarialbe<float> RPCHumidity(&GetHumidity, "Humidity");
+void Get_Temp_and_Humidity(Arguments * input, Reply * output);
+
+RPCFunction Temp_and_Humidity_Finder(&Get_Temp_and_Humidity, "Temp_and_Humidity_Finder");
 
 EthernetInterface eth;  
 HTTPServer svr;
 
+DHT sensor(D4, DHT11);
+
+void Get_Temp_and_Humidity(Arguments * input, Reply *output){
+    int error = 0;
+    float h = 0.0f, c = 0.0f;
+    char arg[100];
+
+    error = sensor.readData();
+    if (0 == error) {
+        c   = sensor.ReadTemperature(CELCIUS);
+        h   = sensor.ReadHumidity();
+        sprintf(arg,"Temperature in Celcius: %4.2f, Humidity is %4.2f",c, h);
+    
+        output->putData(arg);
+    }
+}
+
 int main() {
   //Turn the LEDs off
-  uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x00, 0x00}; 
-  led1.write(1);
+  uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x32, 0x23, 0x42}; 
+  led1.write(0);
+  led2.write(0);
+  led3.write(0);
   
   RPC::add_rpc_class<RpcDigitalOut>();
 
@@ -23,13 +51,11 @@
     printf("Error %d in setup.\n", ethErr);
     return -1;
   }
-  
   svr.addHandler<HTTPRpcRequestHandler>("/rpc");
   
   //attach server to port 80
+  printf("Listening...\n");
   svr.start(80, &eth);
-  
-  printf("Listening...\n");
     
   Timer tm;
   tm.start();
@@ -42,4 +68,4 @@
       tm.start();
     }
   }
-}
\ No newline at end of file
+}