ESP8266 NOrMCU +Serial.available , Need to interrupt if serial available

Preformatted textHello ,
I am using Serial communication using ESP 8266 nord mcu. My main program is too lengthy that's why i using demo code to express my problems.

  1. When ever Serial not available in need to perform a task which is less important. if Any data Available i have to perform very important task . Assume that Controller doing less important task mean while i received data on RX in this condition i want left this less important task incomplete and must do very Priority task first. please suggest how do(use software interrupt)?????

2.when ever i received data which is not use full my program got poss at Serial.readString(); until another data come to serial.


String data="";


void setup() {
 
Serial.begin(960);

}

void loop() {
top:
  if Serial.available()>0{//-------fisrt funtion it must run when data available on RX
  Serial.println("Data recived from web it "):
  data=Serial.readString();
 if( Serial.readString()==NULL)goto top;
  if(data.length();==23){
    println("fist weigtment got ");
   //in my main programm is send data on web server 
    }
    
  if(data.length();==33){
    println("Second weigtment got ");
   //in my main programm is send data on web server 
    }
    goto top;
    
    }

    if(! Serial.available()){//------this funtion must not work if any data avilable on RX
     println("Doing less impoortant work "); 
    }
    
    }

Inside the less important tasks call a checkup function that checks for Serial.avalable and calls eventual high priority tasks.
What do You intend to do if less important tasks are called from the serial input?
I don't think You are an experienced interrupt user....

Break your not-so-important task up in small pieces and execute one piece, next check serial and do what is needed, next execute the next piece of the not-so-important task, next check serial again and so on.

Something to read up on is finite state machines to execute the small pieces of the not-so-important task.

Stay away from delay(); and there is hardly ever a need for goto (this is not a scenario for goto).

No, you misunderstand what interrupts are. :upside_down_face:

It's all a matter of organising your code properly.

1 Like

sir ,
1.In Very Important task :- i follows these steps
Read Serial>cheek right data or not> cheek WiFi connection >if available send on server Else >save to EEPROM.
2.IN less important :- i follows these steps
raed EEprom >Cheek WiFi >if available send saved data to Server.
During posting data On web server . Any data Received on RX i have to save it first ....because if i miss it data i can't got it again.
So i request to every one ,
please provide solution . I don't want to miss Rx data.
i know very well that i am not a expert coder. Many people are tell me every thing but not give any wrathful solution .
please help

sir i try it ,
but during getting Response from web Severe . i miss the data.

Post your full real code so we can see what you're doing.

#include <ESP8266WiFi.h>
#include <Wire.h>
#include <ArduinoHttpClient.h>
#include <ESP8266WebServer.h>
#include <WiFiClient.h>
#include <EEPROM.h>
#define EEPROM_I2C_ADDRESS 0x50
#define trigger D0
#define LED D3
#define power D6
#define VEH_NUM         10
#define VEH_TYPE        8
#define NAME            16
#define ADD             10
#define ITEM            8
#define CHARGES         5
#define RST             5
#define WET             6
#define KEY             13
#define TIME            16
#define Ad_lsb_1st      65533
#define Ad_msb_1st      65532
#define Ad_2nd_lsb      65530
#define Ad_2nd_msb      65529
#define Msb_Count1st    65528
#define Lsb_Count1st    65527
#define Msb_Count2nd    65526
#define Lsb_Count2nd    65525
#define Msb_Count3rd    65521
#define Lsb_Count3rd    65520
#define Ad_man_lsb      65518
#define Ad_man_msb      65517
#define rst_add         65500
#define Key_msb         9001
#define Key_lsb         9002
#define Strt_1st_wet    9004
#define Stop_1st_wet    26604
#define Strt_2nd_wet    26606
#define Stop_2d_wet     45506
#define Strt_man_wet    45508
#define Stop_man_wet    65410
//---host

String a;
String p;
//Variables
int i = 0;

const char* ssid = "text";
const char* passphrase = "text";
String st;
String content;

  String epass = "";
String esid;
//Function Decalration
bool testWifi(void);
void launchWeb(void);
void setupAP(void);
ESP8266WebServer server(80);


String search="";
unsigned short int add,lastadd,offadd,from,temp,count_1st,count_2nd,count_3rd; 
String  data ="";
String  charges ="";
String  charges_2 ="";
String  first_weight_time ="";
String  gross ="";
String  item="";
String  net ="";
String  party_address="";
String  party_name="";
String  rstNo ="";
String  second_weight_time ="";
String  tare="";
String  vehicle_type =""; 
String  vehile_no="";
String  weighbridgeId ="012555";
String  local_rst_no ="";
String  lable="";
String  chek="";

String  Wet_type="";
byte high,low;
const char serverAddress[] = "jbcweighingscale.com"; 
int port = 80;
String postData="";
String path ="/admin_ws/api.php/PARAM-data"; 
String contentType ="application/x-www-form-urlencoded";
int statusCode,state,k,l,s,m,n,v;
String response="";

WiFiClient wifi;
HttpClient client = HttpClient(wifi, serverAddress, port);
int status = WL_IDLE_STATUS;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Wire.begin(D2,D1);
  Serial.println("Disconnecting previously connected WiFi");
  WiFi.disconnect();
  EEPROM.begin(512); //Initialasing EEPROM
  delay(10);
  Serial.println("Startup");
  pinMode(LED,OUTPUT);
  pinMode(trigger,INPUT_PULLUP);
  pinMode(power,OUTPUT);
  digitalWrite(power,LOW);
  //---------------------------------------- Read eeprom for ssid and pass
  Serial.println("Reading EEPROM ssid");
  for (int i = 0; i < 32; ++i)
  {
    esid += char(EEPROM.read(i));
  }
  Serial.println();
  Serial.print("SSID: ");
  Serial.println(esid);
  Serial.println("Reading EEPROM pass");

  for (int i = 32; i < 96; ++i)
  {
    epass += char(EEPROM.read(i));
  }
  Serial.print("PASS: ");
  Serial.println(epass);
WiFi.begin(esid.c_str(), epass.c_str());
if(digitalRead(trigger)==0){
 
  digitalWrite(power,HIGH);
  digitalWrite(LED,HIGH);
  launchWeb();
    setupAP();
}
while (digitalRead(trigger)==0)
  {
    Serial.println("Seting wifi SSID ,Treigger on");
    delay(100);
    server.handleClient();
}
   delay(500);    
   Serial.println("welcome");
  
}
//----------------------------------------------- Fuctions used for WiFi credentials saving and connecting to it which you do not need to change 
bool testWifi(void)
{
  int c = 0;
  Serial.println("Waiting for Wifi to connect");
  while ( c < 20 ) {
    if (WiFi.status() == WL_CONNECTED)
    {
      return true;
    }
    delay(500);
    Serial.print("*");
    c++;
  }
  Serial.println("");
  Serial.println("Connect timed out, opening AP");
  return false;
}

void launchWeb()
{
  Serial.println("");
  if (WiFi.status() == WL_CONNECTED)
    Serial.println("WiFi connected");
  Serial.print("Local IP: ");
  Serial.println(WiFi.localIP());
  Serial.print("SoftAP IP: ");
  Serial.println(WiFi.softAPIP());
  createWebServer();
  // Start the server
  server.begin();
  Serial.println("Server started");
}

