Hi, i am getting problem when using micro SD module for data logging. When i am trying the example code from arduino it working for like 10 second and ghibberish after that. I am having a long code but i will upload only the code relating to the SD card. It always cannot make the file and execute "Serial.println("Error opening rekamdata.txt!");".
Is this because the program? or the micro SD i am using is broken? the micro SD work fine using adaptor.
*P.S. i am doesn't know what topic this is related so i placed it on programming
#include <SPI.h>
#include <SD.h>
#define CS 4
File data;
void setup()
{
Serial.begin (9600);
Serial.print("Membaca SDcard...");
SPI.begin();
if (!SD.begin(CS))
{
Serial.println("Failed broken SD card!");
while (1);
}
Serial.println("Sucsses SD card!");
}
void loop ()
{
String Bensin_awals = String(Bensin_awal);
String Value_bensins = String(Value_bensin);
String Jaraks = String(Jarak);
//rekam data
data = SD.open("rekamdata.txt", FILE_WRITE);
if (data)
{
data.println("");
data.print("|Bensin_Awal=|");
data.print(Bensin_awals);
data.print("|Value_bensin=|");
data.print(Value_bensins);
data.print("|Jarak=|");
data.print(Jaraks);
data.close();
Serial.println("Data logged successfully.");
} else {
Serial.println("Error opening rekamdata.txt!");
}
}
are you using a 1, 2, or 4 gb card, or something larger? SD card modules have a capacity limit.
Filenames MUST be DOS 8.3. rekamdata.txt
is too long.
Capacity limit is 32gb or less.
I am using 2gb micro usd, and the module and the micro sd work fine with example code from arduino
Update
I am trying working in it and it's worked thank you no one have mentioned this before
i got a new problem the data that i got didn't getting print on sd card but it print on serial monitor. for your information my first data is on float form
b707
June 23, 2023, 3:59pm
8
Please show your latest code
hi, i am sorry just replying it i make it work with this code
#include <SD.h>
#include <SPI.h>
#define CS 4
File data;
float Bensin_awal = 33.33;
float Value_bensin = 44.44;
float Jarak = 55.55;
String Bensin_awals = "" ;
String Value_bensins = "" ;
String Jaraks = "" ;
void setup() {
Serial.begin (9600);
Serial.print("Membaca SDcard...");
SPI.begin();
if (!SD.begin(CS))
{
Serial.println("GAGAL/SDcard rusak!");
while (1);
}
Serial.println("Berhasil");
}
void loop() {
databaca();
}
void databaca() {
Bensin_awals = String(Bensin_awal);
Value_bensins = String(Value_bensin);
Jaraks = String(Jarak);
//rekam data
data = SD.open("data.txt",FILE_WRITE);
if (data)
{
data.println ("");
data.print("|Bensin_awal=|");
data.print(Bensin_awals);
data.print("|Value_bensin=|");
data.print(Value_bensins);
data.print("|Jarak=|");
data.print(Jaraks);
data.close();
Serial.println("Data logged successfully.");
} else {
Serial.println("Error opening rekamdata.txt!");
}
delay(1000);
}
system
Closed
December 25, 2023, 11:52am
10
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.