acd52832_TempRead example

Dependencies:   aconno_bsp mbed

Files at this revision

API Documentation at this revision

Comitter:
jurica238814
Date:
Tue Sep 20 12:10:53 2016 +0000
Commit message:
acd52832_TempRead example

Changed in this revision

aconno_bsp.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r b19f4bca544a aconno_bsp.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aconno_bsp.lib	Tue Sep 20 12:10:53 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/jurica238814/code/aconno_bsp/#f8335dffc2f4
diff -r 000000000000 -r b19f4bca544a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 20 12:10:53 2016 +0000
@@ -0,0 +1,50 @@
+/* Copyright (c) 2016 Aconno. All Rights Reserved.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+ 
+#include "mbed.h"
+#include "acd52832_bsp.h"
+
+#define V0 0.5    //In volts
+#define TC 0.01   //In volts
+#define VCC (3.3)
+
+#define RX  (p25)
+#define TX  (p26)
+
+// initialize serial port
+Serial pc(TX, RX);
+
+AnalogIn tempVoltage (ADC_TEMP);
+DigitalOut Hot(PIN_LED_RED);
+DigitalOut Cold(PIN_LED_BLUE);
+
+float getTemperature(float vout){
+    return ((float)vout - (float)V0)/((float)TC);
+}
+
+int main(){
+    
+    // Clear LEDs
+    Hot = 1;
+    Cold = 1;
+    
+    while(1){
+        pc.printf("Current temperature: %f\n", getTemperature(tempVoltage.read()*(float)VCC));
+        if (getTemperature(tempVoltage.read()*(float)VCC) > 22){
+            // Turn Hot ON
+            Hot = 0;
+            Cold = 1;
+        }
+        else{
+            // Turn Cold On
+            Hot = 1;
+            Cold = 0;
+        }
+        wait(1);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r b19f4bca544a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 20 12:10:53 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
\ No newline at end of file