void setupAP(void)
{
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);
  int n = WiFi.scanNetworks();
  Serial.println("scan done");
  if (n == 0)
    Serial.println("no networks found");
  else
  {
    Serial.print(n);
    Serial.println(" networks found");
    for (int i = 0; i < n; ++i)
    {
      // Print SSID and RSSI for each network found
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.print(")");
      Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
      delay(10);
    }
  }
  Serial.println("");
  st = "<ol>";
  for (int i = 0; i < n; ++i)
  {
    // Print SSID and RSSI for each network found
    st += "<li>";
    st += WiFi.SSID(i);
    st += " (";
    st += WiFi.RSSI(i);

    st += ")";
    st += (WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*";
    st += "</li>";
  }
  st += "</ol>";
  delay(100);
  WiFi.softAP("JBC Server", "jbc12345");
  Serial.println("softap");
  launchWeb();
  Serial.println("over");
}

void createWebServer()
{
 {
    server.on("/", []() {

      IPAddress ip = WiFi.softAPIP();
      String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
      content = "<!DOCTYPE HTML>\r\n<html>Hello from JBC ";
      content += "<form action=\"/scan\" method=\"POST\"><input type=\"submit\" value=\"scan\"></form>";
      content += ipStr;
      content += "<p>";
      content += st;
      content += "</p><form method='get' action='setting'><label>SSID: </label><input name='ssid' length=32><input name='pass' length=64><input type='submit'></form>";
      content += "</html>";
      server.send(200, "text/html", content);
    });
    server.on("/scan", []() {
      //setupAP();
      IPAddress ip = WiFi.softAPIP();
      String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);

      content = "<!DOCTYPE HTML>\r\n<html>go back";
      server.send(200, "text/html", content);
    });

    server.on("/setting", []() {
      String qsid = server.arg("ssid");
      String qpass = server.arg("pass");
      if (qsid.length() > 0 && qpass.length() > 0) {
        Serial.println("clearing eeprom");
        for (int i = 0; i < 96; ++i) {
          EEPROM.write(i, 0);
        }
        Serial.println(qsid);
        Serial.println("");
        Serial.println(qpass);
        Serial.println("");

    Serial.println("writing eeprom ssid:");
    for (int i = 0; i < qsid.length(); ++i)
{
    EEPROM.write(i, qsid[i]);
    Serial.print("Wrote: ");
    Serial.println(qsid[i]);
        }
    Serial.println("writing eeprom pass:");
    for (int i = 0; i < qpass.length(); ++i)
        {
    EEPROM.write(32 + i, qpass[i]);
    Serial.print("Wrote: ");
    Serial.println(qpass[i]);
        }
    EEPROM.commit();

    content = "{\"Success\":\"saved to eeprom... reset to boot into new wifi\"}";
    statusCode = 200;
    while(digitalRead(trigger)==0){
    digitalWrite(LED,HIGH);
    digitalWrite(power,HIGH);
    delay(100);
    digitalWrite(LED,LOW);
    digitalWrite(power,LOW);
    delay(100);
        }
    ESP.reset();
      } else {
    content = "{\"Error\":\"404 not found\"}";
    statusCode = 404;
    Serial.println("Sending 404");
      }
    server.sendHeader("Access-Control-Allow-Origin", "*");
    server.send(statusCode, "application/json", content);

    });
  } 
}
//---------------------------------------------------------------------------------Write byte---------------------------------------------------------------------------------------------
 void writebyte(unsigned short int address, byte val)
{
  Wire.beginTransmission(EEPROM_I2C_ADDRESS);
  Wire.write((unsigned short int)(address >> 8)); // MSB
  Wire.write((unsigned short int)(address &  0xFF));   // lSB
  Wire.write(val);
  Wire.endTransmission();
  delay(6);
}
   //---------------------------------------------------------------------------------Write String -----------------------------------------------------------------------------------------
 void write_string(unsigned short int address, String val){
  Serial.println("writing data"); 
  Serial.println(val);
  for (int x=0;x<val.length();x++){
  writebyte(address,val[x]);
  address++;
  }
}

//-----------------------------------------------------------------------------------READ Byte -------------------------------------------------------------------------------------------------------------

  byte readbyte(unsigned short int address)
{
   byte rData = 0xFF;
  Wire.beginTransmission(EEPROM_I2C_ADDRESS);
  Wire.write(( unsigned short int)(address >> 8));   // MSB
  Wire.write((unsigned short int)(address &  0xFF));   // LSB
  Wire.endTransmission();  
  Wire.requestFrom(EEPROM_I2C_ADDRESS, address);  
  rData =  Wire.read();
  return rData;
  delay(6);
}
////---------------------------------------------------------------------------------Read Strign------------------------------------------------------------------------------------------
 String read_string(unsigned short int address,char len){
  Serial.println("reading data");
  String r="";
  for(unsigned short int i=0;i<len;i++){
  r+=char(readbyte(address));
  address++;
  }
  Serial.println(r);
  return r;
 }
//--------------------------------------------------------Post 1st weightment data-----------------------------------------------------------------------------------------------------
 void send_1stweight_data(){  
   
postData="tag=addData&data=charges="+charges+"#charges_2="+charges_2+"#first_weight_time="+first_weight_time+"#gross="+gross+"#item="+item+"#net="+net+"#party_address="+party_address+"#party_name="+party_name+"#rstNo="+rstNo+"#second_weight_time="+second_weight_time+"#tare="+tare+"#vehicle_type="+vehicle_type +"#vehile_no="+vehile_no+"#weighbridgeId="+weighbridgeId+"#local_rst_no="+local_rst_no;
   Serial.println("Making Data Upload FOR FIRST WEIGHT Request......");
   client.post(path, contentType, postData);
   statusCode = client.responseStatusCode();
   response = client.responseBody();
   rstNo =response;
   Serial.print("Key no.: ");
   Serial.println(rstNo);
   Serial.println(rstNo.length());
   Serial.print("Status code: ");
   Serial.println(statusCode);
   Serial.print("Response: ");
   Serial.println(response);
   Serial.println(response.length());
   return;
  }
 //----------------------------------------------------------Post 2nd Weightment Data------------------------------------------------------------------------------------------------------
 void send_2ndWet_data(){
 
  postData="tag=addData&data=rstNo="+rstNo+"#second_weight_time="+second_weight_time+"#tare="+tare+"#charges_2="+charges_2+"#first_weight_time="+first_weight_time+"#net="+net+"#gross="+gross+"#weighbridgeId="+weighbridgeId;
  Serial.println("Making Data Upload SECOND WEIGHT Request......");
  Serial.println(rstNo);
  Serial.println(gross);
  Serial.println(tare);
  Serial.println(net);
  Serial.println(charges_2);
  Serial.println(first_weight_time);
  Serial.println(second_weight_time);
  Serial.println(weighbridgeId);
  
  client.post(path, contentType, postData);
  statusCode = client.responseStatusCode();
  response = client.responseBody();
  rstNo =client.responseBody();
  Serial.print("Status code: ");
  Serial.println(statusCode);
  Serial.print("Response: ");
  Serial.println(response);
  Serial.println(response.length());
  return;
  }

