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@7:9032b52be810, 2016-03-31 (annotated)
- Committer:
- DanielBlomdahl
- Date:
- Thu Mar 31 17:30:45 2016 +0000
- Revision:
- 7:9032b52be810
- Parent:
- 6:76e8649a643f
- Child:
- 8:882ccc7bbc8a
Success! First successful save of time, voltage, and temperature to the SD card and print on Terminal;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| DanielBlomdahl | 2:a2966bf82e8c | 1 | |
| DanielBlomdahl | 0:42e8fa13c7a9 | 2 | #include "mbed.h" |
| DanielBlomdahl | 2:a2966bf82e8c | 3 | #include "MAX31855.h" |
| DanielBlomdahl | 6:76e8649a643f | 4 | #include "SDSaveFunction.h" |
| DanielBlomdahl | 0:42e8fa13c7a9 | 5 | |
| DanielBlomdahl | 2:a2966bf82e8c | 6 | Serial pc(USBTX,USBRX); |
| DanielBlomdahl | 2:a2966bf82e8c | 7 | SPI spi(NC,PTD3,PTD1); |
| DanielBlomdahl | 7:9032b52be810 | 8 | SPI sdspi(PTE3,PTE1,PTE2); |
| DanielBlomdahl | 2:a2966bf82e8c | 9 | |
| DanielBlomdahl | 2:a2966bf82e8c | 10 | MAX31855 thermometer1(spi,PTC4); |
| DanielBlomdahl | 2:a2966bf82e8c | 11 | MAX31855 thermometer2(spi,PTC3); |
| DanielBlomdahl | 7:9032b52be810 | 12 | AnalogIn solarPanel(PTB2); |
| DanielBlomdahl | 1:8116bd9d3c46 | 13 | Timer t; |
| DanielBlomdahl | 0:42e8fa13c7a9 | 14 | |
| DanielBlomdahl | 7:9032b52be810 | 15 | |
| DanielBlomdahl | 0:42e8fa13c7a9 | 16 | int main() |
| DanielBlomdahl | 0:42e8fa13c7a9 | 17 | { |
| DanielBlomdahl | 1:8116bd9d3c46 | 18 | float temp1, temp2; |
| DanielBlomdahl | 1:8116bd9d3c46 | 19 | float lastTime = 0; |
| DanielBlomdahl | 1:8116bd9d3c46 | 20 | float dt = 0.5; |
| DanielBlomdahl | 7:9032b52be810 | 21 | float voltage = 0; |
| DanielBlomdahl | 7:9032b52be810 | 22 | float halfHour = 0; |
| DanielBlomdahl | 1:8116bd9d3c46 | 23 | t.start(); |
| DanielBlomdahl | 6:76e8649a643f | 24 | mountSDCard(); |
| DanielBlomdahl | 6:76e8649a643f | 25 | openDataFile(); |
| DanielBlomdahl | 7:9032b52be810 | 26 | float timeReset = 0; |
| DanielBlomdahl | 6:76e8649a643f | 27 | while (halfHour<=6) { |
| DanielBlomdahl | 7:9032b52be810 | 28 | |
| DanielBlomdahl | 7:9032b52be810 | 29 | if (t.read()>lastTime+dt) { |
| DanielBlomdahl | 7:9032b52be810 | 30 | lastTime = t.read(); |
| DanielBlomdahl | 7:9032b52be810 | 31 | timeReset = 30*60*halfHour+lastTime; |
| DanielBlomdahl | 7:9032b52be810 | 32 | temp1 = thermometer1.read(); |
| DanielBlomdahl | 7:9032b52be810 | 33 | temp2 = thermometer2.read(); |
| DanielBlomdahl | 7:9032b52be810 | 34 | voltage = solarPanel.read(); // I will need to put the voltage reading in here. |
| DanielBlomdahl | 7:9032b52be810 | 35 | pc.printf("Voltage %f\t Temp %f\t Time %f\r\n", voltage, temp1, time); |
| DanielBlomdahl | 7:9032b52be810 | 36 | |
| DanielBlomdahl | 7:9032b52be810 | 37 | writeData(lastTime, temp1, voltage); |
| DanielBlomdahl | 7:9032b52be810 | 38 | if (t.read()>=30*60){ |
| DanielBlomdahl | 7:9032b52be810 | 39 | halfHour++; |
| DanielBlomdahl | 7:9032b52be810 | 40 | t.reset(); |
| DanielBlomdahl | 7:9032b52be810 | 41 | } |
| DanielBlomdahl | 7:9032b52be810 | 42 | } |
| DanielBlomdahl | 7:9032b52be810 | 43 | |
| DanielBlomdahl | 7:9032b52be810 | 44 | |
| DanielBlomdahl | 6:76e8649a643f | 45 | } |
| DanielBlomdahl | 6:76e8649a643f | 46 | closeDataFile(); |
| DanielBlomdahl | 0:42e8fa13c7a9 | 47 | } |
