BMP085を入れました
Dependencies: BMP085_2 SDFileSystem mbed
Diff: main.cpp
- Revision:
- 4:5872b6ac17e5
- Parent:
- 3:37b076ff27a9
- Child:
- 5:9cfdae50349e
diff -r 37b076ff27a9 -r 5872b6ac17e5 main.cpp --- a/main.cpp Sun Jul 28 07:29:25 2013 +0000 +++ b/main.cpp Tue Jul 30 11:24:17 2013 +0000 @@ -1,10 +1,11 @@ #include "mbed.h" -//#include "SDFileSystem.h" +#include "SDFileSystem.h" +#include "bmp085.h" -//SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board +SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board Serial xbee(p13,p14); // tx, rx /*Timeout dater;*/ -LocalFileSystem local("local"); +//LocalFileSystem local("local"); Timer timer; AnalogIn temp_in(p20); @@ -13,19 +14,24 @@ AnalogIn acc_z(p19); AnalogIn v_out(p16); AnalogIn light_in(p15); +BMP085 bmp085(p28, p27); + + int main() { float r_temp, temp; float vo,ax,ay,az, light; - FILE* fp = fopen("/local/CanSat.txt", "a"); + //FILE* fp = NULL; + //fp = fopen("/sd/CanSat.txt", "a"); unsigned count = 0; - time_t epoch = 0; + + //time_t epoch = 0; - fprintf(fp, "E %d \r", epoch); + //fprintf(fp, "E %d \r", epoch); timer.start(); - + while(1){ //epoch = time(NULL); float seconds = timer.read(); @@ -36,18 +42,24 @@ az = acc_z/10; light = light_in/10*33; r_temp = temp_in * 3.3 * 100 ; - + bmp085.update(); + P = bmp085.get_pressure(); + t = bmp085.get_temperature(); + + if (fp != NULL) { + fprintf(fp, "S %f ", seconds); + fprintf(fp, "T %5.2f ",r_temp); + fprintf(fp, "H %5.2f ",(vo*8-6)/25); + fprintf(fp, "X %5.2f ",(ax*33-1.65)/0.66); + fprintf(fp, "Y %5.2f ",(ay*33-1.65)/0.66); + fprintf(fp, "Z %5.2f ",(az*33-1.65)/0.66); + fprintf(fp, "L %5.2f ",light); + fprintf(fp, "P %6.2f ", P); + fprintf(fp, "t %6.2f ", t); + fprintf(fp,"\n"); + }//if - fprintf(fp, "S %f ", seconds); - fprintf(fp, "T %5.2f ",r_temp); - fprintf(fp, "H %5.2f ",(vo*8-6)/25); - fprintf(fp, "X %5.2f ",(ax*33-1.65)/0.66); - fprintf(fp, "Y %5.2f ",(ay*33-1.65)/0.66); - fprintf(fp, "Z %5.2f ",(az*33-1.65)/0.66); - fprintf(fp, "L %5.2f",light); - fprintf(fp,"\n"); - - if (count % 100 == 0) { + if (count % 100 == 0) { xbee.printf("S %f ", seconds); xbee.printf("T %5.2f ",r_temp); xbee.printf("H %5.2f ",((vo*8-6)/25)); @@ -55,6 +67,8 @@ xbee.printf("Y %5.2f ",(ay*33-1.65)/0.66); xbee.printf("Z %5.2f ",(az*33-1.65)/0.66); xbee.printf("L %5.2f",light); + xbee.printf("P %6.2f ", P); + xbee.printf("t %6.2f ", t); xbee.printf("\n\r"); }//if