How do I adjust the timing of acquiring Modbus data after sensor operation?

  1. The ADS1115 sensor is activated and the result is stored in a variable via a specific operation on eight channels.
    (It takes about 800 ~ 850ms to reach this point. It will work again in 1 second.)

  2. Save the sensor value to MODBUS and wait for the call.

  3. Call MODBUS every 1 second to receive the value.

Problem: After receiving the value only for the first time of the call, after a few seconds, the time out error occurs and the value is not received.

Action: The MODBUS wait time is short as 150 ~ 200ms.
Let the ADS1115 sensor run once every 3 seconds
Increased MODBUS call waiting time to 1 second, but call failed

function timing in oscilloscope :

modbus simulator result : (success 358 / time out error 332)

void setup() {
  /* Serial */

  Serial1.begin(BAUDRATE);    // GPS
  Serial2.begin(BAUDRATE);    // LoRa
  Serial.begin(BAUDRATE);     // monitor
  rtc.begin(DateTime(F(__DATE__), F(__TIME__)));
  slave.cbVector[CB_READ_REGISTERS] = readAnalogIn;
  
  // set Serial and slave at baud 9600.
  slave.begin( BAUDRATE );

  /* Timer */
  Timer1.attachInterrupt(COUNT_1MS).start(1000);                            // every 1ms
  Timer2.attachInterrupt(ADC_CAL_START).start(1000000);                // every 1s
  Timer4.attachInterrupt(SAVE_LORA_BUFFER_AND_SDCARD).start(1000000); // every 1s
  Timer5.attachInterrupt(GPS_INIT).start(3600000000);  every 1 hour

  /* ADC */
  analogReadResolution(12);
  pinMode(SENSOR_00, INPUT);
  pinMode(SENSOR_01, INPUT);
  pinMode(SENSOR_02, INPUT);
  pinMode(SENSOR_03, INPUT);
  pinMode(SENSOR_04, INPUT);
  pinMode(SENSOR_05, INPUT);
  pinMode(SENSOR_06, INPUT);
  pinMode(SENSOR_07, INPUT);


  /* ADS1115 */
  ads1.getAddr_ADS1115(ADS1115_DEFAULT_ADDRESS);   // 0x48, 1001 000 (ADDR = GND)
  ads2.getAddr_ADS1115(ADS1115_VDD_ADDRESS);    // 0x49, 1001 001 (ADDR = VDD)
  ads1.setGain(GAIN_TWO);  // 2/3x gain +/- 6.144V  1 bit = 0.1875mV
  ads2.setGain(GAIN_TWO);
  ads1.setMode(MODE_CONTIN);       // Continuous conversion mode
  ads2.setMode(MODE_CONTIN);       // Continuous conversion mode
  ads1.setRate(RATE_250);       // 250SPS
  ads2.setRate(RATE_250);       // 250SPS
  ads1.setOSMode(OSMODE_SINGLE);   // Set to start a single-conversion
  ads2.setOSMode(OSMODE_SINGLE);   // Set to start a single-conversion

  ads1.begin();   // ADS1115 - 1 start
  ads2.begin();   // ADS1115 - 2 start

  SDCARD_CHECK_FAIL();
  
}



void COUNT_1MS(){ 
  count_value++;
  if(count_value == 3000){
    ADS1115_oneTime = false;
    count_value = 0;
  }
  if((ads1115_finish_value >= 1999) && (ads1115_finish_value <= 2001)){
      ads1115_finish_value = 0;
  }
}




/****************************************************************/
void loop() {

    if (!LoRaParameter_oneTime && !GPS_oneTime && !Setting_File_SDCARD_oneTime) {                      
      LoRa_SaveBuffer();
    }
    else if (LoRaParameter_oneTime && !GPS_oneTime && !Setting_File_SDCARD_oneTime) { 
      GPS_SaveBuffer();
    }
    else if (!Setting_File_SDCARD_oneTime && LoRaParameter_oneTime && GPS_oneTime){  
      Check_Setting_File_SDCARD();  
    } 
/*After the first boot, the above if code is not executed and the following code repeats the loop for 3 seconds. */
    else if (Setting_File_SDCARD_oneTime){ 
      if (!ADS1115_oneTime) {
        ADS1115_SaveBuffer();
      }else if(ADS1115_oneTime){
        ads1115_finish_value = count_value;
      }

      if((ads1115_finish_value > 2001) && (ads1115_finish_value <= 3000)){ 
        slave.poll();
      }
    } 
} // loop

I get values at first perfectly, but I get time out error after few seconds, it seems that the timing is still twisted. I do not know how to fix it.
If I remove the ads1115 function, all the sensors will function normally, and even if I call the Modbus value every 100ms, I get a value perfectly without error.

Post pictures to the forum, we don't follow temporary URLs to Google or any other provider of such services!

Post complete code, your code does not compile!

I cannot find any Modbus functionality in your code.