Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MAX31855 SDFileSystem mbed
main.cpp
- Committer:
- DanielBlomdahl
- Date:
- 2016-05-15
- Revision:
- 11:1e56b710b568
- Parent:
- 10:f5d4d5e30b9b
File content as of revision 11:1e56b710b568:
#include "mbed.h"
#include "MAX31855.h"
#include "SDSaveFunction.h"
Serial pc(USBTX,USBRX);
SPI spi(NC,PTD3,PTD1);
SPI sdspi(PTE3,PTE1,PTE2);
DigitalIn eject(PTA4); // INT2
DigitalOut greenLed(LED2);
DigitalOut redLed(LED1);
MAX31855 thermometer1(spi,PTB9);
MAX31855 thermometer2(spi,PTD0);
AnalogIn solarPanel(PTB2);
Timer t;
int main()
{
const int secondsHalfHour = 30*60; //number of seconds in 1 half hour
redLed = 0;
greenLed = 1;
wait(0.5);
redLed = 1;
greenLed = 0;
wait(0.5);
greenLed = 1;
float temp1, temp2;
float lastTime = 0;
float dt = 0.5;
float voltage = 0;
float halfHour = 0;
float totalTime;
t.start();
mountSDCard();
openDataFile();
while (halfHour<6) {
if (eject == 0) {
greenLed = 0;
wait(0.5);
greenLed = 1;
break;
}
totalTime = secondsHalfHour*halfHour + t.read();
if (totalTime>lastTime+dt) {
lastTime = totalTime;
temp1 = thermometer1.read();
wait(.02);
temp2 = thermometer2.read();
voltage = 3.3*(solarPanel.read());
pc.printf("Voltage %f\t Temp1 %f\t Temp2 %f\t Time %f\r\n", voltage, temp1, temp2, lastTime);
writeData(lastTime, temp1, temp2, voltage);
}
if (t.read()>=secondsHalfHour){
halfHour++;
t.reset();
}
}
closeDataFile();
greenLed = 0;
while(true){
}
}
