Particle doesn't connect to cloud after restarting

When I restart my photon it does all the normal restarting procedure up until its trying to connect to the cloud (flashes white after flashing green) but the white flashing takes much longer than it did when i first purchased it. It sometimes will take little time to restart, and go to breathing white in an instant. Most of the time it’ll flashing white for a long time and wont restart unless I press the reset button over and over.
I am using the particle browser to flash code to it, if that matters.
I’ve found this topic on multiple threads and none of them seem to help.

Any help is greatly appreciated

How does it behave when it’s running Tinker?

I quickly flashed the example that comes in the web browsers and for now seems to do the trick. Does this mean ill have to include tinker in all of my scripts

Nope, it rather means you need to locate the part of your code that caused this mis-behaviour and change that :wink:

Seeing your code would help us to point you at the respective part(s)

1 Like

Here is the code i am trying to use. Alot of things are commented out as i was trying to debug the circuit i was builiding for the one-wire water proof temperature sensor.

     // This #include statement was automatically added by the Particle IDE.
 #include "SparkTime/SparkTime.h"
 // This #include statement was automatically added by the Particle IDE.
 #include "Adafruit_DHT/Adafruit_DHT.h"
 // This #include statement was automatically added by the Particle IDE.
 #include "OneWire/OneWire.h"
 // This #include statement was automatically added by the Particle IDE.
 #include "spark-dallas-temperature/spark-dallas-temperature.h"
 // This #include statement was automatically added by the Particle IDE.
 #include "blynk/blynk.h"

 #define DHTPIN 3     // what pin we're connected to
 #define DHTTYPE DHT11		// DHT 11 
 #define ONE_WIRE_BUS D2
 #define TEMPERATURE_PRECISION 9
 #define RELAY_OFF 1
 #define RELAY_ON 0

 #define Relay_1  5  // Arduino Digital I/O pin number
 #define Relay_2  6

 int h =-1;
 int  t =-1;
 int f=-1;
 int hi =-1;
 int dp = -1;
 int TempC = -1;
 double InTempC = -1;
 int waterTempF = -1;
 char results[64];
 char auth[] = "bf45e278b95f4458a7e447aa781af319"; 
 char result[64];

 int led2 = D7;

 DHT dht(DHTPIN, DHTTYPE);

 OneWire oneWire(ONE_WIRE_BUS);
 DallasTemperature sensors(&oneWire);
 DeviceAddress inWaterThermometer = { 0x28, 0xB6, 0x78, 0x5E, 0x07, 0x0, 0x0, 0x4F };

 void update18B20Temp(DeviceAddress deviceAddress, double &tempC);

 void setup() {
     Serial.begin(9600); 
       Blynk.begin(auth);
 Particle.variable("Humidity",h);
 Particle.variable("AmbientTempC",t);
 Particle.variable("AmbientTempF",f);
 Particle.variable("WaterTempF",waterTempF);
 Particle.variable("WaterTempC",InTempC);
 Particle.variable("result",results,STRING);
 //Particle.publish("result",result,STRING);
// DS18B20 initialization
sensors.begin();
sensors.setResolution(inWaterThermometer, TEMPERATURE_PRECISION);
dht.begin();
pinMode(led2,OUTPUT);

pinMode(Relay_1, OUTPUT);   
pinMode(Relay_2, OUTPUT);
 }

 void loop() {
     delay(1000);
Blynk.run();
digitalWrite(led2, LOW);


  h = dht.getHumidity();
  t = dht.getTempCelcius();
  f = dht.getTempFarenheit();
  //  hi = dht.getHeatIndex();
 //   dp = dht.getDewPoint();

    // DS18B20
    sensors.requestTemperatures();
    update18B20Temp(inWaterThermometer, InTempC);
    waterTempF = (InTempC * 9)/5 + 32;


  if (waterTempF<= 65)
 {
 digitalWrite(led2, HIGH);
 }
   else
 digitalWrite(led2,LOW);
 }


 //digitalWrite(Relay_1, RELAY_OFF);
 Serial.print("Humid: "); Serial.print(h);Serial.print("%");Serial.print("Temp: ");                  Serial.print(t);Serial.print("*C ");Serial.print(f);Serial.print("*F ");Serial.print(" - ");Serial.print("Water Temp:"); Serial.print(waterTempF);Serial.println("F");
 //Serial.println(Time.timeStr());
  Blynk.virtualWrite(V1, f);
  Blynk.virtualWrite(V4, waterTempF);
 Blynk.virtualWrite(V2, h);


//google docs will get this variable - if you are storing the value in a google sheet	 
//sprintf(results,"%i %i %i %i", (int)waterTempF, (int)f, (int)h,(int)dp); 
}
void update18B20Temp(DeviceAddress deviceAddress, double &tempC)
{
  tempC = sensors.getTempC(deviceAddress);
}

Sorry its a little messy, thanks again

Just a few hints.
You don’t seem to use the SparkTime library, so just remove that (BTW I’m not sure what the benefit of this lib is over the native RTC Time features).
When using Blynk you should not have a delay(1000) slow down the Blynk tasks. Rather use a non-blocking approach like this

void loop() {
  static uint32_t msSoftDelay = 0;
  // full speed actions here
  Blynk.run();
  if (millis() - msSoftDelay < 1000) return;
  msSoftDelay = millis();
  // soft-delayed actions here 
  ...
}

But to pinpoint the cause of your issues, you may want to find out if Blynk is contributing to it or not and hence just comment all Blynk stuff and see if the issue persists or not.

And try to use the more elaborate pin names D0, D1, … instead of these anonymous pin numbers :wink:

2 Likes