SEAN O CONNELL / thermostat_fan_demo-sensor_battery-2

Dependencies:   PinDetect libmDot mbed-rtos mbed-src

Fork of thermostat_fan_demo-sensor_battery-1 by SEAN O CONNELL

Files at this revision

API Documentation at this revision

Comitter:
socie123
Date:
Sat Oct 31 03:26:02 2015 +0000
Parent:
1:6011d8873701
Commit message:
version2

Changed in this revision

thermostat_fan_demo-sensor-d55b476ea5e6/libmDot.lib Show annotated file Show diff for this revision Revisions of this file
thermostat_fan_demo-sensor-d55b476ea5e6/main.cpp Show annotated file Show diff for this revision Revisions of this file
thermostat_fan_demo-sensor-d55b476ea5e6/mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
thermostat_fan_demo-sensor-d55b476ea5e6/mbed-src.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 6011d8873701 -r 8fd3285d3395 thermostat_fan_demo-sensor-d55b476ea5e6/libmDot.lib
--- a/thermostat_fan_demo-sensor-d55b476ea5e6/libmDot.lib	Tue Oct 20 21:26:23 2015 +0000
+++ b/thermostat_fan_demo-sensor-d55b476ea5e6/libmDot.lib	Sat Oct 31 03:26:02 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/MultiTech/code/libmDot/#5e805b567124
+http://developer.mbed.org/teams/MultiTech/code/libmDot/#0b4eb17d07ae
diff -r 6011d8873701 -r 8fd3285d3395 thermostat_fan_demo-sensor-d55b476ea5e6/main.cpp
--- a/thermostat_fan_demo-sensor-d55b476ea5e6/main.cpp	Tue Oct 20 21:26:23 2015 +0000
+++ b/thermostat_fan_demo-sensor-d55b476ea5e6/main.cpp	Sat Oct 31 03:26:02 2015 +0000
@@ -11,6 +11,7 @@
 #include "mbed.h"
 #include "mDot.h"
 #include "PinDetect.h"
+#include "MTSLog.h"
 
 mDot* dot;
 Ticker ledTick;
@@ -21,7 +22,7 @@
 PinDetect up_button(PB_1);        //A0 on Arduino base shield
 PinDetect down_button(PB_0);      //A1 on Arduino base shield
 AnalogIn temperatureSensor(PC_1); //A2 on Arduino base shield
-AnalogIn Battery(PA_5); //D3 on Arduino base shield
+AnalogIn Battery(PA_5); //D13 on Arduino base shield
 DigitalOut transmitLED(LED1);     
 DigitalOut buttonPressLED(PA_1);  //D6 on Arduino base shield
 
@@ -31,7 +32,7 @@
 static uint8_t config_frequency_sub_band = 1;
 
 //Global Variables
-static uint16_t voltage;
+//static uint16_t voltage;
 static uint16_t setPoint = 21;       //21 C is standard room temp
 static volatile bool timeToReadTemperature = true;
 static volatile bool timeToReadBattery = true;
@@ -90,7 +91,7 @@
     buttonPressLED = 1;
 
     // Configure timers
-    periodicSendTick.attach(&periodicSendTock, 5*60);
+    periodicSendTick.attach(&periodicSendTock, 1*60);
     temperatureMonitorTick.attach(&temperatureMonitorTock, 0.15);
     BatteryMonitorTick.attach(&BatteryMonitorTock, 0.15);
 
@@ -102,7 +103,7 @@
     up_button.setSampleFrequency();
     down_button.setSampleFrequency();
 
-    uint16_t temperature = 0;
+    float temperature = 0.0;
     while (1) {
         if (timeToReadTemperature) {
             uint16_t B = 4100;            //B value of the thermistor
@@ -127,32 +128,43 @@
             }
 
             timeToReadTemperature = false;
-   }  
+      }
       
-        
+             float voltage = 0.0;         
             //uint16_t voltage;
+                    //meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
+                    //meas = meas * 3300; // Change the value to be in the 0 to 3300 range
+                    //printf("measure = %.0f mV\n", meas);
+    
     while (1) {
         if (timeToReadBattery) {
-          voltage = Battery.read_u16(); 
+          //uint16_t analogReading2;
+          
+          voltage = Battery.read(); 
+          voltage = (voltage* 3300) *2/1000 ;
+        
+         // get the voltage of battery
+        // voltage=((65534-analogReading2)*4.00/analogReading2);
+     }
+          
             timeToReadBattery = false;
-        }
-
-
+  
         if (dataChanged) {
             char latestData[100];
             transmitLED = 1;
             sentSetPoint = setPoint;
-            sprintf(latestData, "temp: %d,set: %d,volt: %d", temperature, sentSetPoint, voltage);
+            sprintf(latestData, "temp:%.2f,volt:%.2f", temperature, voltage);
             printf("%s\r\n", latestData);
 
-
             if (send(latestData)) {
                 dataChanged = false;
             }
             transmitLED = 0;
         }
+        
     }
-}
+ 
+    }   
 }
 
 void ledTock() {
@@ -166,6 +178,8 @@
 
 void BatteryMonitorTock() {
     timeToReadBattery = true;
+    //dataChanged = true;
+    
 }
 
 void temperatureMonitorTock() {
@@ -286,7 +300,18 @@
         return false;
     }
     printf("Data sent!\r\n");
-    return true;
+         // in the 868 (EU) frequency band, we need to wait until another channel is available before transmitting again
+    //uint32_t sleep_time = std::max((uint32_t)10000, (uint32_t)dot->getNextTxMs()) / 1000;
+    //logInfo("going to sleep...");
+ 
+    // go to deepsleep and wake up automatically sleep_time seconds later
+    //ot->sleep(sleep_time, mDot::RTC_ALARM);
+ 
+    // go to deepsleep and wake up on rising edge of WKUP pin (PA0/XBEE_CTS/XBEE_DIO7)
+    // dot->sleep(0, mDot::INTERRUPT);
+ 
+    //return ; 
+    return true ;
 }
 
 void printError(mDot* dot, int32_t returnCode)
diff -r 6011d8873701 -r 8fd3285d3395 thermostat_fan_demo-sensor-d55b476ea5e6/mbed-rtos.lib
--- a/thermostat_fan_demo-sensor-d55b476ea5e6/mbed-rtos.lib	Tue Oct 20 21:26:23 2015 +0000
+++ b/thermostat_fan_demo-sensor-d55b476ea5e6/mbed-rtos.lib	Sat Oct 31 03:26:02 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#ef0a22cdf839
+http://mbed.org/users/mbed_official/code/mbed-rtos/#12552ef4e980
diff -r 6011d8873701 -r 8fd3285d3395 thermostat_fan_demo-sensor-d55b476ea5e6/mbed-src.lib
--- a/thermostat_fan_demo-sensor-d55b476ea5e6/mbed-src.lib	Tue Oct 20 21:26:23 2015 +0000
+++ b/thermostat_fan_demo-sensor-d55b476ea5e6/mbed-src.lib	Sat Oct 31 03:26:02 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-src/#30f9462b5296
+http://mbed.org/users/mbed_official/code/mbed-src/#a11c0372f0ba