trash over HTTP

Dependencies:   C027_Support HTTPClient TrashSensors mbed Crypto

Fork of SLOTrashHTTP by Corey Ford

Collects sensor readings and sends them to https://trash.coreyford.name/

Server code: https://github.com/coyotebush/trash-map

Revision:
5:21e76b5af13b
Parent:
4:1acb5d26ec21
Child:
6:43ac8ef67a03
--- a/main.cpp	Thu May 28 04:29:26 2015 +0000
+++ b/main.cpp	Thu May 28 05:13:22 2015 +0000
@@ -2,13 +2,14 @@
 #include "HTTPClient.h"
 
 #include "hcsr04.h"
+#include "GroveTemp.h"
 #include "GPS.h"
 
 #include "SHA1.h"
 #include "HMAC.h"
 
-#define TRIG_PIN D6
-#define ECHO_PIN D5
+#define TRIG_PIN A2
+#define ECHO_PIN A1
 #define HTTP_ENDPOINT "http://trash.coreyford.name/sensor"
 #define SENSOR_NAME "Throop"
 
@@ -53,6 +54,9 @@
     double distV;
     char str[512];
     
+    GroveTempSensor tempS;
+    double tempV;
+    
     while (true) {
         // Distance sensor
         distS.start();
@@ -60,6 +64,9 @@
         distV = distS.get_dist_cm();
         printf("sensor reading: %0.2f\r\n", distV);
         
+        // Temperature sensor
+        tempV = tempS.getTemp();
+        
         // GPS
         printf("trying GPS\r\n");
         while ((gpsRet = gps.getMessage(gpsBuf, sizeof(gpsBuf))) > 0)
@@ -82,7 +89,9 @@
         
         // Combine readings in JSON
         char json[255];
-        snprintf(json, 255, "{\"distance\":%0.1f,\"latitude\":%0.5f,\"longitude\":%0.5f}", distV, lat, lon);
+        snprintf(json, 255,
+            "{\"distance\":%0.1f,\"temperature\":%0.1f,\"latitude\":%0.5f,\"longitude\":%0.5f}",
+            distV, tempV, lat, lon);
            
         // Compute a MAC (message authentication code) of the value,
         // using our MAC (media access control) address as a key.