Temperature dashboard assignment

Dependencies:   EthernetInterface LM75B mbed-rtos mbed

Fork of temperature-dashboard-start by Sille Van Landschoot

Committer:
sillevl
Date:
Fri Nov 07 14:37:02 2014 +0000
Revision:
16:58c33ec28b2a
Parent:
11:59dcefdda506
Child:
17:c8a4886ba688
temperature dashboard start for students

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:bb128f0e952f 1 #include "mbed.h"
sillevl 16:58c33ec28b2a 2 #include "TempDashSocketConnection.h"
sillevl 16:58c33ec28b2a 3 #include "TemperatureSensor.h"
sillevl 16:58c33ec28b2a 4 #include <string.h>
sillevl 16:58c33ec28b2a 5
sillevl 16:58c33ec28b2a 6 Serial pc(USBTX, USBRX); // tx, rx
sillevl 16:58c33ec28b2a 7
sillevl 16:58c33ec28b2a 8 std::string key = "";
sillevl 16:58c33ec28b2a 9 std::string name = "mbed";
sillevl 16:58c33ec28b2a 10 static const char SERVER[] = "labict.be";
sillevl 16:58c33ec28b2a 11 static const int PORT = 45678;
donatien 0:bb128f0e952f 12
emilmont 7:65188f4a8c25 13 int main() {
sillevl 16:58c33ec28b2a 14 pc.baud(115200);
donatien 0:bb128f0e952f 15 EthernetInterface eth;
donatien 0:bb128f0e952f 16 eth.init(); //Use DHCP
donatien 0:bb128f0e952f 17 eth.connect();
sillevl 16:58c33ec28b2a 18 pc.printf("IP Address is %s\r\n", eth.getIPAddress());
donatien 0:bb128f0e952f 19
sillevl 16:58c33ec28b2a 20 TemperatureSensor sensor(p28, p27, key, name);
donatien 0:bb128f0e952f 21
sillevl 16:58c33ec28b2a 22 TempDashSocketConnection sock;
emilmont 7:65188f4a8c25 23
sillevl 16:58c33ec28b2a 24 while(1) {
sillevl 16:58c33ec28b2a 25 if (sensor.open()) {
sillevl 16:58c33ec28b2a 26 sock.connect(SERVER, PORT);
sillevl 16:58c33ec28b2a 27 sock.sendSensorData(sensor.getDataPacket());
sillevl 16:58c33ec28b2a 28 sock.close();
sillevl 16:58c33ec28b2a 29 wait(1.0);
sillevl 16:58c33ec28b2a 30 }
emilmont 7:65188f4a8c25 31 }
emilmont 7:65188f4a8c25 32 eth.disconnect();
donatien 0:bb128f0e952f 33 }