//----------------------------------------------------------------------------Save first Weightment Data----------------------------------------------------------------------------------
void save_1st(){
   delay(6);
   high= readbyte(Ad_msb_1st);
   low= readbyte(Ad_lsb_1st);
   Serial.print("write lable at add=");
   offadd=word(high,low);
   Serial.println(offadd);
   lable="@1";
   Serial.println(lable);
   delay(6);
   write_string(offadd,lable);
   offadd+=lable.length();
   write_string(offadd,local_rst_no);
   Serial.println(local_rst_no);
   offadd+=RST;
   write_string(offadd,vehile_no);
   Serial.println(vehile_no);
   offadd+=VEH_NUM; 
    write_string(offadd,vehicle_type);
   Serial.println(vehicle_type);
   offadd+=VEH_TYPE;                             
   write_string(offadd,party_name);
   Serial.println(party_name);
   offadd+=NAME;
   write_string(offadd,party_address);
   Serial.println(party_address);
   offadd+=ADD;
   write_string(offadd,item);                           
   Serial.println(item);
   offadd+=ITEM;
  
   if (Wet_type=="T"){ 
   Serial.print("Saving Tare: ");
   write_string(offadd,Wet_type);
   Serial.println(Wet_type);
   offadd+=1;
   write_string(offadd,tare);
   Serial.println(tare);
   offadd+=WET;
   write_string(offadd,first_weight_time);
   Serial.println(first_weight_time);
   }
   if (Wet_type=="G"){ 
   Serial.print("Saing Gross: ");
   write_string(offadd,Wet_type);
   Serial.println(Wet_type);
   offadd+=1;
   write_string(offadd,gross);
   Serial.println(gross);
   offadd+=WET;
   write_string(offadd,second_weight_time);
   Serial.println(second_weight_time);
   }
  
   offadd+=TIME;
   write_string(offadd,charges);
   Serial.println(charges);
   offadd+=CHARGES+1;
   if(offadd>=Stop_1st_wet){Serial.print("memory full");offadd=Strt_1st_wet;}
   high=highByte(offadd);
   low=lowByte(offadd);
   writebyte(Ad_msb_1st, high);
   writebyte(Ad_lsb_1st, low);
   high= readbyte(Ad_msb_1st);
   low= readbyte(Ad_lsb_1st);
   Serial.print("last add");
   offadd=word(high,low);
   Serial.println(offadd);
   Serial.println("Data Save On Memory");
   count_1st++;
   high=highByte(count_1st);
   low=lowByte(count_1st);
   writebyte(Msb_Count1st , high);
   writebyte(Lsb_Count1st, low);
   Serial.print("total ofliine 1ST wet entery = ");
   Serial.println(count_1st);
   vehicle_type="";
   party_address="";
   data="";
   local_rst_no="";
   vehile_no=""; 
   party_name=""; 
   item="";
   Wet_type="";
   rstNo="";
   tare="";
   gross="";
   first_weight_time="";
   charges="";
   lable="";
   second_weight_time="";
   charges_2="";
   delay(6);
   return;
}
//----------------------------------------------------------------Save 2nd Weightmetn Data-------------------------------------------------------------------------------------------------
void save_2nd(){
  
   delay(6);
   high= readbyte(Ad_2nd_msb );
   low= readbyte(Ad_2nd_lsb);
   Serial.print("write 2nd lable at add=");
   offadd=word(high,low);
   Serial.println(offadd);
   lable="@2"; 
   Serial.println(lable);
   delay(6);
   write_string(offadd,lable);
   offadd+=lable.length();
   write_string(offadd,local_rst_no);
   Serial.println(local_rst_no);
   offadd+=RST;
   write_string(offadd,gross);
   Serial.println(gross);
   offadd+=WET;
   write_string(offadd,second_weight_time);  
   Serial.println(second_weight_time);
   offadd+=TIME;
   write_string(offadd,tare);
   Serial.println(tare);
   offadd+=WET;
   write_string(offadd,first_weight_time);
   Serial.println(first_weight_time);
   offadd+=TIME;
   write_string(offadd,net);
   Serial.println(net);
   offadd+=WET;
   write_string(offadd,charges_2);
   Serial.println(charges_2);
   offadd+=CHARGES+1;
   if(add>=Stop_2d_wet ){Serial.print("memory full");add=Strt_2nd_wet;}
    
   high=highByte(offadd);
   low=lowByte(offadd);
   writebyte(Ad_2nd_msb , high);
   writebyte(Ad_2nd_lsb, low);
   high= readbyte(Ad_2nd_msb );
   low= readbyte(Ad_2nd_lsb);
   Serial.print("last add");
   offadd=word(high,low);
   Serial.println(offadd);
   Serial.println("Data Second weightment Save On Memory");
   Serial.println("Dtat from Second wirght ");
   count_2nd++;
   high=highByte(count_2nd);
   low=lowByte(count_2nd);
   writebyte(Msb_Count2nd , high);
   writebyte(Lsb_Count2nd, low);
   Serial.print("total ofliine 2nd wet entery = ");
   Serial.println(count_2nd);
   vehicle_type="";
   party_address="";
   data="";
   local_rst_no="";
   vehile_no=""; 
   party_name=""; 
   item="";
   Wet_type="";
   rstNo="";
   tare="";
   gross="";
   first_weight_time="";
   charges="";
   lable="";
   second_weight_time="";
   charges_2="";
   delay(6);
   return;
}
//----------------------------------------------------------------------Save Manual Weigthment------------------------------------------------------------------------------------------
void save_manual_wet(){

   delay(6);
   high= readbyte(Ad_man_msb );
   low= readbyte(Ad_man_lsb);
   Serial.print("write maanual lable at add=");
   offadd=word(high,low);
   Serial.println(offadd);
   lable="@3";
   Serial.println(lable);
   delay(6);
   write_string(offadd,lable);
   offadd+=lable.length();
   write_string(offadd,local_rst_no);
   Serial.println(local_rst_no);
   offadd+=RST;
   write_string(offadd,vehile_no);
   Serial.println(vehile_no);
   offadd+=VEH_NUM; 
   write_string(offadd,vehicle_type);
   Serial.println(vehicle_type);
   offadd+=VEH_TYPE;                             
   write_string(offadd,party_name);
   Serial.println(party_name);
   offadd+=NAME;
   write_string(offadd,party_address);
   Serial.println(party_address);
   offadd+=ADD;
   write_string(offadd,item);                           
   Serial.println(item);
   offadd+=ITEM;
   write_string(offadd,gross);
   Serial.println(gross);
   offadd+=WET;
   write_string(offadd,second_weight_time);
   Serial.println(second_weight_time);
   offadd+=TIME;
   write_string(offadd,tare);
   Serial.println(tare);
   offadd+=WET;
   write_string(offadd,first_weight_time);
   Serial.println(first_weight_time);
   offadd+=TIME;
   write_string(offadd,net);
   Serial.println(net);
   offadd+=WET;
   write_string(offadd,charges_2);
   Serial.println(charges_2);
   offadd+=CHARGES+1;
   if(add>=Stop_man_wet ){Serial.print("memory full");add=Strt_man_wet;}
   high=highByte(offadd);
   low=lowByte(offadd);
   writebyte(Ad_man_msb , high);
   writebyte(Ad_man_lsb, low);
   high= readbyte(Ad_man_msb );
   low= readbyte(Ad_man_lsb);
   Serial.print("last add");
   offadd=word(high,low);
   Serial.println(offadd);
   Serial.println("Data Manual weightment Save On Memory");
   Serial.println("Dtat from Manual wirght ");
   count_3rd++;
   high=highByte(count_3rd);
   low=lowByte(count_3rd);
   writebyte(Msb_Count3rd, high);
   writebyte(Lsb_Count3rd, low);
   Serial.print("total ofliine Manual wet entery = ");
   Serial.println(count_3rd);
   vehicle_type="";
   party_address="";
   data="";
   local_rst_no="";
   vehile_no=""; 
   party_name=""; 
   item="";
   Wet_type="";
   rstNo="";
   tare="";
   gross="";
   first_weight_time="";
   charges="";
   lable="";
   second_weight_time="";
   charges_2="";

   delay(6);
   return;
}
//-------------------------------------------------------------Read 1st Weigthment Data- From Memory-------------------------------------------------------------------------------------------------
void search_1st(){
  
   add=Strt_1st_wet;
   lable="@1";
   rep:
   Serial.print("Sraching for 1st wightment fromm add = "); 
   Serial.println(add); 
   if(add>=Stop_1st_wet){Serial.print("No recoreds found for first weight");
 
   return;}
   search=read_string(add,lable.length());
   
   Serial.println(search);
   if(search==lable){
   
   from=add;
   Serial.print("reading lables from add=");
   Serial.println(from);
    
   Serial.print("Recoreds found for first weight");
   add+=lable.length();
   local_rst_no=read_string(add,RST);
   Serial.println(local_rst_no);
   add+=RST;
   vehile_no=read_string(add,VEH_NUM);
   Serial.println(vehile_no);
   add+=VEH_NUM;
   vehicle_type=read_string(add,VEH_TYPE);
   Serial.println(vehicle_type);
   add+=VEH_TYPE;
   party_name=read_string(add,NAME);
   Serial.println(party_name);
   add+=NAME;
   party_address=read_string(add,ADD);
   Serial.println(party_address);
   add+=ADD;
   item=read_string(add,ITEM);
   Serial.println(item);
   add+=ITEM;
   Wet_type=read_string(add,1);
   Serial.println(Wet_type);
   add+=1;

   if (Wet_type=="T"){ 
   Serial.print("Reading Tare: ");
   tare=read_string(add,WET);
   Serial.println(tare);
   add+=WET;
   first_weight_time=read_string(add,TIME);
   Serial.println(first_weight_time);
   }
   if (Wet_type=="G"){ 
   Serial.print("Reading Gross: ");
   gross=read_string(add,WET);
   Serial.println(gross);
   add+=WET;
   second_weight_time=read_string(add,TIME);
   Serial.println(second_weight_time);
   }
   
   add+=TIME;
   charges=read_string(add,CHARGES);
   Serial.println(charges);
   add+=CHARGES+1;
   return; 
   }
  if(search!=lable){add+=lable.length()+ RST + VEH_NUM + VEH_TYPE + NAME + ADD + 1 + ITEM + WET + TIME + CHARGES+1;
   Serial.println("lable  not found");
   Serial.println("Searching.... again");
   search="";
   goto rep;}
 }  
