All sensors sending to server via http

Dependencies:   C12832 CCS811 MMA7660 Sht31 TSL2561 mbed-http vl53l0x_api

Fork of HTTP-Python-Demo by Cambridge Hackathon

Committer:
lwc24
Date:
Sun Nov 26 02:23:40 2017 +0000
Revision:
4:061755016e24
Parent:
3:409108394e75
Working send all data with time

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jenny Plunkett 0:c5b042cf8162 1 //----------------------------------------------------------------------------
Jenny Plunkett 0:c5b042cf8162 2 // The confidential and proprietary information contained in this file may
Jenny Plunkett 0:c5b042cf8162 3 // only be used by a person authorised under and to the extent permitted
Jenny Plunkett 0:c5b042cf8162 4 // by a subsisting licensing agreement from ARM Limited or its affiliates.
Jenny Plunkett 0:c5b042cf8162 5 //
Jenny Plunkett 0:c5b042cf8162 6 // (C) COPYRIGHT 2016 ARM Limited or its affiliates.
Jenny Plunkett 0:c5b042cf8162 7 // ALL RIGHTS RESERVED
Jenny Plunkett 0:c5b042cf8162 8 //
Jenny Plunkett 0:c5b042cf8162 9 // This entire notice must be reproduced on all copies of this file
Jenny Plunkett 0:c5b042cf8162 10 // and copies of this file may only be made by a person if such person is
Jenny Plunkett 0:c5b042cf8162 11 // permitted to do so under the terms of a subsisting license agreement
Jenny Plunkett 0:c5b042cf8162 12 // from ARM Limited or its affiliates.
Jenny Plunkett 0:c5b042cf8162 13 //----------------------------------------------------------------------------
lwc24 3:409108394e75 14 #include <sstream>
lwc24 3:409108394e75 15 #include <string>
lwc24 4:061755016e24 16 #include <time.h>
lwc24 3:409108394e75 17
Jenny Plunkett 0:c5b042cf8162 18 #include "mbed.h"
Jenny Plunkett 0:c5b042cf8162 19 #include "OdinWiFiInterface.h"
Jenny Plunkett 0:c5b042cf8162 20 #include "http_request.h"
Jenny Plunkett 0:c5b042cf8162 21
lwc24 3:409108394e75 22 #include "C12832.h"
lwc24 3:409108394e75 23 #include "CCS811.h"
lwc24 3:409108394e75 24 #include "Sht31.h"
lwc24 3:409108394e75 25 #include "TSL2561.h"
lwc24 3:409108394e75 26 #include "MMA7660.h"
lwc24 3:409108394e75 27
lwc24 3:409108394e75 28 #include "vl53l0x_api.h"
lwc24 3:409108394e75 29 #include "vl53l0x_platform.h"
lwc24 3:409108394e75 30 #include "vl53l0x_i2c_platform.h"
lwc24 3:409108394e75 31
lwc24 3:409108394e75 32 #define USE_I2C_2V8
lwc24 3:409108394e75 33
Jenny Plunkett 0:c5b042cf8162 34 // GLOBAL VARIABLES HERE
lwc24 3:409108394e75 35 C12832 lcd(PE_14, PE_12, PD_12, PD_11, PE_9);
lwc24 3:409108394e75 36 DigitalOut led(PB_6, 1);
lwc24 3:409108394e75 37 Sht31 temp_sensor(PF_0, PF_1);
lwc24 3:409108394e75 38 CCS811 air_sensor(PF_0, PF_1);
lwc24 3:409108394e75 39 TSL2561 light_sensor(PF_0, PF_1, TSL2561_ADDR_HIGH);
lwc24 3:409108394e75 40 MMA7660 accel(PF_0, PF_1);
lwc24 3:409108394e75 41
lwc24 3:409108394e75 42 OdinWiFiInterface wifi;
lwc24 3:409108394e75 43
lwc24 3:409108394e75 44 InterruptIn post_button(PF_2);
lwc24 3:409108394e75 45 InterruptIn get_put_button(PG_4);
lwc24 3:409108394e75 46 volatile bool post_clicked = false;
lwc24 3:409108394e75 47 volatile bool get_clicked = false;
lwc24 3:409108394e75 48 volatile bool put_clicked = false;
lwc24 3:409108394e75 49
lwc24 3:409108394e75 50 // FUNCTION DEFINITIONS HERE
lwc24 3:409108394e75 51 void lcd_print(const char* message) {
lwc24 3:409108394e75 52 lcd.cls();
lwc24 3:409108394e75 53 lcd.locate(0, 3);
lwc24 3:409108394e75 54 lcd.printf(message);
lwc24 3:409108394e75 55 }
Jenny Plunkett 0:c5b042cf8162 56
Jenny Plunkett 0:c5b042cf8162 57
lwc24 3:409108394e75 58 float * read_temp() {
lwc24 3:409108394e75 59 float t = temp_sensor.readTemperature();
lwc24 3:409108394e75 60 float h = temp_sensor.readHumidity();
lwc24 3:409108394e75 61 //char val[32];
lwc24 3:409108394e75 62 //sprintf(val, "TEMP: %3.2fC, HUM: %3.2f%%", t, h);
lwc24 3:409108394e75 63 //lcd_print(val);
lwc24 3:409108394e75 64 static float out[2];
lwc24 3:409108394e75 65 out[0] = t;
lwc24 3:409108394e75 66 out[1] = h;
lwc24 3:409108394e75 67 return out;
lwc24 3:409108394e75 68 }
lwc24 3:409108394e75 69
lwc24 3:409108394e75 70 uint16_t * read_air() {
lwc24 3:409108394e75 71 air_sensor.init();
lwc24 3:409108394e75 72 uint16_t eco2, tvoc;
lwc24 3:409108394e75 73 air_sensor.readData(&eco2, &tvoc);
lwc24 3:409108394e75 74 //char val[32];
lwc24 3:409108394e75 75 //sprintf(val, "eCO2: %dppm, TVOC: %dppb", eco2, tvoc);
lwc24 3:409108394e75 76 //lcd_print(val);
lwc24 3:409108394e75 77 static uint16_t out[2];
lwc24 3:409108394e75 78 out[0] = eco2;
lwc24 3:409108394e75 79 out[1] = tvoc;
lwc24 3:409108394e75 80 return out;
lwc24 3:409108394e75 81 }
lwc24 3:409108394e75 82
lwc24 3:409108394e75 83 int * read_light() {
lwc24 3:409108394e75 84 int vis = light_sensor.getLuminosity(TSL2561_VISIBLE);
lwc24 3:409108394e75 85 int infr = light_sensor.getLuminosity(TSL2561_INFRARED);
lwc24 3:409108394e75 86 //char val[32];
lwc24 3:409108394e75 87 //sprintf(val, "VIS: %d, INFR: %d ", vis, infr);
lwc24 3:409108394e75 88 //lcd_print(val);
lwc24 3:409108394e75 89 static int out[2];
lwc24 3:409108394e75 90 out[0] = vis;
lwc24 3:409108394e75 91 out[1] = infr;
lwc24 3:409108394e75 92 return out;
lwc24 3:409108394e75 93 }
lwc24 3:409108394e75 94
lwc24 3:409108394e75 95
lwc24 3:409108394e75 96 double * read_accel() {
lwc24 3:409108394e75 97 double x = accel.x();
lwc24 3:409108394e75 98 double y = accel.y();
lwc24 3:409108394e75 99 double z = accel.z();
lwc24 3:409108394e75 100 //char val[32];
lwc24 3:409108394e75 101 //sprintf(val, "x=%.2f y=%.2f z=%.2f", x, y, z);
lwc24 3:409108394e75 102 //lcd_print(val);
lwc24 3:409108394e75 103 static double out[3];
lwc24 3:409108394e75 104 out[0] = x;
lwc24 3:409108394e75 105 out[1] = y;
lwc24 3:409108394e75 106 out[2] = z;
lwc24 3:409108394e75 107 return out;
lwc24 3:409108394e75 108 }
lwc24 3:409108394e75 109
lwc24 3:409108394e75 110
Jenny Plunkett 0:c5b042cf8162 111
lwc24 3:409108394e75 112 VL53L0X_Error WaitMeasurementDataReady(VL53L0X_DEV Dev) {
lwc24 3:409108394e75 113 VL53L0X_Error Status = VL53L0X_ERROR_NONE;
lwc24 3:409108394e75 114 uint8_t NewDatReady=0;
lwc24 3:409108394e75 115 uint32_t LoopNb;
lwc24 3:409108394e75 116
lwc24 3:409108394e75 117 if (Status == VL53L0X_ERROR_NONE) {
lwc24 3:409108394e75 118 LoopNb = 0;
lwc24 3:409108394e75 119 do {
lwc24 3:409108394e75 120 Status = VL53L0X_GetMeasurementDataReady(Dev, &NewDatReady);
lwc24 3:409108394e75 121 if ((NewDatReady == 0x01) || Status != VL53L0X_ERROR_NONE) {
lwc24 3:409108394e75 122 break;
lwc24 3:409108394e75 123 }
lwc24 3:409108394e75 124 LoopNb = LoopNb + 1;
lwc24 3:409108394e75 125 VL53L0X_PollingDelay(Dev);
lwc24 3:409108394e75 126 } while (LoopNb < VL53L0X_DEFAULT_MAX_LOOP);
lwc24 3:409108394e75 127
lwc24 3:409108394e75 128 if (LoopNb >= VL53L0X_DEFAULT_MAX_LOOP) {
lwc24 3:409108394e75 129 Status = VL53L0X_ERROR_TIME_OUT;
lwc24 3:409108394e75 130 }
lwc24 3:409108394e75 131 }
lwc24 3:409108394e75 132
lwc24 3:409108394e75 133 return Status;
lwc24 3:409108394e75 134 }
lwc24 3:409108394e75 135
lwc24 3:409108394e75 136 VL53L0X_Error WaitStopCompleted(VL53L0X_DEV Dev) {
lwc24 3:409108394e75 137 VL53L0X_Error Status = VL53L0X_ERROR_NONE;
lwc24 3:409108394e75 138 uint32_t StopCompleted=0;
lwc24 3:409108394e75 139 uint32_t LoopNb;
lwc24 3:409108394e75 140
lwc24 3:409108394e75 141 if (Status == VL53L0X_ERROR_NONE) {
lwc24 3:409108394e75 142 LoopNb = 0;
lwc24 3:409108394e75 143 do {
lwc24 3:409108394e75 144 Status = VL53L0X_GetStopCompletedStatus(Dev, &StopCompleted);
lwc24 3:409108394e75 145 if ((StopCompleted == 0x00) || Status != VL53L0X_ERROR_NONE) {
lwc24 3:409108394e75 146 break;
lwc24 3:409108394e75 147 }
lwc24 3:409108394e75 148 LoopNb = LoopNb + 1;
lwc24 3:409108394e75 149 VL53L0X_PollingDelay(Dev);
lwc24 3:409108394e75 150 } while (LoopNb < VL53L0X_DEFAULT_MAX_LOOP);
lwc24 3:409108394e75 151
lwc24 3:409108394e75 152 if (LoopNb >= VL53L0X_DEFAULT_MAX_LOOP) {
lwc24 3:409108394e75 153 Status = VL53L0X_ERROR_TIME_OUT;
lwc24 3:409108394e75 154 }
lwc24 3:409108394e75 155
lwc24 3:409108394e75 156 }
lwc24 3:409108394e75 157
lwc24 3:409108394e75 158 return Status;
lwc24 3:409108394e75 159 }
lwc24 3:409108394e75 160
lwc24 3:409108394e75 161 void send_post() {
lwc24 3:409108394e75 162 post_clicked = true;
lwc24 3:409108394e75 163 }
lwc24 3:409108394e75 164
lwc24 3:409108394e75 165 void send_put() {
lwc24 3:409108394e75 166 put_clicked = true;
lwc24 3:409108394e75 167 }
Jenny Plunkett 0:c5b042cf8162 168
Jenny Plunkett 0:c5b042cf8162 169 int main() {
Jenny Plunkett 0:c5b042cf8162 170
lwc24 3:409108394e75 171 // Setup Laser
lwc24 3:409108394e75 172 VL53L0X_Dev_t MyDevice;
lwc24 3:409108394e75 173 VL53L0X_Dev_t *pMyDevice = &MyDevice;
lwc24 3:409108394e75 174 VL53L0X_RangingMeasurementData_t RangingMeasurementData;
lwc24 3:409108394e75 175 VL53L0X_RangingMeasurementData_t *pRangingMeasurementData = &RangingMeasurementData;
lwc24 3:409108394e75 176
lwc24 3:409108394e75 177 // Initialize Comms laster
lwc24 3:409108394e75 178 pMyDevice->I2cDevAddr = 0x52;
lwc24 3:409108394e75 179 pMyDevice->comms_type = 1;
lwc24 3:409108394e75 180 pMyDevice->comms_speed_khz = 400;
lwc24 3:409108394e75 181
lwc24 3:409108394e75 182 VL53L0X_RdWord(&MyDevice, VL53L0X_REG_OSC_CALIBRATE_VAL,0);
lwc24 3:409108394e75 183 VL53L0X_DataInit(&MyDevice);
lwc24 3:409108394e75 184 uint32_t refSpadCount;
lwc24 3:409108394e75 185 uint8_t isApertureSpads;
lwc24 3:409108394e75 186 uint8_t VhvSettings;
lwc24 3:409108394e75 187 uint8_t PhaseCal;
lwc24 3:409108394e75 188
lwc24 3:409108394e75 189 VL53L0X_StaticInit(pMyDevice);
lwc24 3:409108394e75 190 VL53L0X_PerformRefSpadManagement(pMyDevice, &refSpadCount, &isApertureSpads); // Device Initialization
lwc24 3:409108394e75 191 VL53L0X_PerformRefCalibration(pMyDevice, &VhvSettings, &PhaseCal); // Device Initialization
lwc24 3:409108394e75 192 VL53L0X_SetDeviceMode(pMyDevice, VL53L0X_DEVICEMODE_CONTINUOUS_RANGING); // Setup in single ranging mode
lwc24 3:409108394e75 193 VL53L0X_SetLimitCheckValue(pMyDevice, VL53L0X_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE, (FixPoint1616_t)(0.25*65536)); //High Accuracy mode, see API PDF
lwc24 3:409108394e75 194 VL53L0X_SetLimitCheckValue(pMyDevice, VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE, (FixPoint1616_t)(18*65536)); //High Accuracy mode, see API PDF
lwc24 3:409108394e75 195 VL53L0X_SetMeasurementTimingBudgetMicroSeconds(pMyDevice, 200000); //High Accuracy mode, see API PDF
lwc24 3:409108394e75 196 VL53L0X_StartMeasurement(pMyDevice);
Jenny Plunkett 0:c5b042cf8162 197
lwc24 3:409108394e75 198 // Setup wifi
lwc24 3:409108394e75 199 lcd_print("Connecting...");
lwc24 3:409108394e75 200 int ret = wifi.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2);
lwc24 3:409108394e75 201 if (ret != 0) {
lwc24 3:409108394e75 202 lcd_print("Connection error.");
lwc24 3:409108394e75 203 return -1;
lwc24 3:409108394e75 204 }
lwc24 3:409108394e75 205 lcd_print("Successfully connected!");
lwc24 4:061755016e24 206
lwc24 4:061755016e24 207 // Initialize reading variables
lwc24 4:061755016e24 208 int var=1, measure=0;
lwc24 4:061755016e24 209 int ave=0, sum=0;
lwc24 4:061755016e24 210 double * acc;
lwc24 4:061755016e24 211 int * light;
lwc24 4:061755016e24 212 uint16_t * air;
lwc24 4:061755016e24 213 float * temp;
lwc24 4:061755016e24 214 //auto time0 = chrono::steady_clock::now();
lwc24 4:061755016e24 215
lwc24 4:061755016e24 216 int counter = 0;
lwc24 4:061755016e24 217 int buffer_size = 10;
lwc24 4:061755016e24 218 int buffer_time[buffer_size];
lwc24 4:061755016e24 219 double buffer_acc[buffer_size][3];
lwc24 4:061755016e24 220 int buffer_dist[buffer_size];
lwc24 4:061755016e24 221 int buffer_light[buffer_size][2];
lwc24 4:061755016e24 222 uint16_t buffer_air[buffer_size][2];
lwc24 4:061755016e24 223 float buffer_temp[buffer_size][2];
lwc24 3:409108394e75 224
lwc24 3:409108394e75 225 post_button.rise(&send_post);
lwc24 3:409108394e75 226 get_put_button.rise(&send_put);
lwc24 4:061755016e24 227
lwc24 4:061755016e24 228 Timer t;
lwc24 4:061755016e24 229
lwc24 4:061755016e24 230 t.start();
lwc24 4:061755016e24 231
lwc24 3:409108394e75 232 while (true) {
lwc24 3:409108394e75 233
lwc24 3:409108394e75 234 // Get laser measurement
lwc24 4:061755016e24 235 while(var<=2){
lwc24 3:409108394e75 236 WaitMeasurementDataReady(pMyDevice);
lwc24 3:409108394e75 237 VL53L0X_GetRangingMeasurementData(pMyDevice, pRangingMeasurementData);
lwc24 3:409108394e75 238 measure=pRangingMeasurementData->RangeMilliMeter;
lwc24 3:409108394e75 239 sum=sum+measure;
lwc24 3:409108394e75 240 VL53L0X_ClearInterruptMask(pMyDevice, VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_NEW_SAMPLE_READY);
lwc24 3:409108394e75 241 VL53L0X_PollingDelay(pMyDevice);
lwc24 3:409108394e75 242 var++;
lwc24 3:409108394e75 243 }
lwc24 3:409108394e75 244 ave=sum/var; // This is the measurement value
lwc24 3:409108394e75 245 var=1;
lwc24 3:409108394e75 246 sum=0;
lwc24 4:061755016e24 247
lwc24 4:061755016e24 248 // TIMINGS
lwc24 4:061755016e24 249 int now_time = t.read_ms();
lwc24 3:409108394e75 250
lwc24 4:061755016e24 251 std::ostringstream timestr;
lwc24 4:061755016e24 252 timestr << "Elapsed time: " << now_time/1000 << "\n Press SW1 to send data";
lwc24 4:061755016e24 253 std::string tstr = timestr.str();
lwc24 4:061755016e24 254
lwc24 4:061755016e24 255 //std::ostringstream timestr;
lwc24 4:061755016e24 256 //timestr << counter;
lwc24 4:061755016e24 257 //std:string tstr = timestr.str();
lwc24 4:061755016e24 258 //lcd_print(tstr.c_str());
lwc24 4:061755016e24 259
lwc24 4:061755016e24 260 //buffer is sent via http when it is full
lwc24 4:061755016e24 261 buffer_time[counter] = now_time;
lwc24 4:061755016e24 262 //buffer_time[counter] = 0;
lwc24 4:061755016e24 263 buffer_dist[counter] = ave;
lwc24 3:409108394e75 264 // Get accelerometer measurement
lwc24 3:409108394e75 265 acc = read_accel();
lwc24 4:061755016e24 266 buffer_acc[counter][0] = acc[0];
lwc24 4:061755016e24 267 buffer_acc[counter][1] = acc[1];
lwc24 4:061755016e24 268 buffer_acc[counter][2] = acc[2];
lwc24 3:409108394e75 269 light = read_light();
lwc24 4:061755016e24 270 buffer_light[counter][0] = light[0];
lwc24 4:061755016e24 271 buffer_light[counter][1] = light[1];
lwc24 3:409108394e75 272 //temp = read_temp();
lwc24 4:061755016e24 273 //buffer_temp[counter][0] = temp[0];
lwc24 4:061755016e24 274 //buffer_temp[counter][0] = temp[1];
lwc24 4:061755016e24 275 //air = read_air();
lwc24 4:061755016e24 276 //buffer_air[counter][0] = air[0];
lwc24 4:061755016e24 277 //buffer_air[counter][0] = air[1];
lwc24 3:409108394e75 278
lwc24 4:061755016e24 279 counter += 1;
lwc24 4:061755016e24 280
lwc24 4:061755016e24 281 if (counter >= buffer_size) {
lwc24 4:061755016e24 282 counter = 0;
lwc24 4:061755016e24 283 lcd_print(tstr.c_str());
lwc24 3:409108394e75 284
lwc24 4:061755016e24 285 if (post_clicked) {
lwc24 4:061755016e24 286 lcd_print("Sending Data... \nPress SW2 to stop.");
lwc24 4:061755016e24 287 //post_clicked = false;
lwc24 4:061755016e24 288 NetworkInterface* net = &wifi;
lwc24 4:061755016e24 289 HttpRequest* request = new HttpRequest(net, HTTP_POST, "http://10.25.1.118:5000");
lwc24 4:061755016e24 290 request->set_header("Content-Type", "application/json");
lwc24 4:061755016e24 291 std::ostringstream datastr;
lwc24 4:061755016e24 292
lwc24 4:061755016e24 293 datastr << "{ \"time\" : [ " << buffer_time[0];
lwc24 4:061755016e24 294 for(int i=1; i<buffer_size; i++){
lwc24 4:061755016e24 295 datastr << ", " << buffer_time[i];
lwc24 4:061755016e24 296 }
lwc24 4:061755016e24 297 datastr << " ], ";
lwc24 4:061755016e24 298
lwc24 4:061755016e24 299 datastr << " \"dist\" : [ " << buffer_dist[0];
lwc24 4:061755016e24 300 for(int i=1; i<buffer_size; i++){
lwc24 4:061755016e24 301 datastr << ", " << buffer_dist[i];
lwc24 4:061755016e24 302 }
lwc24 4:061755016e24 303 datastr << " ], ";
lwc24 4:061755016e24 304
lwc24 4:061755016e24 305 datastr << " \"acc\" : [ ";
lwc24 4:061755016e24 306 datastr << "{ \"x\" : " << buffer_acc[0][0] << ", \"y\" : " << buffer_acc[0][1] << ", \"z\": " << buffer_acc[0][2] << "}" ;
lwc24 4:061755016e24 307 for(int i=1; i<buffer_size; i++){
lwc24 4:061755016e24 308 datastr << ", { \"x\" : " << buffer_acc[i][0] << ", \"y\" : " << buffer_acc[i][1] << ", \"z\": " << buffer_acc[i][2] << "}" ;
lwc24 4:061755016e24 309 }
lwc24 4:061755016e24 310
lwc24 4:061755016e24 311 // Light
lwc24 4:061755016e24 312 datastr << "], ";
lwc24 4:061755016e24 313 datastr << " \"visible\" : [ " << buffer_light[0][0];
lwc24 4:061755016e24 314 for(int i=1; i<buffer_size; i++){
lwc24 4:061755016e24 315 datastr << ", " << buffer_light[i][0];
lwc24 4:061755016e24 316 }
lwc24 4:061755016e24 317 datastr << " ], ";
lwc24 4:061755016e24 318 datastr << " \"infared\" : [ " << buffer_light[0][1];
lwc24 4:061755016e24 319 for(int i=1; i<buffer_size; i++){
lwc24 4:061755016e24 320 datastr << ", " << buffer_light[i][1];
lwc24 4:061755016e24 321 }
lwc24 4:061755016e24 322 datastr << " ] ";
lwc24 4:061755016e24 323
lwc24 4:061755016e24 324 /*
lwc24 4:061755016e24 325 // Temperature
lwc24 4:061755016e24 326 datastr << " ], ";
lwc24 4:061755016e24 327 datastr << " \"temp\" : [ ";
lwc24 4:061755016e24 328 datastr << "{ \"temperature\" : " << buffer_temp[0][0] << ", \"humidity\" : " << buffer_temp[0][1] << "}" ;
lwc24 4:061755016e24 329 for(int i=1; i<buffer_size; i++){
lwc24 4:061755016e24 330 datastr << ", { \"visible\" : " << buffer_temp[i][0] << ", \"infared\" : " << buffer_temp[i][1] << "}" ;
lwc24 4:061755016e24 331 }
lwc24 4:061755016e24 332
lwc24 4:061755016e24 333 // Air
lwc24 4:061755016e24 334 datastr << " ], ";
lwc24 4:061755016e24 335 datastr << " \"air\" : [ ";
lwc24 4:061755016e24 336 datastr << "{ \"eco2\" : " << buffer_air[0][0] << ", \"tvoc\" : " << buffer_air[0][1] << "}" ;
lwc24 4:061755016e24 337 for(int i=1; i<buffer_size; i++){
lwc24 4:061755016e24 338 datastr << ", { \"eco2\" : " << buffer_air[i][0] << ", \"tvoc\" : " << buffer_air[i][1] << "}" ;
lwc24 4:061755016e24 339 }
lwc24 4:061755016e24 340 */
lwc24 4:061755016e24 341
lwc24 4:061755016e24 342 datastr << "}";
lwc24 4:061755016e24 343
lwc24 4:061755016e24 344 std::string dstr = datastr.str();
lwc24 4:061755016e24 345 HttpResponse* response = request->send(dstr.c_str(), strlen(dstr.c_str()));
lwc24 4:061755016e24 346
lwc24 4:061755016e24 347 //const char body[] = "{ \"key1\" : \"value1\" }";
lwc24 4:061755016e24 348 //HttpResponse* response = request->send(body, strlen(body));
lwc24 4:061755016e24 349 //lcd_print(response->get_body_as_string().c_str());
lwc24 4:061755016e24 350 delete request;
lwc24 4:061755016e24 351 }
lwc24 3:409108394e75 352 }
lwc24 3:409108394e75 353
lwc24 3:409108394e75 354 if (put_clicked) {
lwc24 4:061755016e24 355 lcd_print("Stopped Sending Data...");
lwc24 3:409108394e75 356 put_clicked = false;
lwc24 3:409108394e75 357 post_clicked = false;
lwc24 3:409108394e75 358 }
lwc24 3:409108394e75 359
lwc24 3:409108394e75 360 //wait_ms(10);
lwc24 3:409108394e75 361
lwc24 3:409108394e75 362 }
Jenny Plunkett 0:c5b042cf8162 363
Jenny Plunkett 0:c5b042cf8162 364 }