Can not Connect to my cell phone Hotspot

That is very odd, since the message would be independet of the WiFi connection.

What happens if you enter any other character? Do you get this displayed in your serial monitor?
But just to be on the safe side you can add some other cases to which shoul connect

like this

void loop()
{
  int c = Serial.read();
  switch (c)
  {
    case -1:
      // nothing to read, so ignore
      break;
    case '\r':          // hit emter to connect
    case 'c':          // or c
    case ' ':           // or spacebar / blank
      Serial.println("Try to connect to cloud");
      Particle.connect();
      Serial.println("See cyan blinking?");
    default:
      Serial.write(c);  // echo what we got
  }    
}

I actually did something similar but it never got the case. I tried with added space and ‘c’ but I still don’t see the “Try to connect to cloud” message in the serial.

On the other hand. I find if I turn hotspot on my phone, turn airplane mode on and off again, Reboot the phone, turn on hotspot, then reset the Photon it almost always connects and gets an IP Address. As a result I’m able to try the code snippets again and again.

What’s strange is that:

  1. I get a different IP Address each time
  2. On the phone I never see a device connected. When I connect my Surface to my phone for example, I see it appear on the phone instantly and I can see it’s IP address and MAC on the phone.

Holly crap!
It connected.
press Enter
I got a blue led for a split second (2 breadths) and then it switched to flashing green
Never see a “Try to connect” message in the terminal window, though

I did put a 1 second delay in the loop maybe that helps with capturing just one key press (I don’t know)

This happens with all my phones too. They seem to never hand out the same IP twice.


Try this sequence:

  • Safe Mode
  • flash above code
  • clear WiFi credentials
  • provide only phone hotspot credentials via serial monitor (press w and supply info)
  • reset device once going to green
  • try code above

I'm still very puzzled about the missing "Try to connect to cloud" message, since this has to happen.
There is no need for a delay, since the device buffers 64 byte of serial input and will process one by one (unless you type faster than 10k characters per second :wink: )

I just edited my earlier post.
I don’t ever see the “Try to connect to cloud” in the terminal window. So I’m guessing it never gets to the line, so the blue breathing LED may not be indicating connection to the cloud.

Is there a way to:

  1. get the device to connect to the cloud using an IP Address (not sure if that’s what it’s doing already). I want to see if I
  2. Specify and DNS the device can use (rather than use one from the phone).

I’ve also edited my above post :wink:

As it seems your WiFi is working, but the cloud connection not.
So the next thing to test in between those two states is how good the WiFi actually works.
For that reason I’ll just post you a simple TCPServer code which you can connect to via telnet.

SYSTEM_MODE(SEMI_AUTOMATIC)

TCPClient client;
TCPServer server(79);     // first try a safe port
//TCPServer server(5683); // later try the CoAP port for the cloud

void setup() {
  Serial.begin(115200);
  WiFi.on();
  WiFi.connect();
  waitUntil(WiFi.ready);

  server.begin();

  while(Serial.read() < 0) Particle.process();
  Serial.printlnf("SSID\t: %s"    , (const char*)WiFi.SSID());
  Serial.printlnf("Local IP\t: %s", (const char*)WiFi.localIP().toString());
}

void loop() {
  char x;

  if(!client.connected())
  {
    client = server.available();
    if (client.connected())
    {
      client.printlnf(" Hi, I am Photon!\r\nHow can I serve you? (%s)", (const char*)client.remoteIP().toString());
    }
  }
  else
  {
    while(client.available())
    {
      switch(x = client.read())
      {
        case '?':           // disconnect client
          client.println("Good Bye!");
          client.stop();
          break;
        case 'c':           // hit c to connect
          Serial.println("Try to connect to cloud");
          Particle.connect();
          Serial.println("See cyan blinking?");
        default:
          Serial.write(x);
      }
    }
  }
}
  • first press any key in serial monitor to get the server IP address
  • the try telnet <ip> 79
  • type in anything (not containing ?, c) and hit ENTER to test transmission
  • try c + ENTER to test cloud connection
  • try ? + ENTER to close the telnet connection

