SD card - datalogger with Nodemcu v3 and Max 31865 - not appending.....

Dears,

i am doing a project with Nodemcu v3, max 31865 and SD card datalogger. I am able to see the display on the phone with the IP address and also the temperature updates very well even visible in the serial monitor. The data needs to be logged into the SD card on every 2second, but the challenge which i face is; the file is freshly overwritten all the time with single value and not creating a log.

I have attached code along with this mail and please assist me how to solve this challenge? I google quite a bit but i couldnt understand the reason. Let me know how to proceed,

Test-6-AP-Max31865-C-SDCARD.txt (4.79 KB)

You open the file in setup() but never close it.

You open it again inside loop() but never close it. That means that each time through loop, you are trying to open it again.

If you are going to open it in setup(), then don’t open it again each time through loop().

I tried the part of closing the file in the void Loop() section and still no luck. i changed my sd card adaptor and still quite unlucky. Everytime it stores the last value displayed on the serial monitor.

i changed the probe to DHt22 and wrote a fresh code… still the same challenge. I formatted the sd card to fat32 and still the same challenge. I really dont understand where i am making a mistake here…

i can see the values in the serial monitor very well but just this data logging is driving me crazy…
/*
ESP8266 SD Card Module
CS D8 (HCS)
SCK D5 (HSCLK)
MOSI D7 (HMOSI)
MISO D6 (HMISO)
VCC VV (+5)
GND GND

*/
#include <SD.h>
#include <DHT.h>

#define DHTPIN D2
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

#define CS_PIN D8

float mytemp;
float myhumi;

void setup()
{
Serial.begin(9600);
Serial.print(“initializing SD…”);

dht.begin();
if (!SD.begin(CS_PIN)) {
Serial.println(“Card is not present - FAILED.”);
return;
}
Serial.println(“Card Initialized.”);
}

void loop()
{
myhumi= dht.readHumidity();
Serial.print("Humidity: ");
Serial.println(myhumi);
mytemp = dht.readTemperature();
Serial.print("Temperature: “);
Serial.println(mytemp);
delay(200);
File dataFile = SD.open(“LOG.txt”, FILE_WRITE);
if (dataFile) {
Serial.println(“The file was opened successfully.”);
dataFile.print(myhumi);
dataFile.print(” | ");
dataFile.println(mytemp);
dataFile.close();
}
else {
Serial.println(“failed to log into LOG.txt”);
}
}

after an extensive search i found the answer.....

refer the link below

in the above link the interesting part is that old SD.h file doesnot allow to append