Photon can't get Cloud connection [SOLVED]

Hi all, I was working well with my photon since many week ago. But today it can’t get cloud connection, the cyan led still flashing all time. I was read many post and trying many things (I believe), but nothing change.

I tried the following things and all of them was done successfully but it stills without cloud connection: Erase wifi table connections and introduce a new credential, testing with other networks, flash tinker over USB, and finally a Firmware locally update to 0.5.0 with dfu-util.

Some one have another idea to be checked ?? Can I ask from cloud if the photon is trying to reach them ??

Is it flashing slow (~0.5Hz) or faster (with or without a short red/orange burst)?
Any changes on your router/firewall?

Yes, my cyan led still flashing faster all time. Some times goes green for a 2 - 3 seconds and came back quickly again to faster cyan flashing. Nothing changes on my router and also I was testing with my phone tethering.

In addition I got another older photon unit that was working properly and connected to the cloud and after upgrade to 5.0 same history, also it’s showing cyan led flashing faster… I’m really frustrated with this because I’m doing something wrong.

thanks.

I have new dates… First, I can’t put in SafeMode. When I try yo put in safe mode then I get a cyan flashing faster mode instead magenta flashing and Second. If the photon is blinking cyan this means that it reach wifi connection but not cloud connections, so why I can’t see into my network? This means that the problem is related with authentication or get a valid IP address ??. Please some help on this??

Note. also I updated the public Keys by putting the photon in DFU mode and doing “particle keys server cloud_public.der” and then “particle keys doctor -photon_id-”

video with flashing issue

That is normal. Only once you got connected to the cloud the LED would go breathing magenta.

And in your video I think to see a quick orange burst before going green again.
So particle keys doctor <deviceID> should work - unless your network blocks the port or target address.

To narrow down things, you could flash a sketch with SYSTEM_MODE(SEMI_AUTOMATIC) and only WiFi.connect() to see if you can get onto your WiFi.
Next you could try one of the TCPServer samples to see if you can connect to a public server.
If all that works you could test if CoAP port 5683 is open.

Good idea. I’m adding a sketch with following and I see some changes…

 SYSTEM_MODE(SEMI_AUTOMATIC);

void setup(){

  // Make sure your Serial Terminal app is closed before powering your device
  Serial.begin(9600);

  WiFi.connect();

  for(int i=0;i<10;i++){
      Serial.println("waiting " + String(10-i) + " seconds before we...");
      delay(1000);
 }

  Serial.println(WiFi.localIP());
  Serial.println(WiFi.subnetMask());
  Serial.println(WiFi.gatewayIP());
  Serial.println("SSID:" + String(WiFi.SSID()));
}

void loop(){
}

And I’m getting 0.0.0.0 for localIP, subnetMask and gateway. Also SSID is blank. I forced to get a static IP adding the following before WiFi.connect():

  IPAddress myAddress(192,168,1,70);
  IPAddress netmask(255,255,255,0);
  IPAddress gateway(192,168,1,1);
  IPAddress dns(192,168,1,1);
  WiFi.setStaticIP(myAddress, netmask, gateway, dns);

  // now let's use the configured IP
  WiFi.useStaticIP();

Now photon get those IP parameters, but en both cases there is the same result, now the led is green and blink slowly, What this means? now is in the network but is not trying to reach the particle cloud.

So next test has been try to get something out there:

SYSTEM_MODE(SEMI_AUTOMATIC);

TCPClient client;

void setup(){

  Serial.begin(9600);

  IPAddress myAddress(192,168,1,70);
  IPAddress netmask(255,255,255,0);
  IPAddress gateway(192,168,1,1);
  IPAddress dns(192,168,1,1);
  WiFi.setStaticIP(myAddress, netmask, gateway, dns);

  WiFi.connect();

  for(int i=0;i<10;i++){
      Serial.println("waiting " + String(10-i) + " seconds before we...");
      delay(1000);
  }

  Serial.println(WiFi.localIP());
  Serial.println(WiFi.subnetMask());
  Serial.println(WiFi.gatewayIP());
  Serial.println("SSID:" + String(WiFi.SSID()));

  if (client.connect("google.com", 80))
  {
    Serial.println("connected");
    client.println("GET /search?q=unicorn HTTP/1.0");
    client.println("Host: www.google.com");
    client.println("Content-Length: 0");
    client.println();
  }
  else
  {
    Serial.println("connection failed");
  }

}