If this works apart from cloud, then change the port number to 5683 and retest to test if the cloud port is blocked on your hotspot - if cloud already works, just the better :wink:

On this one Photon, I have cleared credentials (setup down for 10 seconds).So the only credentials I have on there for my phone.

I’ll try the Safe mode step first and see

Here is something else I just tried. I used my wife’s phone’s hotspot. Again, the only credentials on the Photon are for that hotspot.
Flashed code
It connects without a problem
Never see the “Try to connect to the cloud”.

So I tried flashing one of my other apps that works against the eclipse MQTT broker. This app works as expected when connected to WiFi router.

Cleared credentials
Set credentials for Wife’s phone
Flashed code
Reset the device
I see it connecting and connected to the phone. Phone also reports 1 guest connected (this phone doesn’t show IP or MAC)
However, the app doesn’t actually work. Basically I can send it messages via the broker and it switches LED color. Doesn’t work. The device also sends message to a different topic on the broker. Never receive messages from the device either. Rebooted phone and device and tried all over again. No luck. That is the device is never actually getting on the Internet.

Are both phones going via the same provider/carrier?
Can other Photons get online via these phones?

Tried the TCPServer code.
For the first attempt I decided to use the Wifi router to ensure I’m using the app correctly.
So I cleared credential and set credentials for the Wifi router.
Flashed the code
reset the device and started the serial monitor using CLI
I see the device connected to my router (green breathing LED).
Press any key does not seem to do anything. That is I don’t see the IP (or SSSID)

I jumped on to my router and I can see the device is connected, so I got the IP address from there and using telnet, I attempted to connect to it on port 79
No luck there either.
I’m looking at the code above but I can’t see what I’m missing

Are both phones going via the same provider/carrier?
Can other Photons get online via these phones?

Yes, they use AT&T
I use my Surface via my phone almost every day. I just tried connecting each phone to the other and browsing various websites. All works as expected.

That explains some things :wink:
AFAIK CLI is only a monitor which does just display serial output, but does not actually send things to the device.
Try PuTTY or any other duplex serial monitor - even Particel Dev Serial Monitor would do.

By the way, I originally had the same misunderstanding with particle serial monitor. I kept wondering why my code wasn’t allowing me to hit a key to continue! It’s because it literally only monitors, and does not allow you to send.

Gosh, I feel really stupid! Ok, I’ll try the TCP code and the others again…

There was a clue :wink:

Tried the original code (not the TCP Server code)
Device connects to my phone
I see the various messages in terminal program
Press ‘c’ and I see the message as well as the blinking blue led (blinking, not breathing).
Yay!
Hmmrph…
The see the led go to a dim blue (almost like it went into listen mode) for a split second. Then green flashing LED.

Tried the same with my wife’s phone (clearing credentials before). Same result.

Next I’ll try the TCP Server code with telnet

Could you post a video of that sequence?

> Could you post a video of that sequence?

Ok, let me do that

Here is a link to the video showing the outcome of the original program
Photon Connecting via Cell Phone to Cloud and disconnecting

I think I saw a short orange/red blip/burst there after the cyan, which would indicate a problem with the key exchange during cloud handshake.
But the device connects fine when you are going through your router?

If not, you could try

particle keys doctor

to repair the keys, but if it does work with the router, the phone hotspot seems to interfere.

BTW: Did you give the TCPServer a go? This might also show if the connection is flaky which is especially problematic during key exchange.

I don’t know if this makes a difference, but I’ve never used the Particle cloud except for the Web IDE and flashing my devices. I know the devices can get on the Internet via my router since everything I’m doing is Internet dependent. I mainly use http://iot.eclipse.org as my MQTT broker or I run Mosquito locally while developing/testing.

I tried the TCP server app. I had to get my desktop connected to the cell phones hotspot. I tried my wife’s cell phone first. And the program works as expected using port 79.

Now I’m going to try my cell phone also using port 79.