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

Revision:
7:1da0a084cd69
Parent:
6:ebbde59c5a1d
--- a/main.cpp	Fri Nov 20 08:28:11 2015 +0000
+++ b/main.cpp	Sun Nov 29 13:41:05 2015 +0000
@@ -7,10 +7,10 @@
 
 
 
-    ThingSpeak ts("074MPWFODR7JHD1K", 6); 
+    ThingSpeak ts("074MPWFODR7JHD1K"); 
     C12832 lcd(p5, p7, p6, p8, p11);
-    Sensor current(p19,4);
-    Sensor voltage(p20,24);
+    Sensor current(p19,4.65);
+    Sensor voltage(p20,16.23);
    
 
 
@@ -20,29 +20,22 @@
     int i;
     
     lcd.cls();
-    lcd.locate(0,3);    
+    lcd.locate(0,3);  
+    lcd.printf("Ethernet Connecting ! \n");  
     ts.connect();
     lcd.printf("Ethernet Connected ! \n");
-    ts.getIP();
-    
     wait(1);
     
     while(1){
-           
-        voltage.read();
-        current.read();           
-        U = voltage.calc();       
-        I = current.calc();
-        ina[0] = ina219.readRawReg(0x04); //* Current *//
+                  
+        U = voltage.read();       
+        I = current.read();
+        ina[0] = ina219.readRawReg(0x04);//* Current *//
         ina[1] = ina219.readRawReg(0x02); //* Bus Voltage *//
-        ina[2] = ina219.readRawReg(0x03); //* Power *// 
-        
+        ina[2] = ina219.readRawReg(0x03);//* Power *// 
+    
         lcd.cls();
-        lcd.locate(0,3);
-        lcd.printf("V = %.2f V \n",U);
-        lcd.printf("I = %.2f A \n",I);
-        lcd.printf("P = %.2f W \n", U*I);
-        lcd.locate(0,14);        
+        lcd.locate(0,3);    
         lcd.printf("V = %.2f V \n",ina[1]);
         lcd.printf("I = %.2f A \n",ina[0]);
         lcd.printf("P = %.2f W \n",ina[2]);
@@ -50,7 +43,8 @@
         i = 1;
         ts.setField(U, i++);
         ts.setField(I, i++); 
-        for(int j = 0 ; j<= 3; j++)
+        ts.setField(I*U, i++); 
+        for(int j = 0 ; j<= 2; j++)
             ts.setField(ina[j], i++);
             
         ts.putUp();