putting strings to xbee
Dependencies: BMP085 SDFileSystem mbed JPEGCamera
Fork of SaibiCansat2014 by
Diff: main.cpp
- Revision:
- 11:3b13ec465f0f
- Parent:
- 9:3a2d25f4700b
- Child:
- 12:495d513bb022
diff -r 337ccaaec39c -r 3b13ec465f0f main.cpp --- a/main.cpp Fri Jul 18 08:51:01 2014 +0000 +++ b/main.cpp Fri Jul 18 09:54:25 2014 +0000 @@ -82,36 +82,46 @@ int loop_count = 0; while (1) { + FILE *fp = fopen("/sd/sensor.csv", "a"); loop_count += 1; //wait(1.5); //BOSH BMP085 Barometric pressure,temperature measurement accelerometer.getOutput(readings); - pc.printf("ADXL345 ------------------------\n"); - pc.printf(" %+4.2f, %+4.2f, %+4.2f\n", + //pc.printf("ADXL345 ------------------------\n"); + char buf[100]; + sprintf(buf, "X %+4.2f Y %+4.2f Z %+4.2f ", (float((int16_t)readings[0]+18)/256), (float((int16_t)readings[1]-4 )/256), (float((int16_t)readings[2]+22)/256)); - xbee.printf("X:%+4.2f Y:%+4.2f Z:%+4.2f ", - (float((int16_t)readings[0]+18)/256), - (float((int16_t)readings[1]-4 )/256), - (float((int16_t)readings[2]+22)/256)); + pc.printf(buf); + fwrite(buf, strlen(buf), 1, fp); + xbee.printf(buf); bmp085.update(); //ADXL 345 Acceleration measurement - pc.printf("\nBOSH BMP085 --------------------\n"); - pc.printf(" p:%6.2f hPa / t:%6.2f C\n", bmp085.get_pressure(), bmp085.get_temperature()); - xbee.printf("P:%6.2f T:%6.2f ", bmp085.get_pressure(), bmp085.get_temperature()); + //pc.printf("\nBOSH BMP085 --------------------\n"); + sprintf(buf, "P %6.2f T %6.2f ", bmp085.get_pressure(), bmp085.get_temperature()); + pc.printf(buf); + fwrite(buf, strlen(buf), 1, fp); + xbee.printf(buf); //CSDS Ambient light measurement P15 analog-in1 - pc.printf("Ambient light :: %f\n",ain_CDS*100); - xbee.printf("L%f ",ain_CDS*100); + sprintf(buf, "L %f ",ain_CDS*100); + pc.printf(buf); + fwrite(buf, strlen(buf), 1, fp); + xbee.printf(buf); //Humidity measurement P16 analog-in2 - pc.printf("Humidity :: %f\n",ain_Humedity*100); - xbee.printf("H:%f ",ain_Humedity*100); + sprintf(buf, "H %f ",ain_Humedity*100); + pc.printf(buf); + fwrite(buf, strlen(buf), 1, fp); + fwrite("\r\n", 2, 1, fp); + fclose(fp); + + xbee.printf(buf); //LM35DZ Temperature measurement P20 analog-in6 //this sensor does not work for now. disabled.