Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Anoop S
#91189 Here is the code of my project where I am reading the serial data from arduino. The data coming from arduino is bytes which should be put into a spiffs file. Now the problem is spiffs.write() function is taking too much time to write and some of the bytes gets lost during this process. Please someone help.
Code: Select all#include "FS.h"
#include <SoftwareSerial.h>
SoftwareSerial s(D6,D5);

int flag = 0;

void setup() {
  s.begin(9600);
  Serial.begin(9600);
  SPIFFS.begin();
  SPIFFS.remove("/myFile.bin");
}

void loop() {
  uint8_t buff[512];
  File testFile = SPIFFS.open("/myFile.bin", "a+");
  if (s.available()>0){
    if (flag == 0){
      char ch = s.read();
      if (ch == ':'){
        flag = 1;
      }
    }
   
    else{
      s.readBytes(buff, sizeof(buff));
      //Serial.write(buff, sizeof(buff));
      testFile.write(buff, sizeof(buff));
      testFile.close();
    }
  }
}