Can not Connect to my cell phone Hotspot

Ok, thanks, let me try this.

On a slightly different topic. I’ve never been able to get the “Serial” to start/connect soon enough to see Serial.println() messages in setup. I’'ve tried tools such as Real Term, Putty etc. as well as the CLI serial monitor. I mean I know how to use Real Term and Putty, but I’m not able to connect to th eCOM port in time to see these messages fly by (if that makes sense).

So how does one pull this off exactly?

I see the “Here we go” message. The Photon is breathing green not blue. My phone doesn’t show it is connected, however.

That is odd, as the breathing green would indicate that your device is actually connected to a WiFi.

So let’s test the next step

SYSTEM_MODE(SEMI_AUTOMATIC)

void setup()
{
  WiFi.connect(); 
  Serial.begin(115200);
  while(Serial.read() < 0 && millis() < 10000) Particle.process(); // this waits here till you connect via Serial and hit a key (or max 10sec)
  
  if (!waitFor(WiFi.ready, 10000))
    Serial.println("Not able to connect to WiFi for 10sec");
  else
  {
    Serial.print("Here we go SSID: ");
    Serial.println(WiFi.SSID());
  }
}

void loop()
{
  if (Serial.read() == '\r') Particle.connect();  // to trigger a cloud connect hit enter
}

Sorry, I had to step away and get some other work done before the day ended…
What does “ready” actually mean. Only a connection or that it has received an IP address as well. I know from previous exercises that the device will connect, but not get an IP Address.

What’s happening now is that it breadths green, then after about a minute it starts to flash and this time it attempts another access point. Which has started me going the route of attempting to clear the cached credentials.

I’ll try out this other code and get back to you.

Same process as before
Thanks for the Particle.process() trick!
I see the correct SSID (my cell phone’s hotspot) in the terminal window
I then hit Enter.
Not sure what to expect with Particle.connect(), but I hit it a few times (seeing that it’s in a loop) but I didn’t see any signs of it being connected. The device is not showing as online in my Particle Devices page on Particle.io

I appreciate all of the help with trouble shooting @ScruffR! Hopefully we can get to the end game or file a bug or something.

I also get a case where I see an empty/blank SSID and an IP Address of 0.0.0.0 (I added the localIP() call);

This means that the WiFi module received the IP address, but if you request that IP via WiFi.localIP() it might not have been forwarded to the µC memory and hence you see 0.0.0.0.
To get around this add one call to Particle.process() - which would allow for pending WiFi tasks to be executed - before requesting IP or SSID.

Maybe like this

SYSTEM_MODE(SEMI_AUTOMATIC)

void setup()
{
  WiFi.connect(); 
  Serial.begin(115200);
  while(Serial.read() < 0 && millis() < 10000) Particle.process(); // this waits here till you connect via Serial and hit a key (or max 10sec)
  
  if (!waitFor(WiFi.ready, 10000))
    Serial.println("Not able to connect to WiFi for 10sec");
  else
  {
    Particle.process();
    Serial.printlnf("Here we go\nSSID\t: %s", WiFi.SSID());
    Particle.process();
    Serial.printlnf("localIP\t: %s", WiFi.localIP().toString().c_str());
  }
}

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

What color sequences do you see on the RGB LED?
Maybe post a video, since each step of the connection process has its own blink pattern, this gives you a good clue where the device is and which parts may be problematic (e.g. taking ages, timing out).

@ScruffR I changed the code to what you posted here. I retained the Macro (SEMI_AUTOMATIC).

Still doesn’t connect (flashing green LED). However, it takes at least 1 minute before I see the “Not able to connect to Wifi for 10 seconds” message.

I’ve has one case where it was flashing the green LED very rapidly. Every once in a while it would change the color for like a micro second to red/magenta and flash green slower (the normal rate) and then after about half a second go back to flashing green rapidly. This just happened 1 after resetting one time. I’ve not bee able to reproduce this. Most times, after resetting, it would just continue to flash green.

Got some good news and some bad news!

It connected and I see the correct SSID and I see an IP Address!
I then hit Enter
I don’t see the “Try to connect to cloud” message
No cyan breathing either
Hit Enter a few more times…nothing.

After about 45 seconds, it goes back to flashing green. Nothing on the Serial monitor after that.
Haven’t been able to reproduce by resetting multiple times and as well as turning my hot spot off and on again and various combinations.

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.