Daniel Blomdahl / Mbed 2 deprecated multiple_variable_temp

Dependencies:   MAX31855 SDFileSystem mbed

main.cpp

Committer:
DanielBlomdahl
Date:
2016-03-31
Revision:
7:9032b52be810
Parent:
6:76e8649a643f
Child:
8:882ccc7bbc8a

File content as of revision 7:9032b52be810:


#include "mbed.h"
#include "MAX31855.h"
#include "SDSaveFunction.h"

Serial pc(USBTX,USBRX);
SPI spi(NC,PTD3,PTD1);
SPI sdspi(PTE3,PTE1,PTE2);

MAX31855 thermometer1(spi,PTC4);
MAX31855 thermometer2(spi,PTC3);
AnalogIn solarPanel(PTB2);
Timer t;


int main()
{
   float temp1, temp2;
   float lastTime = 0;
   float dt = 0.5;
   float voltage = 0;
   float halfHour = 0;
   t.start();
   mountSDCard();
   openDataFile();
   float timeReset = 0;
   while (halfHour<=6) {
       
       if (t.read()>lastTime+dt) {
            lastTime = t.read();
            timeReset = 30*60*halfHour+lastTime;
            temp1 = thermometer1.read();
            temp2 = thermometer2.read();
            voltage = solarPanel.read(); // I will need to put the voltage reading in here.
            pc.printf("Voltage %f\t Temp %f\t Time %f\r\n", voltage, temp1, time);
            
            writeData(lastTime, temp1, voltage);
                if (t.read()>=30*60){
                    halfHour++;
                    t.reset();
            }
        }
       
   
   }
   closeDataFile();
}