Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C12832_lcd EthernetInterface LM75B MMA7660 WebSocketClient mbed-rtos mbed
Revision 0:5f2b64d6ed81, committed 2014-06-09
- Comitter:
- thomas_sullivan
- Date:
- Mon Jun 09 22:54:42 2014 +0000
- Commit message:
- Displays analog input data in a browser using smoothie.js. Use similar to an oscilloscope for debugging or data output. Corresponding html and javascript code available.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/C12832_lcd.lib Mon Jun 09 22:54:42 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/atthackathon/code/C12832_lcd/#3e64ca073642
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Mon Jun 09 22:54:42 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/EthernetInterface/#f6ec7a025939
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LM75B.lib Mon Jun 09 22:54:42 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/neilt6/code/LM75B/#3a44310726fe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA7660.lib Mon Jun 09 22:54:42 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/MMA7660/#a8e20db7901e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NTPClient.lib Mon Jun 09 22:54:42 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/WiredHome/code/NTPClient/#dadd90fba4ea
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebSocketClient.lib Mon Jun 09 22:54:42 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/samux/code/WebSocketClient/#466f90b7849a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Jun 09 22:54:42 2014 +0000
@@ -0,0 +1,92 @@
+//IOT Class Project. June 9, 2014. Tom Sullivan
+
+#include "mbed.h"
+#include "LM75B.h"
+#include "C12832_lcd.h"
+#include "EthernetInterface.h"
+#include "NTPClient.h"
+#include "MMA7660.h"
+#include "Websocket.h"
+
+C12832_LCD lcd;
+DigitalOut led1(LED1);
+MMA7660 MMA(p28, p27);
+AnalogIn pot20(p20);
+AnalogIn pot19(p19);
+AnalogIn ain17(p17);
+AnalogOut aout18(p18);
+BusIn joy(p15,p12,p13,p16); //DigitalIn joyUp(p15), joyDown(p12), joyLeft(p13), joyRight(p16);
+
+Ticker myTicker1;
+EthernetInterface eth;
+NTPClient ntp;
+time_t currentTime;
+char dataOut[128];
+
+//Temperature variables
+LM75B tmp(p28,p27);
+float tempNow, tempHI=80,tempLO=60;
+float coolHyst = 1, heatHyst = 1;
+int Pressing = 0;
+int heatOn = 0, coolOn = 0; //disabled = -1, enabled/Off = 0, enabled/On = 1
+
+//set flag that indicates it is time to output data to the web socket
+void sendData() {
+ led1 = 1; //!led1;
+}
+
+int main()
+{
+ printf("\n\r-----Starting Project-----\n\r");
+ //Connect to ethernet. Use DHCP. **********************
+ eth.init();
+ eth.connect();
+ printf("IP Address is %s\n\r", eth.getIPAddress());
+
+
+ //Connect to mbed websocket server
+ printf("Connecting to mbed websocket server channel 445\n\r");
+ Websocket ws("ws://sockets.mbed.org/ws/445/rw");
+ //Websocket ws("17.244.173.207");//ws://sockets.mbed.org/ws/445/rw");
+ ws.connect();
+ printf("Done connecting\n\r");
+
+ //Attach ticker with X second timing
+ printf("Setting ticker\n\r");
+ myTicker1.attach(&sendData, 0.5); //send data out every half second
+ float potOut,senseIn,sigOut;
+
+ int i=0;
+ while(1) {
+
+ //Print information to LCD
+ //lcd.cls();
+ //lcd.locate(0,3);
+
+ //If the time is right, send data to the websocket server
+ if (led1) {
+ i=i+1;
+ if (i >= 20) {
+ i=0;
+ };
+
+ //printf("Sending message\n\r");
+ //accel_z = MMA.z();
+ //sprintf(dataOut,"{\"Temp\":%.1f,\"X\":%.1f,\"Y\":%.1f,\"Z\":%.1f}",tempNow,MMA.x(),MMA.y(),MMA.z());
+ potOut=pot19.read();
+ senseIn = ain17.read() + 0.1;
+ sigOut = ((float)i)/20;
+ //printf("%d, %.2f\n\r",i,sigOut);
+ sprintf(dataOut,"{\"X\":%.2f,\"Y\":%.2f,\"Z\":%.2f}",potOut,senseIn,sigOut);
+ //printf("%s\n\r",dataOut);
+ //lcd.cls();
+ //lcd.locate(0,3);
+ //lcd.printf("Pot19: %.2f\n",potOut);
+ //lcd.printf("Sense: %.2f\n",senseIn);
+ //lcd.printf("SigOut: %.2f\n",sigOut);
+
+ ws.send(dataOut);// %d",heatOn);
+ led1 = 0;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Mon Jun 09 22:54:42 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#be2573f85b81
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jun 09 22:54:42 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file