program for final combination of working pieces

Dependencies:   SDFileSystem TMP102 mbed ISL29125

Fork of TEMP_Test by Thomas Dale

Files at this revision

API Documentation at this revision

Comitter:
tdale19
Date:
Wed Mar 16 21:56:06 2016 +0000
Parent:
3:8ace1992bc93
Child:
5:958471753d5a
Commit message:
First test of Temp sensors

Changed in this revision

ISL29125.lib Show diff for this revision Revisions of this file
RGBSensor.cpp Show diff for this revision Revisions of this file
RGBSensor.h Show diff for this revision Revisions of this file
SDSave.cpp Show annotated file Show diff for this revision Revisions of this file
SDSave.h Show annotated file Show diff for this revision Revisions of this file
TEMPSensor.cpp Show annotated file Show diff for this revision Revisions of this file
TEMPSensor.h Show annotated file Show diff for this revision Revisions of this file
TMP102.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
--- a/ISL29125.lib	Sat Mar 12 01:42:13 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/frankvnk/code/ISL29125/#ae36914adb6d
--- a/RGBSensor.cpp	Sat Mar 12 01:42:13 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-#include "RGBSensor.h"
-#include "ISL29125.h"
-
-// The location of the sensor on the FRDM-K64F//
-
-ISL29125 RGB_sensor(I2C_SDA,I2C_SCL);
-
-void RGB_init() {
-    RGB_sensor.RGBmode(ISL29125_RGB);
-    RGB_sensor.Range(ISL29125_10KLX);
-    RGB_sensor.Resolution(ISL29125_16BIT);
-}
-void get_rgb(uint16_t rgb[]){
-    RGB_sensor.Read(ISL29125_RGB, rgb);
-}
--- a/RGBSensor.h	Sat Mar 12 01:42:13 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-#include "mbed.h"
-
-#ifndef RGBSensor   
-#define RGBSensor
-
-
-void RGB_init();
-void get_rgb(uint16_t rgb[]);
-
-#endif
--- a/SDSave.cpp	Sat Mar 12 01:42:13 2016 +0000
+++ b/SDSave.cpp	Wed Mar 16 21:56:06 2016 +0000
@@ -1,4 +1,3 @@
-
 #include "SDFileSystem.h"
 #include "mbed.h"
 extern Serial pc;
@@ -13,22 +12,27 @@
         fprintf(fp, "Time (s)\t temperature (c)\t UV (mW/cm2)\t red (mW/cm2)\t green (mW/cm2)\t blue (mW/cm2)\n\r");
 }
 
