Arduino restarts by itself while executing the program

Hello,
Im working on a project where on one side I have some sensors connected on UNO as well as SD module and on other side I jave UNO with tft display. My goal is to be able to display the current sensor data on UNO with tft as well as store the data in csv file on SD card on UNO with SD module and sensors. My plan to communicate between two UNOs if to send json file via serial communication using software serial. One of the sensors (pms5003) also uses serial comm to display and read data from it. I have tried each segment of project code solo and it works well by itself but when I connect everything together the program or rather UNO with SD module just starts to reset (Im checking this via Serial prints on serial monitor, I have put various serial prints with numbers or messages so I can check where the code stops working).
The code from first Arduino that has SD module and sensors is this:

#include <SoftwareSerial.h>
#include <Adafruit_CCS811.h>
#include <dht.h>
#include <SPI.h>
#include <SD.h>
#include <ArduinoJson.h>

dht DHT;
#define DHT22_PIN 5
Adafruit_CCS811 ccs;
File myFile;
int aqi;
int pm1=0, pm2_5=0, pm10=0;
float t,h;
int co2,voc;
SoftwareSerial pmsSerial (2, 3);
SoftwareSerial linkSerial(7, 6);

struct pms5003data {
      uint16_t framelen;
      uint16_t pm10_standard, pm25_standard, pm100_standard;
      uint16_t pm10_env, pm25_env, pm100_env;
      uint16_t particles_03um, particles_05um, particles_10um, particles_25um, particles_50um, particles_100um;
      uint16_t unused;
      uint16_t checksum;
    };
     
    struct pms5003data data;

    boolean readPMSdata(Stream *s) {
      if (! s->available()) {
        return false;
      }
      // Read a byte at a time until we get to the special '0x42' start-byte
      if (s->peek() != 0x42) {
        s->read();
        return false;
      }
     
      // Now read all 32 bytes
      if (s->available() < 32) {
        return false;
      }
        
      uint8_t buffer[32];    
      uint16_t sum = 0;
      s->readBytes(buffer, 32);
     
      // get checksum ready
      for (uint8_t i=0; i<30; i++) {
        sum += buffer[i];
      }
     

      for (uint8_t i=2; i<32; i++) {
        Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", ");
      }
      Serial.println();
      
      
      // The data comes in endian'd, this solves it so it works on all platforms
      uint16_t buffer_u16[15];
      for (uint8_t i=0; i<15; i++) {
        buffer_u16[i] = buffer[2 + i*2 + 1];
        buffer_u16[i] += (buffer[2 + i*2] << 8);
      }
     
      // put it into a nice struct :)
      memcpy((void *)&data, (void *)buffer_u16, 30);
     
      if (sum != data.checksum) {
        Serial.println("Checksum failure");
        return false;
      }
      // success!
      return true;
    }