//--------------------------------------------------------Read 2nd Weightment Data From memory---------------------------------------------------------------------------------------------
void search_2nd() {
   add=Strt_2nd_wet;
   lable="@2";
   re:
   Serial.print("Sraching for 2nd wightment fromm add = "); 
   Serial.println(add); 
   if(add>=Stop_2d_wet ){Serial.print("No recoreds found for first weight");
    return;}
   search=read_string(add,lable.length());
   
   Serial.println(search);
   if(search==lable){
   from=add;
   Serial.print("Recoreds found for Second weight");
   add+=lable.length();
   local_rst_no=read_string(add,RST);
   Serial.println(local_rst_no);
   add+=RST;
   gross=read_string(add,WET);
   Serial.println(gross);
   add+=WET;
   second_weight_time=read_string(add,TIME);
   Serial.println(second_weight_time);
   add+=TIME;
   tare=read_string(add,WET);
   Serial.println(tare);
   add+=WET;
   first_weight_time=read_string(add,TIME);
   Serial.println(first_weight_time);
   add+=TIME;
   net=read_string(add,WET);
   Serial.println(net);
   add+=WET;
   charges_2=read_string(add,CHARGES);
   Serial.println(charges_2);
   add+=CHARGES+1;
   
  
    
  //-----------------------------------Read Rst number from EEPROM-------------
   add=1;
   repat:
   if(add>=9000){Serial.print("Wrong RST");
   local_rst_no="";
   rstNo="";
   search="";
   party_name="";
   data="";
   charges="";
   charges_2="";
   second_weight_time="";
   return;}
   search=read_string(add,RST);
   
   Serial.println(search);
   if(search== local_rst_no){
   Serial.println("number found");
    Serial.println(search);
   add+=RST;
   charges=read_string(add,CHARGES);
   Serial.println("first charges");
   Serial.println(charges);
   l=charges.toInt();
   Serial.println(l);
   Serial.println("Total charges");
   Serial.println(charges_2);
   k=charges_2.toInt();
   
   Serial.println(k);
   s=k-l;
   charges_2=String(s);
   Serial.println(s);
   Serial.println("final charge");
   Serial.println(charges_2);
   add+=CHARGES;
   rstNo=read_string(add,13);
   return;
   }
    if(search!= local_rst_no){
    Serial.println("number not found");
    Serial.println("Searching.... again");
    search="";
    
    add+=RST+CHARGES+14;
    goto repat;
     }
}  
   if(search!=lable){add+=lable.length()+ RST + WET + WET +WET+ TIME + TIME +CHARGES+ 1;
   Serial.println("lable for second weight not found");
   Serial.println("Searching.... again");
   search="";
   goto re;} 
     
}
//------------------------------------------------------------------------------------Read Manual wightmnet---------------------------------------------------------------------------------
 void search_manual (){
    add=Strt_man_wet;  
   lable="@3";
   point:
   Serial.print("Sraching forMnaual wightment fromm add = "); 
   Serial.println(add); 
   if(add>=Stop_man_wet){Serial.print("No recoreds found for Manula weight");
   return;}
   search=read_string(add,lable.length());
   Serial.println(search);
   if(search==lable){
   from=add;
   Serial.print("reading lables from add=");
   Serial.println(from);
   Serial.print("Recoreds found for Manual weight");
   add+=lable.length();
   local_rst_no=read_string(add,RST);
   Serial.println(local_rst_no);
   add+=RST;
   vehile_no=read_string(add,VEH_NUM);
   Serial.println(vehile_no);
   add+=VEH_NUM;
   vehicle_type=read_string(add,VEH_TYPE);
   Serial.println(vehicle_type);
   add+=VEH_TYPE;
   party_name=read_string(add,NAME);
   Serial.println(party_name);
   add+=NAME;
   party_address=read_string(add,ADD);
   Serial.println(party_address);
   add+=ADD;
   item=read_string(add,ITEM);
   Serial.println(item);
   add+=ITEM;
   gross=read_string(add,WET);
   Serial.println(gross);
   add+=WET;
   second_weight_time=read_string(add,TIME);
   Serial.println(second_weight_time);
   add+=TIME;
   tare=read_string(add,WET);
   Serial.println(tare);
   add+=WET;
   first_weight_time=read_string(add,TIME);
   Serial.println(first_weight_time);
   add+=TIME;
   net=read_string(add,WET);
   Serial.println(net);
   add+=WET;
   charges_2=read_string(add,CHARGES);
   Serial.println(charges_2);
   add+=CHARGES+1;
   return;}
  
   if(search!=lable){add+=lable.length()+ RST + VEH_NUM + VEH_TYPE + NAME + ADD + ITEM + WET + WET + WET + TIME + TIME + CHARGES + 1;
   Serial.println("lable  not found");
   Serial.println("Searching.... again");
   search="";
   goto point;}
  
  }
  
  //----------------------------------------------------------------------------------Chek Response for Firstweight------------------------------------------------------------------------------------------------------------------
void chk_resp_1st_wt(){
   Serial.println("Cheking response for first weightment");
   if(response.length()==13){
   Serial.print("First weight Data sent on server");
   Serial.print("Saving RST Number for local rast= ");
   Serial.println(local_rst_no);
   delay(6);
   
   high= readbyte(Key_msb);
   low= readbyte(Key_lsb);
   Serial.print("write RST at add=");
   add=word(high,low);
   Serial.println(add);
   write_string(add,local_rst_no);
   add+=RST;
   write_string(add,charges);
   add+=CHARGES;
   write_string(add,rstNo);
   add+=13+1;
   lastadd=add;
   high=highByte(lastadd);
   low=lowByte(lastadd);
   writebyte(Key_msb, high);
   writebyte(Key_lsb, low);
   high= readbyte(Key_msb);
   low= readbyte(Key_lsb);
   Serial.println(high);
   Serial.println(low);
   Serial.print("last add");
   lastadd=word(high,low);
   Serial.println(lastadd);
   vehicle_type="";
   party_address="";
   data="";
   local_rst_no="";
   vehile_no=""; 
   party_name=""; 
   item="";
   Wet_type="";
   rstNo="";
   tare="";
   gross="";
   first_weight_time="";
   charges="";
   lable="";
   second_weight_time="";
   delay(5);
   return;
   }
   if(response.length()!=13){
   Serial.println("bad tresponse, Saving data ");
   save_1st();
   Serial.println("Saving process for 1st wt complete.. ");
   delay(6);
   return;
   } 
}
//---------------------------------------------------------Chek response for Second weightment data--------------------------------------------------------------------------------------------
void resp_chk_2nd_wt(){
   Serial.println("Cheking response for Second weihgtment");
   if(response.length()==13){
   Serial.print("Second weight Data sent on server");
   Serial.println("2nd wet data send copmlete");
    
   for(int z=0;z<10;z++){
     writebyte(from,' ');
     from++;
     }
   Serial.println("removing lable");
   
   local_rst_no="";
   rstNo="";
   search="";
   net="";
   gross="";
   tare="";
   charges_2="";
   charges="";
   second_weight_time="";
   data="";
   delay(6);
   vehicle_type="";
   party_address="";
   data="";
   local_rst_no="";
   vehile_no=""; 
   party_name=""; 
   item="";
   Wet_type="";
   rstNo="";
   tare="";
   gross="";
   first_weight_time="";
   charges="";
   lable="";
   second_weight_time="";
   charges_2="";
   return;
   }
   if(response.length()!=13){
   Serial.println("Data not Send ,Saving data");
   Serial.println("Saving Data for Second weightment");
   save_2nd();
   Serial.println("Data save for 2nd wt complete");
   delay(6);
   return;
   }  
   }
//---------------------------------------------------------Chek Response For Mnaula Weightment Data--------------------------------------------------------------------------------------------
void resp_chk_manual(){
   Serial.println("Cheking response for Manual weihgtment");
   if(response.length()==13){
   Serial.print("Mnaula weight Data sent on server");
   
    
   for(int z=0;z<10;z++){
     writebyte(from,' ');
     from++;
     }
   Serial.println("removing lable");
   party_address="";
   local_rst_no="";
   rstNo="";
   search="";
   net="";
   gross="";
   tare="";
   charges_2="";
   charges="";
   first_weight_time="";
   second_weight_time="";
   data="";
   vehicle_type="";
   vehile_no=""; 
   party_name=""; 
   lable="";
   chek="";
   delay(6);
   return;
   }
   if(response.length()!=13){
   Serial.println("Data not Send ,Saving data");
   Serial.println("Saving Data for Manual weightment");
   save_manual_wet();
   Serial.println("Data save for Mnaula wet complete");
   delay(10000);
   return;
   }  
   }
//------------------------------------------------------------------------VOID LOOP-----------------------------------------------------------------------------------------------------------------
void loop() {
   if (state==WL_CONNECTED){ 
    digitalWrite(LED,HIGH);
   digitalWrite(power,HIGH);}
  top:
  
  state =WiFi.status();
  if (Serial.available()>0){
  Serial.println("data reciving");
  data=Serial.readString();
  if(data==NULL)goto top;
  Serial.println(data);
  Serial.println("data lenght");
  Serial.println(data.length());
  if(data.length()==109){//--------------------------------------------------Get Firts weightment Data-------------------------------------------------------------------------------------- 
  Serial.println("Dtat from first weight");
  local_rst_no=data.substring(3,8);//rst
  Serial.print("local_rst_no:");
  Serial.println(local_rst_no);
  vehile_no=data.substring(9,19);//veh no
  Serial.println(vehile_no);
  vehicle_type=data.substring(21,29);//veh type
  Serial.println(vehicle_type);
  party_name=data.substring(31,47);//part
  Serial.println(party_name);
  party_address=data.substring(49,59);//add  
  Serial.println(party_address);
  item=data.substring(61,69);//item
  Serial.println(item);
  Wet_type=data.substring(71,72);//weight type
  Serial.println(Wet_type);
  if (Wet_type=="T"){ 
   Serial.print("Tare: ");
   tare=data.substring(73,79);//weight 
   Serial.println(tare);
   first_weight_time=data.substring(83,99);//time
   Serial.println(first_weight_time);
   }
   if (Wet_type=="G"){ 
   Serial.print("Gross: ");
   gross=data.substring(73,79);//weight
   Serial.println(gross);
   second_weight_time=data.substring(83,99);//time 
   Serial.println(second_weight_time);
   }
   charges=data.substring(102,107);//charge
   Serial.println(charges);
   delay(1000);
   state =WiFi.status();
   Serial.println("Reading complete");
   if (state  ==WL_CONNECTED){//--------------------------------------------Send  First Weihgtment data online ----------------------------------------------------------------------------
   Serial.println("We are connected send direct");
    digitalWrite(LED,HIGH);
   digitalWrite(power,HIGH);
   write_string(rst_add,local_rst_no);
   Serial.println("New RST number saved");
   send_1stweight_data();
   delay(5);
   chk_resp_1st_wt();
   Serial.println("local rst key and charges saved");
   delay(5000);}
   if (state  !=WL_CONNECTED){//--------------------------------------------Save First Weihgtment data offline -------------------------------------------------------------------------------
   Serial.println("Connection Lost");
   digitalWrite(LED,LOW);
   digitalWrite(power,LOW);
   Serial.println("Saving Data, your are offline ");
   Serial.print("Saving RST Number for local rast= ");
   Serial.println(local_rst_no);
   write_string(rst_add,local_rst_no);
   Serial.println("New RST number saved");
   save_1st();
   Serial.println("Saving process for 1st wt complete.. ");
   delay(6);}
  }
  
   if(data.length()==150){  //-------------------------------------------Get Second weigtment Data----------------------------------------------------------------------------------------
   Serial.println("Dtat from second weight");
   local_rst_no=data.substring(3,8);//rst
   Serial.print("local_rst_no:");
   Serial.println(local_rst_no);
   vehile_no=data.substring(9,19);//veh no
   Serial.println(vehile_no);
   vehicle_type=data.substring(21,29);//veh type
   Serial.println(vehicle_type);
   party_name=data.substring(31,47);//part
   Serial.println(party_name);
   party_address=data.substring(49,59);//add  
   Serial.println(party_address);
   item=data.substring(61,69);//item
   Serial.println(item);
   Wet_type=data.substring(71,72);//weight type
   gross=data.substring(73,79);//gross
   Serial.println(gross);
   first_weight_time=data.substring(83,99);//time 1
   Serial.println(first_weight_time);
   tare=data.substring(102,108);//tare
   Serial.println(tare);
   second_weight_time=data.substring(112,128);//time 2
   Serial.println(second_weight_time);
   net=data.substring(131,137);//net
   Serial.println(net);
   charges_2=data.substring(143,148);//charge
   Serial.println(charges_2);
   delay(6);
   
   state =WiFi.status();
   Serial.println("Reading complete");
   if (state==WL_CONNECTED){//--------------------------------------------Send  Second Weihgtment data online ----------------------------------------------------------------------------
   Serial.println("We are connected");
   digitalWrite(LED,HIGH);
   digitalWrite(power,HIGH);
   //-----------------------------------------***----chek for manual weightment-to send data online-***--------------------
   Serial.println("reading RST connected");
   chek=read_string(rst_add,RST);
   m=chek.toInt();
   m++;
   Serial.println(m);
   n=local_rst_no.toInt();
   Serial.println(n);
   
   if(m==n){
   delay(5);
   write_string(rst_add,local_rst_no);
   Serial.println("New RST number saved");
   Serial.println("This is Manual Weightment");
   Serial.println("Sending Manual Weightment Data Ditrect");
   send_1stweight_data();
   delay(5);
   resp_chk_manual();
   Serial.println("Sending Manual Weightment Data Complete.....");
   delay(6);
   Serial.println(local_rst_no);
   goto top;
   }
  
   Serial.println("This is Second Weightment");
   Serial.println("Sending Second Weightment Data Ditrect");
   //-----------------------------------Read Rst number from EEPROM-------------
   add=1;
   repat:
   if(add>=9000){Serial.print("Wrong RST");
   local_rst_no="";
   rstNo="";
   search="";
   party_name="";
   data="";
   charges="";
   charges_2="";
   second_weight_time="";
   goto top;}
   search=read_string(add,RST);
   
   Serial.println(search);
   if(search==local_rst_no){
   Serial.println("number found");
    Serial.println(search);
    add+=RST;
   charges=read_string(add,CHARGES);
   Serial.println("first charges");
   Serial.println(charges);
   l=charges.toInt();
   Serial.println(l);
   Serial.println("Total charges");
   Serial.println(charges_2);
   k=charges_2.toInt();
   Serial.println(k);
   s=k-l;
   charges_2=String(s);
   Serial.println(s);
   Serial.println("final charge");
   Serial.println(charges_2);
   add+=CHARGES;
   rstNo=read_string(add,13);
   Serial.println(rstNo);
   delay(6);
   send_2ndWet_data();
   delay(5);
   resp_chk_2nd_wt();
   goto top;
   }
    if(search!= local_rst_no){
    Serial.println("number not found");
    Serial.println("Searching.... again");
    search="";
    
    add+=RST+CHARGES+14;
    goto repat;
     }
    }
   
   if (state!=WL_CONNECTED){//--------------------------------------------Save  Second Weihgtment data offline -------------------------------------------------------------------------------
   Serial.println("Connection Lost");
   digitalWrite(LED,LOW);
   digitalWrite(power,LOW);
   Serial.println("Chekig wetmet 2nd or Mnaual");
   chek=read_string(rst_add,RST);
   m=chek.toInt();
   m++;
   Serial.println(m);
   n=local_rst_no.toInt();
   Serial.println(n);
   delay(5);
   if(m==n){//---------------------------------------------Save Manual wet data offline------------------------------
   Serial.println("This is Manual Weightment");
   delay(5);
   write_string(rst_add,local_rst_no);
   Serial.println("New RST number saved");
   Serial.println("Sending Manual Weightment Data Ditrect");
   save_manual_wet();
   delay(5);
   Serial.println("New RST number saved");
   Serial.println("Saving Manual Weightment Data Complete.....");
   delay(6);
   goto top;}
   Serial.println("Saving Data for Second weightment");
   save_2nd();
   Serial.println("Data save for 2nd wt complete");
   delay(6);}
   }
}

//----------------------------------------------------------Send Data From Memory----------------------------------------------------------------------------------------------------
while (!Serial.available()){Serial.println("not  reciving");
 if (state==WL_CONNECTED){
   digitalWrite(LED,HIGH);
   digitalWrite(power,HIGH);
   Serial.println("Cheking for pending Data");
    
   high=readbyte(Msb_Count1st);
   low=readbyte(Lsb_Count1st);
   count_1st=word(high,low);
  
   if(count_1st>0){
   Serial.print("total pending 1st wet data=");
   Serial.println(count_1st);
   search_1st();
   delay(5); 
   send_1stweight_data();
   Serial.println("1st wet Data Send On Server, chek response");
   if(response.length()==13){
   Serial.print("First weight Data sent on server");
   Serial.print("Saving RST Number for local rast= ");
   Serial.println(local_rst_no);
   delay(6);
    for(int z=0;z<10;z++){
     writebyte(from,' ');
     from++;
     }
    Serial.println("lable removed");
   count_1st--;
   high=highByte(count_1st);
   low=lowByte(count_1st);
   writebyte(Msb_Count1st , high);
   writebyte(Lsb_Count1st, low);
   Serial.print("Remanig ofliine 1ST wet entery = ");
   Serial.println(count_1st);
   high= readbyte(Key_msb);
   low= readbyte(Key_lsb);
   Serial.print("write RST at add=");
   add=word(high,low);
   Serial.println(add);
   write_string(add,local_rst_no);
   add+=RST;
   write_string(add,charges);
   add+=CHARGES;
   write_string(add,rstNo);
   add+=13+1;
   lastadd=add;
   high=highByte(lastadd);
   low=lowByte(lastadd);
   writebyte(Key_msb, high);
   writebyte(Key_lsb, low);
   high= readbyte(Key_msb);
   low= readbyte(Key_lsb);
   Serial.println(high);
   Serial.println(low);
   Serial.print("last add");
   lastadd=word(high,low);
   Serial.println(lastadd);
   delay(6);
   vehicle_type="";
   party_address="";
   data="";
   local_rst_no="";
   vehile_no=""; 
   party_name=""; 
   item="";
   Wet_type="";
   rstNo="";
   tare="";
   gross="";
   first_weight_time="";
   charges="";
   lable="";
   second_weight_time="";
   delay(5);
   goto top;
   }
   if(response.length()!=13){
   Serial.println("bad tresponse, try againg ");
   goto top;
   }
   
   }
   high=readbyte(Msb_Count2nd);
   low=readbyte(Lsb_Count2nd);
   count_2nd=word(high,low);
   if(count_2nd>0 &&count_1st==0 ){
   Serial.print("total pending 2ndwet data=");
   Serial.println(count_2nd);
   search_2nd();
   delay(5);
   send_2ndWet_data();
   Serial.println("2nd wet Data Send On Server, chek response");
   if(response.length()==13){
   Serial.print("Second weight Data sent on server");
   
    
   for(int z=0;z<10;z++){
     writebyte(from,' ');
     from++;
     }
   Serial.println("removing lable");
   count_2nd--;
   high=highByte(count_2nd);
   low=lowByte(count_2nd);
   writebyte(Msb_Count2nd, high);
   writebyte(Lsb_Count2nd, low);
   Serial.print("remaing ofliine 2nd wet entery = ");
   Serial.println(count_2nd);
   
   delay(6);
   
   vehicle_type="";
   party_address="";
   data="";
   local_rst_no="";
   vehile_no=""; 
   party_name=""; 
   item="";
   Wet_type="";
   rstNo="";
   tare="";
   gross="";
   first_weight_time="";
   charges="";
   lable="";
   second_weight_time="";
   charges_2="";
   goto top;
   }
   if(response.length()!=13){
   Serial.println("Data not Send ,try again");
   delay(5);
   goto top;
   }  
   }
   high=readbyte(Msb_Count3rd);
   low=readbyte(Lsb_Count3rd);
   count_3rd=word(high,low);
   if(count_3rd>0 &&count_1st==0 && count_2nd==0){//-----------------------*-*-*-*-*-*-*--

   Serial.print("total pending Manual wte data=");
   Serial.println(count_3rd);
   search_manual (); 
   delay(5);
   send_1stweight_data();
   Serial.println("Mnaual Data Send On Server, chek response");
   if(response.length()==13){
   Serial.print("Second weight Data sent on server");
   
    
   for(int z=0;z<10;z++){
     writebyte(from,' ');
     from++;
     }
   Serial.println("removing lable");
   count_3rd--;
   high=highByte(count_3rd);
   low=lowByte(count_3rd);
   writebyte(Msb_Count3rd, high);
   writebyte(Lsb_Count3rd, low);
   Serial.print("remaing ofliine 2nd wet entery = ");
   Serial.println(count_3rd);
   delay(6);
   vehicle_type="";
   party_address="";
   data="";
   local_rst_no="";
   vehile_no=""; 
   party_name=""; 
   item="";
   Wet_type="";
   rstNo="";
   tare="";
   gross="";
   first_weight_time="";
   charges="";
   lable="";
   second_weight_time="";
   charges_2="";
   goto top;
   }
   if(response.length()!=13){
   Serial.println("Data not Send ,try again");
   delay(5);
   goto top;
   }
    
    }
   goto top;
   }
   if (state!=WL_CONNECTED){
   Serial.println("Connection Lost");
    digitalWrite(LED,LOW);
   digitalWrite(power,LOW);
   goto top;}
} 

}

sir please reply

Have you timed how long it takes to get a response?
E.g.

uint32_t startTime = millis();
statusCode = client.responseStatusCode();
Serial.print("responseStatusCode() took ");
Serial.println (startTime - millis())

And a question is how often do you you want your important task to execute?

There are a few options as far as I can see

  1. Use setHttpResponseTimeout() and set a timeout value for how long you want to wait; not perfect but might be good enough.
  2. Use a second processor to handle the HTTP or use a multicore processor (e.g. ESP32, no experience with them).
  3. Hack the library so it becomes non-blocking.

For (3), you can try to replace the HttpClient::responseStatusCode() in the ArduinoHttpClient with the below; files involved are HttpClient.cpp (which contains the function) and HttpClient.h (to add a new return value for the above HttpClient::responseStatusCode()).

The changes with the original are marked with my username.

The change basically replaces a delay by a return that indicates that no data was received yet. As long as you get a reply HTTP_NODATA_YET, you will have to keep on calling that function.

int HttpClient::responseStatusCode()
{
   if (iState < eRequestSent)
   {
       return HTTP_ERROR_API;
   }
   // The first line will be of the form Status-Line:
   //   HTTP-Version SP Status-Code SP Reason-Phrase CRLF
   // Where HTTP-Version is of the form:
   //   HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT

   // sterretje 2021/11/02
   static bool inProgress = false;
   static unsigned long  timeoutStart;

   int c = '\0';
   do
   {
       // sterretje 2021/11/02
       if(inProgress == false)
       {
           // Make sure the status code is reset, and likewise the state.  This
           // lets us easily cope with 1xx informational responses by just
           // ignoring them really, and reading the next line for a proper response
           iStatusCode = 0;
           iState = eRequestSent;

           // sterretje 2021/11/02
           timeoutStart = millis();
           inProgress = true;
       }

       // Psuedo-regexp we're expecting before the status-code
       const char* statusPrefix = "HTTP/*.* ";
       const char* statusPtr = statusPrefix;
       // Whilst we haven't timed out & haven't reached the end of the headers
       while ((c != '\n') && 
              ( (millis() - timeoutStart) < iHttpResponseTimeout ))
       {
           if (available())
           {
               c = read();
               if (c != -1)
               {
                   switch(iState)
                   {
                   case eRequestSent:
                       // We haven't reached the status code yet
                       if ( (*statusPtr == '*') || (*statusPtr == c) )
                       {
                           // This character matches, just move along
                           statusPtr++;
                           if (*statusPtr == '\0')
                           {
                               // We've reached the end of the prefix
                               iState = eReadingStatusCode;
                           }
                       }
                       else
                       {
                           // sterretje 2021/11/02
                           inProgress = false;
                           return HTTP_ERROR_INVALID_RESPONSE;
                       }
                       break;
                   case eReadingStatusCode:
                       if (isdigit(c))
                       {
                           // This assumes we won't get more than the 3 digits we
                           // want
                           iStatusCode = iStatusCode*10 + (c - '0');
                       }
                       else
                       {
                           // We've reached the end of the status code
                           // We could sanity check it here or double-check for ' '
                           // rather than anything else, but let's be lenient
                           iState = eStatusCodeRead;
                       }
                       break;
                   case eStatusCodeRead:
                       // We're just waiting for the end of the line now
                       break;

                   default:
                       break;
                   };
                   // We read something, reset the timeout counter
                   timeoutStart = millis();
               }
           }
           else
           {
               // We haven't got any data, so let's pause to allow some to
               // arrive
               // sterretje 2021/11/02
               //delay(kHttpWaitForDataDelay);
               return HTTP_NODATA_YET;
           }
       }
       if ( (c == '\n') && (iStatusCode < 200 && iStatusCode != 101) )
       {
           // We've reached the end of an informational status line
           c = '\0'; // Clear c so we'll go back into the data reading loop
       }
   }
   // If we've read a status code successfully but it's informational (1xx)
   // loop back to the start
   while ( (iState == eStatusCodeRead) && (iStatusCode < 200 && iStatusCode != 101) );

   if ( (c == '\n') && (iState == eStatusCodeRead) )
   {
       // sterretje 2021/11/02
       inProgress = false;
       // We've read the status-line successfully
       return iStatusCode;
   }
   else if (c != '\n')
   {
       // sterretje 2021/11/02
       inProgress = false;
       // We must've timed out before we reached the end of the line
       return HTTP_ERROR_TIMED_OUT;
   }
   else
   {
       // sterretje 2021/11/02
       inProgress = false;
       // This wasn't a properly formed status line, or at least not one we
       // could understand
       return HTTP_ERROR_INVALID_RESPONSE;
   }
}

