M2X with Seeed Ethernet using Seeed Accelerometer demo

Dependencies:   LM75B M2XStreamClient jsonlite mbed-rtos mbed

Fork of m2x-seeed_ethernet_demo by Sean Newton

Revision:
5:35a77b9b509c
Parent:
1:49d4f5ca7d58
--- a/main.cpp	Tue Sep 23 03:33:27 2014 +0000
+++ b/main.cpp	Tue Sep 23 22:35:02 2014 +0000
@@ -15,6 +15,7 @@
 double longitude = -96.751614; // You can also read those values from a GPS
 double elevation = 697.00;
 
+PwmOut mypwm(PWM_OUT);
 AnalogIn temp_sensor(A0);  
 
 /**
@@ -65,6 +66,8 @@
     float temperature_f;  
     char amb_temp[6];    
 
+    mypwm.period_ms(500);
+    mypwm.pulsewidth_ms(250);
     /* Have mbed assign the mac address */
     mbed_mac_address((char *)mac);     
 
@@ -107,10 +110,18 @@
     }
 
 
+
+    mypwm.pulsewidth_ms(500);
  
     /* Main loop */
     while (true) {
 
+
+ 
+        /* Wait 5 secs and then loop */
+        delay(2500);
+        mypwm.pulsewidth_ms(0);      
+              
         /* Read ADC value from analog sensor */
         uint16_t a = temp_sensor.read_u16();
                
@@ -123,24 +134,28 @@
         printf("Temp Sensor Analog Reading is 0x%X = %d  \r\n", a, a);         
         printf("Current Temperature: %f C  %f F \r\n", temperature, temperature_f); 
 
+        delay(2500);
+        mypwm.pulsewidth_ms(500);   
+        
         /* Post temperature to M2X site */
         int response = m2xClient.put(feedId, streamName, amb_temp);
         printf("Post response code: %d\r\n", response);
         if (response == -1) 
         {
+            mypwm.pulsewidth_ms(250);                
             printf("Temperature data transmit post error\n");
         }
-        
         /* Update location data */
         response = m2xClient.updateLocation(feedId, name, latitude, longitude, elevation);
         printf("updateLocation response code: %d\r\n", response);
         if (response == -1) 
         {
+            mypwm.pulsewidth_ms(250);        
             printf("Location data transmit post error\n");
         }
 
         printf("\r\n");
-        /* Wait 5 secs and then loop */
-        delay(5000);
+        
+
     }
 }