How should I do?
File contents:
{"DeviceID":"ESP8266","Data":{"Serial":0,"Temp":26,"Hum":32,"Time":"082855"}}
{"DeviceID":"ESP8266","Data":{"Serial":1,"Temp":NULL,"Hum":NULL,"Time":":082955"}}
{"DeviceID":"ESP8266","Data":{"Serial":2,"Temp":25.5,"Hum":32.6,"Time":"083055"}}
{"DeviceID":"ESP8266","Data":{"Serial":3,"Temp":26.7,"Hum":31.2,"Time":"083155"}}
{"DeviceID":"ESP8266","Data":{"Serial":4,"Temp":NULL,"Hum":28,"Time":"083355"}}
{"DeviceID":"ESP8266","Data":{"Serial":5,"Temp":25,"Hum":27,"Time":"083455"}}
{"DeviceID":"ESP8266","Data":{"Serial":6,"Temp":25.3,"Hum":29.6,"Time":"083655"}}
STEP:
1.Read JSON file from SD card.
2.Read one line at a time, after the conversion is completed, read the next line. Example: First time I read 1 to 5 lines, next time read data from 6 to 10 lines.
3.New JSON struct like this:
Code:
#include "SD.h"
#include "FS.h"
#define SD_CS 15
StaticJsonDocument <1024> doc;
File myFile;
void loadData(){
File file = SD.open("myTest.txt", FILE_READ);
DeserializationError error = deserializeJson(doc, file);
if (error)
Serial.println(F("Failed to read file, using default configuration"));
}
void setup(){
Serial.begin(115200);
Serial.println();
Serial.println();
Serial.printf("SD card beging...\n");
if (!SD.begin(SD_CS)){
Serial.printf("SD card Mount Failed...\n");
}
else{
Serial.printf("SD card already...\n");
}
Serial.println();
loadData();
}
void loop(){
}