void setup() {
  
  Serial.begin(115200);
  ccs.begin();
  pmsSerial.begin(9600); //UART to sensor
  linkSerial.begin(4800);
  
  if (!SD.begin(4)) {
    Serial.println(F("initialization failed!"));
    while (1);
  }
   Serial.println(F("initialization done."));
  delay(5000);
  SD.remove("data.csv");
  myFile = SD.open("data.csv", FILE_WRITE);

  if (myFile) {
     Serial.println("2");
    myFile.print("TEMPERATURA");
    myFile.print(",");
    myFile.print("VLAGA");
    myFile.print(",");
    myFile.print("CO2");
    myFile.print(",");
    myFile.print("VOC");
    myFile.print(",");
    myFile.print("PM 1");
    myFile.print(",");
    myFile.print("PM 2.5");
    myFile.print(",");
    myFile.print("PM10");
    myFile.print(",");
    myFile.println("AQI");
   
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println(F("error opening data.csv"));
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  StaticJsonDocument<300> doc;
  if(ccs.available())
  {
  if (!ccs.readData()){
  Serial.println(F("4"));
  int chk = DHT.read22(DHT22_PIN);
  t = DHT.temperature;
  h = DHT.humidity;
  co2 = ccs.geteCO2();
  voc = ccs.getTVOC();
  aqi = analogRead(0);
  pmsSerial.listen();
  if (readPMSdata(&pmsSerial)) {
  pm1 = data.pm10_standard;
  pm2_5 = data.pm25_standard;
  pm10 = data.pm100_standard;}
  
  doc["temp"] = t;
  doc["hum"] = h;
  doc["co2"] = co2;
  doc["voc"] = voc;
  doc["pm1"] = pm1;
  doc["pm2.5"] = pm2_5;
  doc["pm10"] = pm10;
  doc["aqi"] = aqi;
  linkSerial.listen();
  serializeJson(doc, linkSerial);
  Serial.println(F("5"));
  myFile = SD.open("data.csv", FILE_WRITE);
  if (myFile) {
    Serial.println(F("6"));
    myFile.print(t);
    myFile.print(",");
    myFile.print(h);
    myFile.print(",");
    myFile.print(co2);
    myFile.print(",");
    myFile.print(voc);
    myFile.print(",");
    myFile.print(pm1);
    myFile.print(",");
    myFile.print(pm2_5);
    myFile.print(",");
    myFile.print(pm10);
    myFile.print(",");
    myFile.println(aqi);
    myFile.close();
  }
    else {
    Serial.println(F("Error opening file in setup."));
  }
  }}
  Serial.println(F("7"));
  delay(2000);
}

Ill need to make 2 posts because of lack of characters.

Your problem has all the hallmarks of writing outside the bounds of an array

The code for the receiving arduino with tft screen is:

#include <SoftwareSerial.h>[color=#222222][/color]
#include <ArduinoJson.h>[color=#222222][/color]
#include <Adafruit_GFX.h>[color=#222222][/color]
#include <MCUFRIEND_kbv.h>[color=#222222][/color]
MCUFRIEND_kbv tft;[color=#222222][/color]
SoftwareSerial linkSerial(2, 3); // RX, TX[color=#222222][/color]
[color=#222222][/color]
#define BLACK   0x0000[color=#222222][/color]
#define BLUE    0x001F[color=#222222][/color]
#define RED     0xF800[color=#222222][/color]
#define GREEN   0x07E0[color=#222222][/color]
#define CYAN    0x07FF[color=#222222][/color]
#define MAGENTA 0xF81F[color=#222222][/color]
#define YELLOW  0xFFE0[color=#222222][/color]
#define WHITE   0xFFFF[color=#222222][/color]
[color=#222222][/color]
void setup(void)[color=#222222][/color]
{[color=#222222][/color]
    Serial.begin(115200);[color=#222222][/color]
    uint16_t ID = tft.readID();[color=#222222][/color]
    Serial.print("TFT ID = 0x");[color=#222222][/color]
    Serial.println(ID, HEX);[color=#222222][/color]
    tft.begin(ID);[color=#222222][/color]
    tft.setRotation(0);            //PORTRAIT[color=#222222][/color]
    tft.fillScreen(BLACK);[color=#222222][/color]
    while (!Serial) continue;[color=#222222][/color]
    linkSerial.begin(4800);[color=#222222][/color]
}[color=#222222][/color]
[color=#222222][/color]
/* two buttons are quite simple[color=#222222][/color]
 */[color=#222222][/color]
void loop(void)[color=#222222][/color]
{[color=#222222][/color]
  if (linkSerial.available())[color=#222222][/color]
  {[color=#222222][/color]
    // Allocate the JSON document[color=#222222][/color]
    // This one must be bigger than for the sender because it must store the strings[color=#222222][/color]
    StaticJsonDocument<300> doc;[color=#222222][/color]
[color=#222222][/color]
    // Read the JSON document from the "link" serial port[color=#222222][/color]
    DeserializationError err = deserializeJson(doc, linkSerial);[color=#222222][/color]
[color=#222222][/color]
    if (err == DeserializationError::Ok)[color=#222222][/color]
    {[color=#222222][/color]
      float t = doc["temp"].as<float>();[color=#222222][/color]
      float h = doc["hum"].as<float>();[color=#222222][/color]
      int co2 = doc["co2"].as<int>();[color=#222222][/color]
      int voc = doc["voc"].as<int>();[color=#222222][/color]
      int pm1 = doc["pm1"].as<int>();[color=#222222][/color]
      int pm2_5 = doc["pm2.5"].as<int>();[color=#222222][/color]
      int pm10 = doc["pm10"].as<int>();[color=#222222][/color]
      int aqi = doc["aqi"].as<int>();[color=#222222][/color]
      Serial.println(t);[color=#222222][/color]
      Serial.println(co2);[color=#222222][/color]
      Serial.println(pm1);[color=#222222][/color]
      Serial.println(aqi);[color=#222222][/color]
     [color=#222222][/color]
       [color=#222222][/color]
      tft.setTextSize(2);[color=#222222][/color]
      tft.setTextColor(WHITE,BLACK);[color=#222222][/color]
      tft.setCursor(5, 5);[color=#222222][/color]
      tft.print("Temperatura= ");[color=#222222][/color]
      tft.println(t);[color=#222222][/color]
      tft.print("Vlaga = ");[color=#222222][/color]
      tft.println(h);[color=#222222][/color]
      tft.print("C02= ");[color=#222222][/color]
      tft.println(co2);[color=#222222][/color]
      tft.print("TVOC = ");[color=#222222][/color]
      tft.println(voc);[color=#222222][/color]
      tft.print("PM1= ");[color=#222222][/color]
      tft.println(pm1);[color=#222222][/color]
      tft.print("PM2.5 = ");[color=#222222][/color]
      tft.println(pm2_5);[color=#222222][/color]
      tft.print("PM10= ");[color=#222222][/color]
      tft.println(pm10);[color=#222222][/color]
      tft.print("AQI = ");[color=#222222][/color]
      tft.print(aqi);[color=#222222][/color]
    }[color=#222222][/color]
    else[color=#222222][/color]
    {[color=#222222][/color]
      // Print error to the "debug" serial port[color=#222222][/color]
      Serial.print("deserializeJson() returned ");[color=#222222][/color]
      Serial.println(err.c_str());[color=#222222][/color]
 [color=#222222][/color]
      // Flush all bytes in the "link" serial port buffer[color=#222222][/color]
      while (linkSerial.available() > 0)[color=#222222][/color]
        linkSerial.read();[color=#222222][/color]
    }[color=#222222][/color]
  }

P.S.
The UNOs are connected via cca 1.5-2m cable to software serial pins tx-rx rx-tx. The connection was tested with some random sentences and sending json file and it worked well.

UKHeliBob:
Your problem has all the hallmarks of writing outside the bounds of an array

So can I just enlarge json file size?

tuadru:
So can I just enlarge json file size?

Sorry, but I know nothing about processing json files

On a different subject, I see that you are trying to use 2 instances of SoftwareSerial and I have never seen that used successfully

How far apart are the two UNO's? Would be a lot simpler to do this on a single board such as a Mega.

You may be running low on ram, with the SD card buffer, three serial buffers (hardware serial plus two instances of software serial), and the json buffer.

Put the data in a struct and send between the two UNO's as binary data, no need for the json. Also consider using I2C instead of serial between the UNO's.

UKHeliBob:
Sorry, but I know nothing about processing json files

On a different subject, I see that you are trying to use 2 instances of SoftwareSerial and I have never seen that used successfully

I have read some topic where it says it shouldnt be a problem using multiple software serials if u listen to correct one at the time u need it. Never tested it myself.
UNOs are cca 2 meters apart if not less. I dont want them to be together cause I need one "sensor box" and other display module to be separated. I had some memory warning problems but I transfered serial prints to program memory instead of ram with Serial.print(F()); so I get no more memory warnings. I already have device that uses i2c interface and in past I had trouble with using 2 or more i2c devices at the same time (couldnt find proper address etc.)

UPDATE:
It indeed seems to be software serial issue. Even though I included .listen() when i need to switch between the two software serial links it still resets my arduino. Just to test if that is the problem I commented out sensor code that uses serial communication and tried sending other data and it worked fine. Since I currently only have UNOs at my disposal and I really need that sensor that uses serial communication does anyone with previous experience of using 2 software serial links have any advice on if it is possible for me to do this?