Temperature Monitoring with thingspeak (IoT)

Dependencies:   HTTPClient LM75B mbed-rtos mbed

Fork of TCPSocket_HelloWorld by mbed official

Files at this revision

API Documentation at this revision

Comitter:
MohamadNazrin
Date:
Mon Feb 12 07:14:33 2018 +0000
Parent:
15:bc7fc13dc5f6
Commit message:
Temperature monitoring with thingspeak

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
LM75B.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
diff -r bc7fc13dc5f6 -r 91200554b881 EthernetInterface.lib
--- 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
diff -r bc7fc13dc5f6 -r 91200554b881 HTTPClient.lib
--- /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
diff -r bc7fc13dc5f6 -r 91200554b881 LM75B.lib
--- /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
diff -r bc7fc13dc5f6 -r 91200554b881 main.cpp
--- 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();
+        
+        }
 }