trash over HTTP
Dependencies: C027_Support HTTPClient TrashSensors mbed Crypto
Fork of SLOTrashHTTP by
Collects sensor readings and sends them to https://trash.coreyford.name/
Server code: https://github.com/coyotebush/trash-map
Diff: main.cpp
- Revision:
- 9:ce77a3614cd7
- Parent:
- 8:2398817ac9c2
- Child:
- 10:313495291942
--- a/main.cpp Tue Oct 27 04:24:10 2015 +0000 +++ b/main.cpp Sun Nov 15 22:11:42 2015 +0000 @@ -12,7 +12,8 @@ #define TRIG_PIN A2 #define ECHO_PIN A1 -#define HTTP_ENDPOINT "http://trash.coreyford.name/sensor" +#define MOISTURE_PIN A3 +#define HTTP_ENDPOINT "http://192.241.205.91/sensor" #define SENSOR_NAME "Throop" #define CELLULAR_NETWORK 1 @@ -63,6 +64,9 @@ GroveTempSensor tempS; double tempV; + AnalogIn moistureS(MOISTURE_PIN); + double moistureV; + wdt.kick(30.0); while (true) { @@ -76,6 +80,10 @@ tempV = tempS.getTemp(); printf("Temperature reading: %0.2f C\r\n", tempV); + // Moisture sensor + moistureV = 1.0 - moistureS; + printf("Moisture reading: %0.1f%%\r\n", moistureV * 100); + // GPS printf("Checking for GPS messages\r\n"); while ((gpsRet = gps.getMessage(gpsBuf, sizeof(gpsBuf))) > 0) @@ -100,8 +108,8 @@ // Combine readings in JSON char json[255]; snprintf(json, 255, - "{\"distance\":%0.1f,\"temperature\":%0.1f,\"latitude\":%0.5f,\"longitude\":%0.5f,\"first\":%d}", - distV, tempV, lat, lon, first); + "{\"distance\":%0.1f,\"temperature\":%0.1f,\"moisture\":%0.2f,\"latitude\":%0.5f,\"longitude\":%0.5f,\"first\":%d}", + distV, tempV, moistureV, lat, lon, first); // Compute a MAC (message authentication code) of the value, // using our MAC (media access control) address as a key.