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: HTTPClient LM75B mbed-rtos mbed
Fork of TCPSocket_HelloWorld by
Revision 16:91200554b881, committed 2018-02-12
- Comitter:
- MohamadNazrin
- Date:
- Mon Feb 12 07:14:33 2018 +0000
- Parent:
- 15:bc7fc13dc5f6
- Commit message:
- Temperature monitoring with thingspeak
Changed in this revision
--- a/EthernetInterface.lib Fri Feb 09 02:19:29 2018 +0000 +++ b/EthernetInterface.lib Mon Feb 12 07:14:33 2018 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/EthernetInterface/#097a9996f8d5 +https://os.mbed.com/users/MohamadNazrin/code/TempMonitoring/#3b4a8d2e1539
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HTTPClient.lib Mon Feb 12 07:14:33 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/HTTPClient/#cca5d89e6a2b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LM75B.lib Mon Feb 12 07:14:33 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/chris/code/LM75B/#6a70c9303bbe
--- a/main.cpp Fri Feb 09 02:19:29 2018 +0000
+++ b/main.cpp Mon Feb 12 07:14:33 2018 +0000
@@ -1,16 +1,42 @@
#include "mbed.h"
#include "EthernetInterface.h"
-int main() {
-
-static const char* mbedIp = "192.168.137.2"; //IP
-static const char* mbedMask = "255.255.255.0"; // Mask
-static const char* mbedGateway = "192.168.137.1"; //Gateway
+#include "LM75B.h"
+#include "HTTPClient.h"
+
+
+LM75B tmp(p28,p27); // temperature sensor
+char* thingSpeakUrl = "http://api.thingspeak.com/update";
+char* thingSpeakKey = "C9T47QDLBY4NU7MW";
+char buffer[256];
- EthernetInterface eth;
- // eth.init(); //Use DHCP
- eth.init(mbedIp,mbedMask,mbedGateway);
+
+void ethernetSetup(){
+//static const char* mbedIp = "192.168.137.2"; //IP
+//static const char* mbedMask = "255.255.255.0"; // Mask
+//static const char* mbedGateway = "192.168.137.1"; //Gateway
+
+EthernetInterface eth;
+ eth.init(); //Use DHCP
+//eth.init(mbedIp,mbedMask,mbedGateway);
eth.connect();
printf("IP Address is %s\n", eth.getIPAddress());
+
+ }
+
+void thingspeak(){
+ HTTPClient http;
+ buffer[0] = 0;
+ sprintf(buffer,"%s?key=%s&field2=%2f",thingSpeakUrl,thingSpeakKey,tmp.read());
+ printf("Send to %s\r\n", buffer);
+ http.get(buffer, buffer , 10); // Execute the URL of urlBuffer
+
+ }
- while(1) {}
+int main() {
+ ethernetSetup();
+
+ while(1) {
+ thingspeak();
+
+ }
}