void loop(){
  if (client.available())
  {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected())
  {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;);
  }
}

and the response was:

Opening serial monitor for com port: "/dev/cu.usbmodem1411"
waiting 9 seconds before we...
waiting 8 seconds before we...
waiting 7 seconds before we...
waiting 6 seconds before we...
waiting 5 seconds before we...
waiting 4 seconds before we...
waiting 3 seconds before we...
waiting 2 seconds before we...
waiting 1 seconds before we...
192.168.1.70
255.255.255.0
192.168.1.1
SSID:MOVISTAR_1218
connected
HTTP/1.0 302 Found
Location: http://www.google.es/search?q=unicorn&gws_rd=cr&ei=XBZLV-vCEMj6UMnKjsgK
Cache-Control: private
Content-Type: text/html; charset=UTF-8
P3P: CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."
Date: Sun, 29 May 2016 16:18:36 GMT
Server: gws
Content-Length: 276
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Set-Cookie: NID=79=CK-fCT5QU1IEYli4u8KEAOzKQ4TLHSzL1BtqYWDYVxKyMFD9YmWcFF2EuBt1l_F_-RskrgFxd7M-PKDyEgaV26eVM-Lazl2YnQjOp220J4qG3gkhm3I1M6ZdSl10GhCn; expires=Mon, 28-Nov-2016 16:18:36 GMT; path=/; domain=.google.com; HttpOnly

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.es/search?q=unicorn&amp;gws_rd=cr&amp;ei=XBZLV-vCEMj6UMnKjsgK">here</A>.
</BODY></HTML>

disconnecting.

So, seems that is reaching google.com… why is not connecting to particle cloud??
(two days ago was working properly and nothing was changed on my network settings and also I tried with a tethering with my phone).
Note that this is the same in two of my photon boards working with an updated firmware…
I’m really obfuscated with this issue…

WiFi.connect() with DHCP IP lease can easily take more than 10sec, so I'd rather use

  uint32_t ms = millis();
  waitUntil(WiFi.ready);
  Particle.process();
  Serial.printlnf("WiFi took %u seconds to connect", (millis()-ms) / 1000);

and I'd think you should stick with WiFi.useDynamicIP().

And it's normal that the LED stays green when only connected to WiFi/internet and sure there is no Particle cloud connection without a call to Particle.connect().
That test was meant to see where things go pear shaped and now we know WiFi and inet are fine.

If you had a cloud connection, this would kill it.

Rather do

  for(;; Particle.process()); // halt code, but keep cloud connection alive

OK
Now seems that photon get a dynamic IP from router and still reaching google.com

Opening serial monitor for com port: "/dev/cu.usbmodem1411"
WiFi took 0 seconds to connect
192.168.1.38
255.255.255.0
192.168.1.1
SSID:MOVISTAR_1218
connected
HTTP/1.0 302 Found
Location: http://www.google.es/search?q=unicorn&gws_rd=cr&ei=GBxLV4DvDMu8adeJtrgJ
Cache-Control: private
Content-Type: text/html; charset=UTF-8
P3P: CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."
Date: Sun, 29 May 2016 16:43:04 GMT
Server: gws
Content-Length: 276
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Set-Cookie: NID=79=qbT9cRTFF94DYcKP6LTuwJyLBq4SzUwnHKN2rLrjEZB7cH3A4D6ORAbxVSjsUcaE1KiQYdHDS8NDumbE36m8DJZiSA9M9Lw_LJ1UMwpR5k2Tul-SJYYWiqPjWrF1PXHu; expires=Mon, 28-Nov-2016 16:43:04 GMT; path=/; domain=.google.com; HttpOnly

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.es/search?q=unicorn&amp;gws_rd=cr&amp;ei=GBxLV4DvDMu8adeJtrgJ">here</A>.
</BODY></HTML>

disconnecting.

So, next step is to perform a Particle.connect() ??

Exactly and you can use waitUntil(Particle.connected)

Great! Cloud reached!.. many many thanks!

now the question is why is not doing this automatically??

the documentations say "In most cases, you do not need to call Particle.connect(); it is called automatically when the device turns on"

and mysteriously also now I have removed the Particle.connect() sentence and still connecting to the cloud… seems that something has been unblocked !!!

That is the intended effect of SYSTEM_MODE(SEMI_AUTOMATIC)!

If you remove that your application will revert back to default AUTOMATIC mode which will do it … guess? … automatically.