-void createDataFile_testRGB() {
+void createDataFile_testTEMP() {
     fp = fopen("/fs/dataLog.txt", "a");// open file and prepare to write
     if (fp == NULL) {
         pc.printf("Failed to open the file.\n\r");
     }
-    fprintf(fp, "Time (s)\t red (mW/cm2)\t green (mW/cm2)\t blue (mW/cm2)\n\r");
+    fprintf(fp, "Time (s)\t outside (C)\t inside (C)\t On Panel (C)\n\r");
 }
 
-void writeData(float time, float temp, float uv, uint16_t red, uint16_t green, uint16_t blue)
+void writeData(uint16_t time, float temp, float uv, uint16_t red, uint16_t green, uint16_t blue)
 {
     fprintf(fp, "%.2f \t %.2f \t %.2f \t %d \t %d \t %d\n\r", time, temp, uv, red, green, blue);
 }
 
-void writeData_testRGB(float time, uint16_t red, uint16_t green, uint16_t blue) {
+void writeData_testTEMP(uint16_t time, float outside, float inside, float panel) {
     //output values for each
-    fprintf(fp, "%.2f \t %d \t %d \t %d\n\r", time, red, green, blue);
+    fprintf(fp, "%.2f \t %d \t %d \t %d\n\r", time, outside, inside, panel);
+}
+
+void closeDataFile() {
+    fclose(fp);
+    fs.unmount();
 }
 
 bool mountSDCard() {
@@ -37,7 +41,3 @@
     return mountFailure;
 }
 
-void closeDataFile() {
-    fclose(fp);
-    fs.unmount();
-}
\ No newline at end of file
--- a/SDSave.h	Sat Mar 12 01:42:13 2016 +0000
+++ b/SDSave.h	Wed Mar 16 21:56:06 2016 +0000
@@ -2,9 +2,9 @@
 #define SAVE
 
 void createDataFile();
-void createDataFile_testRGB();
-void writeData(uint16_t time, uint16_t temp, uint16_t uv, uint16_t red, uint16_t green, uint16_t blue);
-void writeData_testRGB(float time, uint16_t red, uint16_t green, uint16_t blue);
+void createDataFile_testTEMP();
+void writeData(uint16_t time, float temp, float uv, uint16_t red, uint16_t green, uint16_t blue);
+void writeData_testTEMP(uint16_t time, float outside, float inside, float panel);
 void closeDataFile();
 bool mountSDCard();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TEMPSensor.cpp	Wed Mar 16 21:56:06 2016 +0000
@@ -0,0 +1,29 @@
+#include "TEMPSensor.h"
+#include "mbed.h"
+#include "TMP102.h"
+// The location of the sensor on the FRDM-K64F//
+
+I2C i2c(PTE25,PTE24);
+TMP102 thermometerInside(i2c,0x90);
+AnalogIn thermometerOutside1(PTB3);
+AnalogIn thermometerOutside2(PTC11);
+AnalogIn thermometerPanel1(PTB10);
+AnalogIn thermometerPanel2(PTC10);
+
+float get_outsideTemp()//function to return temperature readings from outside thermometers not in contact with the panels
+{
+    float outsideTemp = (thermometerOutside1.read()+ thermometerOutside2.read()) / 2; //average of two outside thermometer
+    return outsideTemp;
+}
+
+float get_insideTemp()//function to return data from inside on-boatd thermometer
+{
+    float insideTemp = thermometerInside.read(); // onboard in-pod thermometer
+    return insideTemp;
+ }       
+
+float get_panelTemp()//function to return data from the thermometers in contact with the solar panels
+{   
+    float panelTemp = (thermometerPanel1.read() + thermometerPanel2.read()) / 2; // average of two on-panel thermometer
+    return panelTemp;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TEMPSensor.h	Wed Mar 16 21:56:06 2016 +0000
@@ -0,0 +1,11 @@
+#include "mbed.h"
+
+#ifndef TEMPSensor   
+#define TEMPSensor
+
+
+float get_outsideTemp();//function declarations for temperature getters in TEMPSensor.cpp
+float get_insideTemp();
+float get_panelTemp();
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TMP102.lib	Wed Mar 16 21:56:06 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/JLarkin/code/TMP102/#f93c4ce1f910
--- a/main.cpp	Sat Mar 12 01:42:13 2016 +0000
+++ b/main.cpp	Wed Mar 16 21:56:06 2016 +0000
@@ -1,10 +1,11 @@
   //Authors: Tom, Nathan, Jeriah 
 #include "mbed.h"
-#include "RGBSensor.h"
+#include "TEMPSensor.h"
 #include "SDFileSystem.h"
 #include "SDSave.h"
 
 
+
 Timer t;
 DigitalOut ledBlue(LED_BLUE);
 DigitalOut ledRed(LED_RED);
@@ -16,22 +17,19 @@
     ledRed = 0;
     ledBlue = 1;
     wait(0.5);
-    RGB_init();
     t.start();
     pc.printf("The timer has started\n\r");
     if (mountSDCard()) {
         return -1; //end program with error status
     }
     pc.printf("The SD card is mounted\n\r");
-    createDataFile_testRGB();
-    uint16_t rgb[3];
     ledRed = 1;
+    createDataFile_testTEMP();
     while (t.read()<60) {
         if (t.read()>(lastTime+interval))  {
           lastTime=t.read();
-          get_rgb(rgb);
-          pc.printf("t = %.2f \t red = %d \t green = %d\t blue = %d\r\n",lastTime,rgb[0],rgb[1]);
-          writeData_testRGB(lastTime,rgb[0],rgb[1],rgb[2]);//send data to writeData in SDsave.cpp
+          pc.printf("t = %.2f \t outside = %d \t inside = %d\t panel = %d\r\n",lastTime,get_outsideTemp(),get_insideTemp(),get_panelTemp());//prints titles and data of Temp readings
+          writeData_testTEMP(lastTime,get_outsideTemp(),get_insideTemp(),get_panelTemp());//send data to writeData in SDsave.cpp
           //we will get all rgb readings through an array, with the corresponding integers going in order red, green, blue
         }
     }