Particle electron problem with OTA and third SIM card

hello am having problem using flash the code with the OTA over the particle built
before when i used the particle SIM card i didnt have any problem and it was flashing very smooth the same code

now i got AT&T SIM card and some time it flash the code and most of the time it dosnt it times out .
and yes i read the other thread about the Safe Mode
when i put the electron on Safe Mode it flashes successfully .
and the code donst have any blocking issue
and i tried to change the KEEP_ALIVE seconds still it wasnt able to flashe very time .

this is the code
the project is remote control car with blynk and particle electron the project working great just am having issue with flashing the code thro the particle built OTA when am using third party SIM card .

// This #include statement was automatically added by the Particle IDE.
#include <SparkCorePolledTimer.h>

// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>

// Uncomment this, if you want to set network credentials
#include "cellular_hal.h"
STARTUP(cellular_credentials_set("broadband", "", "", NULL));

// This #include statement was automatically added by the Particle IDE.
// Set Blynk hertbeat interval.
// Each heartbeat uses ~90 bytes of data.
#define BLYNK_HEARTBEAT 60

// Set Particle keep-alive ping interval.
// Each ping uses 121 bytes of data.
#define PARTICLE_KEEPALIVE 20


#define LOCK D0
#define UNLOCK D1
#define TRUNK D2
#define PANIC D3
#define ENGINE_START D4
#define ARM D5
#define Engine_Status D6
#define ARM_ENGINE D7

#define ON 255
#define OFF 0

SparkCorePolledTimer updateTimer(1000); //Create a timer object and set it's timeout in milliseconds
void OnTimer(void); //Prototype for timer callback method

//SparkCorePolledTimer updateTimer1(5000); //Create a timer object and set it's timeout in milliseconds
//void WordTittle(void);

int ENGINE_STATUS=0;







void setup()
{
  Serial.begin(9600); // See the connection status in Serial Monitor
  Blynk.begin("xxx", IPAddress(45,55,130,102), 8442);  // Here your Arduino connects to the Blynk Cloud.
  
 updateTimer.SetCallback(OnTimer); 
 //updateTimer1.SetCallback(WordTittle); 
  
  pinMode(LOCK,OUTPUT);
  pinMode(UNLOCK,OUTPUT);
  pinMode(TRUNK,OUTPUT);
  pinMode(PANIC,OUTPUT);
  pinMode(ENGINE_START,OUTPUT);
  pinMode(ARM,OUTPUT);
  pinMode(Engine_Status,INPUT);
  pinMode(ARM_ENGINE,OUTPUT);
  
  digitalWrite(LOCK,HIGH);
  digitalWrite(UNLOCK,HIGH);
  digitalWrite(TRUNK,HIGH);
  digitalWrite(PANIC,HIGH);
  digitalWrite(ENGINE_START,HIGH);
  digitalWrite(ARM,HIGH);
  digitalWrite(ARM_ENGINE,HIGH);
  
 

  
 
  
    
}
//void OnTimer(void){
    
    //void start();
  
    
//}
//void WordTittle(void){
   //  Blynk.virtualWrite(V8,"LOCK ");
   // Blynk.virtualWrite(V9,"UNLOCK ");
   // Blynk.virtualWrite(V10,"PANIC ");
   // Blynk.virtualWrite(V11,"TRUNK ");
   // Blynk.virtualWrite(V12,"ENGINE START ");
   // Blynk.virtualWrite(V13,"ARM/ACTIVE ");
  

void OnTimer(void) {
       ENGINE_STATUS = digitalRead(Engine_Status);
   if (ENGINE_STATUS == HIGH){
        
        Blynk.virtualWrite(V7,"ENGINE ON "); 
        
    }
    else {
        
       Blynk.virtualWrite(V7,"ENGINE OFF ");
    }
    


       
}   
    
   

// Lock

BLYNK_WRITE(V0) //Function to test status from BLYNK widget to PHOTON
{
int state = param.asInt();
if (state ==1)
{
digitalWrite(LOCK,LOW);
}
else if (state ==0)
{
digitalWrite(LOCK,HIGH);
}
}
//Unlock

BLYNK_WRITE(V1) //Function to test status from BLYNK widget to PHOTON
{
int state = param.asInt();
if (state ==1)
{
digitalWrite(UNLOCK,LOW);
}
else if (state ==0)
{
digitalWrite(UNLOCK,HIGH);
}
}
//Trunk

BLYNK_WRITE(V2) //Function to test status from BLYNK widget to PHOTON
{
int state = param.asInt();
if (state ==1)
{
digitalWrite(TRUNK,LOW);
}
else if (state ==0)
{
digitalWrite(TRUNK,HIGH);
}
}
//Panic

BLYNK_WRITE(V3) //Function to test status from BLYNK widget to PHOTON
{
int state = param.asInt();
if (state ==1)
{
digitalWrite(PANIC,LOW);
}
else if (state ==0)
{
digitalWrite(PANIC,HIGH);
}
}
// ENGINE_START

BLYNK_WRITE(V4) //Function to test status from BLYNK widget to PHOTON
{
int state = param.asInt();
if (state ==1)
{
digitalWrite(ENGINE_START,LOW);
}
else if (state ==0)
{
digitalWrite(ENGINE_START,HIGH);
}
}

// ARM /active 
BLYNK_WRITE(V5) //Function to test status from BLYNK widget to PHOTON
{
int state = param.asInt();
if (state ==1)
{
digitalWrite(ARM,LOW);
Blynk.virtualWrite(V6,"CAR ARMED "); 
digitalWrite(ARM_ENGINE,LOW);
 Blynk.virtualWrite(V14,ON);
  Blynk.virtualWrite(V15,OFF);   
  
 
}
else if (state ==0)
{
digitalWrite(ARM,HIGH);
Blynk.virtualWrite(V6,"CAR DISARMED ");
digitalWrite(ARM_ENGINE,HIGH);
Blynk.virtualWrite(V14,OFF);
  Blynk.virtualWrite(V15,ON);

  
}
}  

void loop()
{
   
 updateTimer.Update(); 

  Blynk.run(); 
 
}

You may need to set the correct Particle.keepAlive() value for your provider.

Start with 30sec.

With Electron you can get rid of SparkCorePolledTimer and rather go for Software Timer.

If I recall correctly, you need a keep alive of 30 seconds with AT&T.

All you need is add a line in setup():

Particle.keepAlive(PARTICLE_KEEPALIVE);

Thank u all
I’ll try these changes thanks

I have found that the blynk library causes problems with OTA updates. Anything newer than version 0.3.10 of the blynk library will cause a time out error when trying to flash OTA. Not sure what the fix is for this, or what specifically in the library causes this.

EDIT–
I have since found the change from the library is that blynk.begin will block if it does not connect to the blynk server. I had an auth code mix up which prevented me from connecting to the server which in turn blocked me from doing over the air updates.

1 Like