Completing firmware for the temperature/humidity, IR, and magnetic sensors for both...
[iotcloud.git] / version2 / src / others / ino / Temp-Sensor / Temp-Sensor_Fidelius-Cloud.ino
index c35a2bb8c692e1f96bd6038fe6ed88363a51e69a..3e4441e37d56c4fb63316559585e258952ca61c7 100644 (file)
@@ -63,9 +63,9 @@ void setup() {
        // Wait for a maximum amount of time - sleep if WiFi is not connected
        // Wake up and try again afterwards
        // TODO: either use this or just WiFi connection (below)
-//     Particle.connect();
-//     if (!waitFor(Particle.connected, RETRY_TIME))
-//             System.sleep(SLEEP_MODE_DEEP, RETRY_SLEEP_TIME);
+       //Particle.connect();
+       //if (!waitFor(Particle.connected, RETRY_TIME))
+       //      System.sleep(SLEEP_MODE_DEEP, RETRY_SLEEP_TIME);
 
        // Connect only to WiFi
        WiFi.on();
@@ -129,6 +129,9 @@ void loop() {
        // Check if any reads failed and exit early (to try again).
        if (isnan(humid) || isnan(tempF))
                return;
+       
+       // TODO: Update values separately to different keys
+       /*
        // Humidity
        // Key
        sprintf(keyBuffer, "h%04x", machineId);
@@ -162,12 +165,13 @@ void loop() {
        iValueHumid->releaseRef();
        iKeyTempF->releaseRef();
        iValueTempF->releaseRef();
+       */
        
        // TODO: Collapse temperature and humidity into one key
-/*     sprintf(keyBuffer, "%04x", machineId);
+       sprintf(keyBuffer, "humtemp%04x", machineId);
        IoTString * iKey = new IoTString(keyBuffer);
        // Do updates for the temperature
-       sprintf(dataBuffer, "%0.2f%0.2f", humid, tempF);
+       sprintf(dataBuffer, "%0.2f-%0.2f", humid, tempF);
        IoTString * iValue = new IoTString(dataBuffer);
        
        t1->createNewKey(iKey, machineId);
@@ -176,7 +180,7 @@ void loop() {
        transStatusList->add(t1->commitTransaction());
        
        iKey->releaseRef();
-       iValue->releaseRef();*/
+       iValue->releaseRef();
        
        /*for (uint i = 0; i < transStatusList->size(); i++) {
                TransactionStatus * status = transStatusList->get(i);
@@ -191,9 +195,10 @@ void loop() {
        digitalWrite(PWRPIN, LOW);
 
        // TODO: Profiling
-       //Serial.print("Time end loop: ");
+       //Serial.print("Elapsed time: ");
        //Serial.println(micros());
-       //while(true) { }
+       //while(true);
+       
        System.sleep(SLEEP_MODE_DEEP, SLEEP_TIME);
 }