Hello, I seem to have a problem with my data logger as it only seems to have a limit of 500 kilobytes in the file despite having 32 gigabytes of storage, It clears the lines before and continues to record at a certain amount of lines. For example after line 1000 it continues to record but deletes anything before that. Here is the code I used. I am also using SanDisk Micro SD Card FAT32 formatted.
//Tech Trends Shameer
//Temperature Data Log into SD Card
#include <SPI.h> // Include SPI library (needed for the SD card)
#include <SD.h> // Include SD library
#include <DHT.h> // Include DHT sensor library
File dataFile;
#define DHTPIN 4 // DHT11 data pin is connected to Arduino pin 4
#define DHTTYPE DHT11 // DHT11 sensor is used
#define sensorPower 7
#define sensorPin A0
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT library
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial)
; // wait for serial port to connect. Needed for native USB port only
Serial.print("Initializing SD card...");
if (!SD.begin())
{
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
delay(2000);
dht.begin();
}
uint16_t line = 1;
void loop() {
int moisture = analogRead (A0);
delay(1000);
// Read humidity
byte RH = dht.readHumidity();
//Read temperature in degree Celsius
byte Temp = dht.readTemperature();
dataFile = SD.open("DHT11Log.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (dataFile)
{
Serial.print(line);
Serial.print(": Aragon Alfonso Calunsag Nillas Ngamoy Al-ag Anino R.");
Serial.print(": STEM-B");
Serial.print(": Soil Moisture Index: ");
Serial.println(moisture);
Serial.print(": Temperature = ");
Serial.print(Temp);
Serial.print("°C, Humidity = ");
Serial.print(RH);
Serial.println("%");
// Write data to SD card file (DHT11Log.txt)
dataFile.print(line++);
dataFile.print(": Aragon Alfonso Calunsag Nillas Ngamoy Al-ag Anino R.");
dataFile.print(": STEM-B :>");
dataFile.print(": Soil Moisture Index: ");
dataFile.println(moisture);
dataFile.print(": Temperature = ");
dataFile.print(Temp);
dataFile.print("°C, Humidity = ");
dataFile.print(RH);
dataFile.println("%");
dataFile.close();
int readSensor (A0); {
digitalWrite(sensorPower, HIGH); // Turn the sensor ON
delay(1000); // Allow power to settle
int val = analogRead(A0); // Read the analog value form sensor
digitalWrite(sensorPower, LOW); // Turn the sensor OFF
return val; // Return analog moisture value
}
}
// if the file didn't open, print an error:
else
Serial.println("error opening DHT11Log.txt");
}
Help would be appreciated