Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SdFat version: 20160719
- Assuming the SD is the only SPI device.
- Edit DISABLE_CHIP_SELECT to disable another device.
- Assuming the SD chip select pin is: 10
- Edit SD_CHIP_SELECT to change the SD chip select pin.
- type any character to start
- init time: 748 ms
- Card type: SDHC
- Manufacturer ID: 0X28
- OEM ID: BE
- Product: 68BHO
- Version: 0.8
- Serial number: 0XD50B3A66
- Manufacturing date: 11/2010
- cardSize: 32026.66 MB (MB = 1,000,000 bytes)
- flashEraseSize: 128 blocks
- eraseSingleBlock: true
- OCR: 0XC0FF8000
- SD Partition Table
- part,boot,type,start,length
- 1,0X0,0XC,8192,62543872
- 2,0X0,0X0,0,0
- 3,0X0,0X0,0,0
- 4,0X0,0X0,0,0
- Volume is FAT32
- blocksPerCluster: 64
- clusterCount: 976992
- freeClusters: 976905
- freeSpace: 32011.22 MB (MB = 1,000,000 bytes)
- fatStartBlock: 9310
- fatCount: 2
- blocksPerFat: 7633
- rootDirStart: 2
- dataStartBlock: 24576
- type any character to start
- cardBegin failed
- SD errorCode: 0XA
- SD errorData: 0X5
- #include <FreeStack.h>
- #include <MinimumSerial.h>
- #include <SdFat.h>
- #include <SdFatConfig.h>
- #include <SdFatUtil.h>
- #include <SystemInclude.h>
- #include <Wire.h>
- #include <Adafruit_BMP085.h>
- const uint8_t chipSelect = SS;
- SdFat sd;
- SdFile file;
- Adafruit_BMP085 bmp;
- float startingAltitude;
- void setup() {
- Serial.begin(9600);
- if (!bmp.begin()) {
- Serial.println("Could not find a valid BMP085 sensor, check wiring!");
- }
- float totalAltitude = 0;
- for(int x = 0; x < 10; x++){
- totalAltitude += bmp.readAltitude(102505.98);
- }
- startingAltitude = totalAltitude / 10;
- Serial.println("*****DEBUG MESSAGES*****");
- // Alt
- Serial.print("Starting relative altitude: ");
- Serial.println(startingAltitude);
- // Temp
- Serial.print("Temperature = ");
- Serial.print(bmp.readTemperature());
- Serial.println(" *C");
- // Pressure
- Serial.print("Pressure at sealevel (calculated) = ");
- Serial.print(bmp.readSealevelPressure());
- Serial.println(" Pa");
- Serial.println("************************");
- // SD init
- char fileName[10] = "data.csv";
- delay(1000);
- while (!Serial) {
- SysCall::yield();
- }
- // Initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
- // breadboards. use SPI_FULL_SPEED for better performance.
- if (!sd.begin(chipSelect, SPI_HALF_SPEED)) {
- sd.initErrorHalt();
- }
- // Open file
- if (!file.open(fileName, O_CREAT | O_WRITE | O_EXCL)) {
- Serial.println("Error opening file!");
- }
- }
- void loop() {
- Serial.print("Real altitude = ");
- Serial.print(bmp.readAltitude(102505.98));
- Serial.println(" meters");
- float relAltitude = bmp.readAltitude(102505.98) - startingAltitude;
- Serial.print("Relative altitude = ");
- Serial.print(relAltitude);
- Serial.println(" meters");
- // Write into the SD card
- file.print(relAltitude);
- file.close();
- Serial.println();
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement