Particle Electron flash --factory

This is the blinking cycle.
https://streamable.com/2lqte9

I forgot to mention that I use 3rd party SIM.
Even with tiinker the same think is happening. I dont think is code problem (because whatever code I use the same think is happening) I think that the problem is with factory flash as you mentioned in a past community chat.
https://community.particle.io/t/particle-flash-factory/45054/7?u=ppprc

Anw this was the code I flashed for factory and for user firmware:

Code
// This #include statement was automatically added by the Particle IDE.
//STARTUP(cellular_credentials_set("cytamobile", "", "", NULL));
STARTUP(cellular_credentials_set("cytamobile", "", "", NULL));
#include <OneWire.h>
#include<DS18.h>
ApplicationWatchdog *wd;
//chip select pin on the chipKIT uC32 (board dependent)
#define CS_PIN A2

//percent correction for sensitivity error (e.g. 100 = 100%)
//**user can use reference current to calibrate this value precisely
#define SENSITIVITY_CORRECTION 100 

//enable/disable digital filter                                    
#define FILTER_FLAG 1  

//number of samples for filter
//**lower amount of filter readings for a faster reading
#define NUM_READINGS 5000       

signed int get_mA(void);
float get_A(void);


int irr_sensor(A0);
int i_val = 0;
int v_val = 0;

int volt_sensor(A1);

DS18 temp_sensor(B5);

void watchdogHandler() {
  // Do as little as possible in this function, preferably just
  // calling System.reset().
  // Do not attempt to Particle.publish(), use Cellular.command()
  // or similar functions. You can save data to a retained variable
  // here safetly so you know the watchdog triggered when you 
  // restart.
  // In 2.0.0 and later, RESET_NO_WAIT prevents notifying the cloud of a pending reset
  System.reset();
}

void setup() {
  Serial.begin(9600);
  
  SPI.begin();
  
  pinMode(CS_PIN, OUTPUT);
  Particle.keepAlive(1.5*60);
  wd = new ApplicationWatchdog(6*60*1000, watchdogHandler, 1536);
  // Set up 'power' pins, comment out if not used!
  //pinMode(D3, OUTPUT);
  //pinMode(D5, OUTPUT);
  //digitalWrite(D3, LOW);
  //digitalWrite(D5, HIGH);
}

void loop() {
  // Read the next available 1-Wire temperature sensor
  int temp = -990;
  if (temp_sensor.read()) {
    // Do something cool with the temperature
    temp = int(temp_sensor.celsius());
    Serial.printf("Temperature: %i C \n", int(temp_sensor.celsius()));
    //Particle.publish("temperature", String(int(temp_sensor.celsius())), PRIVATE);
    temp_sensor.read();
  }
  else{
    Serial.printf("ERROR!!!\n");
    Particle.publish("err", "ERROR!!!!", PRIVATE);
  }
  i_val = analogRead(irr_sensor);
  Serial.printf("Irradiance: %i \n",i_val);
  //Particle.publish("irr", String(i_val), PRIVATE);
  
 
  v_val = analogRead(volt_sensor);
  Serial.printf("Volts: %i \n",v_val);
  //Particle.publish("volt", String(v_val), PRIVATE);
  
  signed int ma = 0;
  float a = 0.0;
  
  ma = get_mA();
  Serial.print(ma);               //prints mA value over serial monitor
  Serial.print(" mA   |  ");
  //Particle.publish("c_mA", String(ma), PRIVATE);
  
  a = get_A();
  Serial.print(a);                //prints amp value over serial monitor
  Serial.println(" A");
  //delay(1000);
  //Particle.publish("c_A", String(a), PRIVATE);
  Serial.println(" A");
  
  float batterySoc = System.batteryCharge();
  
  char c_tago[200];
  sprintf(c_tago, "{\"temperature\":%i ,\"irr\":%i ,\"volt\":%i ,\"c_mA\":%i ,\"c_A\":%.3f, \"batt\":%.1f}", temp ,i_val ,v_val ,ma ,a, batterySoc);
  String tago = c_tago;
  Particle.publish("Thesis",tago,PRIVATE);
  Serial.printf("size: %i\n",sizeof(tago));
  Serial.printf("  len: %i\n", strlen(tago));
  Serial.printf("  len: %i\n", tago.length());
  Serial.printf(tago);
  
  i_val = 0;
  v_val = 0;
  
  if(FILTER_FLAG == 0){
    delay(50);
  }

  Serial.println();
  delay(5*60*1000);
}


