Bruce Yang / Mbed 2 deprecated Moko_mbed

Dependencies:   DigitDisplay EthernetInterface WebSocketClient mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
bruceyang
Date:
Sun May 03 06:19:47 2015 +0000
Commit message:
Temp,LED,Websocket

Changed in this revision

DigitDisplay.lib Show annotated file Show diff for this revision Revisions of this file
EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
WebSocketClient.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-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DigitDisplay.lib	Sun May 03 06:19:47 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/seeed/code/DigitDisplay/#d3173c8bfd48
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Sun May 03 06:19:47 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#2fc406e2553f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Sun May 03 06:19:47 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/WebSocketClient/#4567996414a5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun May 03 06:19:47 2015 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "Websocket.h"
+#include "DigitDisplay.h"
+
+DigitalOut myled(LED2);
+EthernetInterface eth;
+DigitDisplay display(P4_29, P4_28);
+AnalogIn ain(P0_23);
+
+int a;
+float temperature;
+int B=3975;                                                         //B value of the thermistor
+float resistance;
+
+int main()
+{
+    char data[256];
+    eth.init();
+    eth.connect();
+    Websocket ws("ws://wot.city/object/554588e158e328ae620000ab/send");
+    ws.connect();
+    while(1) {
+// multiply ain by 675 if the Grove shield is set to 5V or 1023 if set to 3.3V
+        a=ain*675;
+        resistance=(float)(1023-a)*10000/a;                         //get the resistance of the sensor;
+        temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;    //convert to temperature via datasheet ;
+        myled = 1;
+        wait(0.8);
+        myled = 0;
+        wait(0.8);
+        display.write(temperature);
+        sprintf( data , "{ \"temperature\": %f }",temperature);
+        ws.send(data);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Sun May 03 06:19:47 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#557d5b275f31
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun May 03 06:19:47 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8ab26030e058
\ No newline at end of file