In the include file, find

// The response from the server is invalid, is it definitely an HTTP
// server?
static const int HTTP_ERROR_INVALID_RESPONSE =-4;

and add the below after that; it defines the new return code.

// sterretje 2021/11/02
static const int HTTP_NODATA_YET =-5;

Now you have to modify your code. The below is just a demonstration code to how you can use the modified library. It's loosely based on your code; I've omitted a lot of stuff that might be required (like connecting, checking if connected etc).

#include <ESP8266WiFi.h>
#include <ArduinoHttpClient.h>
#include <ESP8266WebServer.h>
#include <WiFiClient.h>

const char* ssid = "text";
const char* passphrase = "text";

const char serverAddress[] = "jbcweighingscale.com";
int port = 80;

WiFiClient wifi;
HttpClient client = HttpClient(wifi, serverAddress, port);
int status = WL_IDLE_STATUS;

String path = "/admin_ws/api.php/PARAM-data";
String contentType = "application/x-www-form-urlencoded";

/*
  The different states for posting
*/
enum class POSTSTATE
{
  POST,
  WAITRESPONSE,
  DONE,
};

/*
  The different possible results for posting
*/
enum class POSTRESULT
{
  SUCCESS,
  ERROR,
  INPROGRESS,
};

void setup()
{
  Serial.begin(115200);

  Serial.println("Disconnecting previously connected WiFi");
  WiFi.disconnect();
}

void loop()
{
  GetData();
  SubmitData();
}

/*
  your important task
*/
void GetData()
{

}

/*
  your less important task
*/
void SubmitData()
{
  // number to indicate what we want to send; you can create an enum and use that if you want to
  // a sequence number is easier for this
  static uint16_t sequenceNo = 0;

  // you can do a test here to see if there is data to submit


  // sequencer
  switch (sequenceNo)
  {
    case 0:
      // if send_1stweight_data() is no longer in progress
      if (send_1stweight_data() != POSTRESULT::INPROGRESS)
      {
        // go to the next
        sequenceNo++;
      }
      break;
    case 1:
      // if send_2ndWet_data() is no longer in progress
      if (send_2ndWet_data() != POSTRESULT::INPROGRESS)
      {
        // go to the next
        sequenceNo++;
      }
      break;
    default:
      // if there is nothing more to send
      sequenceNo = 0;
      break;
  }
}


POSTRESULT send_1stweight_data()
{
  static POSTSTATE state = POSTSTATE::POST;
  POSTRESULT pr = POSTRESULT::INPROGRESS;
  int statusCode = 0;
  String postData = "";
  String response = "";
  String  rstNo = "";

  switch (state)
  {
    case POSTSTATE::POST:
      // make a post
      postData = "hello world";
      Serial.println("Making Data Upload FOR FIRST WEIGHT Request......");
      client.post(path, contentType, postData);
      // and go to next step
      state = POSTSTATE::WAITRESPONSE;
      break;
    case POSTSTATE::WAITRESPONSE:
      statusCode = client.responseStatusCode();
      // if you got one of the 'original' return codes back, go to next step
      if (statusCode != HTTP_NODATA_YET)
      {
        // if you want to handle errors, set pr here if the statusCode indicates an error
        // if(there was an error)
        // {
        //   pr = POSTRESULT::ERROR;
        // }
        state = POSTSTATE::DONE;
      }
      break;
    case POSTSTATE::DONE:
      response = client.responseBody();
      rstNo = response;
      Serial.print("Key no.: ");
      Serial.println(rstNo);
      Serial.println(rstNo.length());
      Serial.print("Status code: ");
      Serial.println(statusCode);
      Serial.print("Response: ");
      Serial.println(response);
      Serial.println(response.length());

      // next time, start with a post
      state = POSTSTATE::POST;
      // indicate completed with SUCCESS
      pr = POSTRESULT::SUCCESS;
      break;
  }
  return pr;
}

/*
  Send the second weight data
  Return:
    INPROGRESS  while posting is in progress
    SUCCESS     once completed
    ERROR       not implemented
*/
POSTRESULT send_2ndWet_data()
{
  static POSTSTATE state = POSTSTATE::POST;
  POSTRESULT pr = POSTRESULT::INPROGRESS;
  int statusCode = 0;
  String postData = "";
  String response = "";
  String  rstNo = "";

  switch (state)
  {
    case POSTSTATE::POST:
      // make a post
      postData = "hello moon";
      Serial.println("Making Data Upload SECOND WEIGHT Request......");
      client.post(path, contentType, postData);
      // and go to next step
      state = POSTSTATE::WAITRESPONSE;
      break;
    case POSTSTATE::WAITRESPONSE:
      statusCode = client.responseStatusCode();
      // if you got one of the 'original' return codes back, go to next step
      if (statusCode != HTTP_NODATA_YET)
      {
        // if you want to handle errors, set pr here if the statusCode indicates an error
        // if(there was an error)
        // {
        //   pr = POSTRESULT::ERROR;
        // }
        state = POSTSTATE::DONE;
      }
      break;
    case POSTSTATE::DONE:
      response = client.responseBody();
      rstNo = response;
      Serial.print("Key no.: ");
      Serial.println(rstNo);
      Serial.println(rstNo.length());
      Serial.print("Status code: ");
      Serial.println(statusCode);
      Serial.print("Response: ");
      Serial.println(response);
      Serial.println(response.length());

      // next time, start with a post
      state = POSTSTATE::POST;
      // indicate completed with SUCCESS
      pr = POSTRESULT::SUCCESS;
      break;
  }
  return pr;
}

The code does compile (Wemos D1 mini) but I have no option to test. If the library modification does not work, you're on your own as I can't test.

Study it and understand the principles. Once you understand it, you can implement it in your code. If you don't understand the demo code, ask.

Note:
There are plenty of improvements to make; your code (and the above) basically contain duplicate functions (maybe with minor differences; it should be possible to use one function and pass required parameters.