/************************************************************************/
/*  signed int get_mA(void)    						*/
/*                                                                      */
/*      Return Value:                                                   */ 
/*              float                                                   */
/*                                                                      */
/*      Description:                                                    */
/*              This function returns the value of current flow in      */
/*              milliamperes (milliamps).                               */
/*                                                                      */
/************************************************************************/
signed int get_mA(void)
{
  Serial.print(" mAAAAAAAA   |  ");
  int result1;                 //first byte from ADC
  int result2;                 //second byte from ADC
  signed int temp_value;                  
  signed int total = 0;        //running total of filter values
  signed int milli_amps;       //converted value into milli amperes  
  
  if(FILTER_FLAG == 1){
    for(int i = 0; i < NUM_READINGS; i++){
      digitalWrite(CS_PIN, LOW);      //begin SPI transfer
      result1 = SPI.transfer(0x00);   //transfer first byte in
      result2 = SPI.transfer(0x00);   //transfer second byte in
      digitalWrite(CS_PIN, HIGH);     //end transfer
    
      temp_value = (SENSITIVITY_CORRECTION / 100) * (10000  * (((result1<<8) | result2) - 2048)) / 819;  //appends the two bytes and converts their value into milliamperes
      total = total + temp_value;
    }
    milli_amps = total / NUM_READINGS; 
  }
  
  else{
    digitalWrite(CS_PIN, LOW);      //begin SPI transfer
    result1 = SPI.transfer(0x00);  //transfer first byte in
    result2 = SPI.transfer(0x00);  //transfer second byte in
    digitalWrite(CS_PIN, HIGH);     //end transfer
    
    milli_amps = (SENSITIVITY_CORRECTION / 100) * (10000  * (((result1<<8) | result2) - 2048)) / 819;  //appends the two bytes and converts their value into milliamperes
  }
  return milli_amps;
}

/************************************************************************/
/*  float get_A(void)    						*/
/*                                                                      */
/*      Return Value:                                                   */ 
/*              float                                                   */
/*                                                                      */
/*      Description:                                                    */
/*              This function returns the value of current flow in      */
/*              amperes (amps).                                         */
/*                                                                      */
/************************************************************************/
float get_A(void)
{
  Serial.print(" AAAAAAAA  |  ");
  int result1;           //first byte from ADC
  int result2;           //second byte from ADC
  float temp_value;      
  float total = 0;       //running total of filter values
  float amps;            //converted value into amperes
  
  if(FILTER_FLAG == 1){
    for(int i = 0; i < NUM_READINGS; i++){
      digitalWrite(CS_PIN, LOW);      //begin SPI transfer
      result1 = SPI.transfer(0x00);   //transfer first byte in
      result2 = SPI.transfer(0x00);   //transfer second byte in
      digitalWrite(CS_PIN, HIGH);     //end transfer
    
      temp_value = (SENSITIVITY_CORRECTION / 100) * (10.0 * (((result1<<8) | result2) - 2048.0) / 819.0);  //appends the two bytes and converts their value into amperes
      total += temp_value;
    }
    amps = total / NUM_READINGS; 
  }
  
  else{
    digitalWrite(CS_PIN, LOW);      //begin SPI transfer
    result1 = SPI.transfer(0x00);  //transfer first byte in
    result2 = SPI.transfer(0x00);  //transfer second byte in
    digitalWrite(CS_PIN, HIGH);     //end transfer
    
    amps = (SENSITIVITY_CORRECTION / 100) * (10.0 * (((result1<<8) | result2) - 2048.0) / 819.0);  //appends the two bytes and converts their value into amperes
  } 
  return amps;
}