Uploading sensor data (voltage divider, MAX4172, INA219) over Ethernet to Thing Speak service. Uses old mbed revision that is compatible with NetServices library. I2C communication is made with I2CR library.

Dependencies:   C12832 I2CR INA219 NetServices mbed

Fork of NetServices_HelloWorld by Segundo Equipo

Files at this revision

API Documentation at this revision

Comitter:
segundo
Date:
Tue Nov 16 20:04:25 2010 +0000
Parent:
0:2419d81ee03d
Child:
2:16857d9ab50d
Commit message:

Changed in this revision

NetServices.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
--- a/NetServices.lib	Tue Nov 09 21:28:45 2010 +0000
+++ b/NetServices.lib	Tue Nov 16 20:04:25 2010 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/segundo/code/NetServices/#ac1725ba162c
+http://mbed.org/users/segundo/code/NetServices/#79049adc01ed
--- a/main.cpp	Tue Nov 09 21:28:45 2010 +0000
+++ b/main.cpp	Tue Nov 16 20:04:25 2010 +0000
@@ -1,9 +1,11 @@
 #include "mbed.h"
 #include "EthernetNetIf.h"
 #include "HTTPClient.h"
+#include "NTPClient.h"
 
 EthernetNetIf eth("mbedSE");
 HTTPClient http;
+NTPClient ntp;
 
 int main() {
 
@@ -14,8 +16,10 @@
         return -1;
     }
 
-    printf("Connected ok, IP : %d.%d.%d.%d\n", eth.getIp()[0], eth.getIp()[1], eth.getIp()[2], eth.getIp()[3]);
+    IpAddr ethIp = eth.getIp();
+    printf("Connected ok, IP : %d.%d.%d.%d\n", ethIp[0], ethIp[1], ethIp[2], ethIp[3]);
 
+    printf("\nHTTPClient get...\n");
     HTTPText txt;
     HTTPResult r = http.get("http://mbed.org/media/uploads/donatien/hello.txt", &txt);
     if (r==HTTP_OK) {
@@ -24,5 +28,16 @@
         printf("Error %d\n", r);
     }
 
+    time_t ctTime;
+    ctTime = time(NULL);
+    printf("\nCurrent time is (UTC): %d %s\n", ctTime, ctime(&ctTime));
+    printf("NTP setTime...\n");
+    Host server(IpAddr(), 123, "pool.ntp.org");
+    printf("Result : %d\n", ntp.setTime(server));
+
+    ctTime = time(NULL);
+    printf("\nTime is now (UTC): %d %s\n", ctTime, ctime(&ctTime));
+
+    printf("Done!\n");
     return 0;
 }
\ No newline at end of file