Having Trouble Setting up Wifi with my Particle App

I have a photon that I’ve used many times in the past and I’m trying to set up the Wifi credentials on it using the app. I keep getting the error message “Error: Please try running setup again after resetting your Photon and putting it back in blinking blue listen mode if needed”

I have also tried setting up via USB and get "Serial err: Error: Opening COM5: File not found.

I have reset the keys with "Particle keys doctor "

Windows is trying to install a “Microsoft Serial BallPoint” that seems to be tied to my photon…

image

The Photon detected as a Serial BallPoint mouse problem can be fixed with the instructions here:

Fixing this first may help because if the computer is communicating with the Photon with random serial characters, it will definitely prevent particle serial wifi from working and may even adversely affect phone-based setup.

Restarting the machine got rid of the “USB serial mouse” issue. I have seen it pop up a couple times, but restarting the Photon makes it go away. My user app uses serial to communicate with a chrome app so I may be getting the occasional errant message that causes the serial mouse issue.

I was able to get it setup with serial. I did notice that when I run particle setup on the CLI with my user code, it forces me to setup the photon by switching to it’s WiFi network (which is impossible on my computer as it doesn’t have a Wifi card…) but when I run particle setup when the photon is in Safe Mode, I am able to configure the wifi via serial.

I am still not able to setup the Photon via the Android App, and I’m having the same problem with a brand new, out of the box Photon. So I think there may be an issue with my phone. I un-installed the Particle Android app, restarted the phone, re-installed the app, logged out, logged back in and it still isn’t working. I’m using a Pixel running stock Android. I will try with another phone when I get a chance.

Connect the Photon by USB to your computer and use the command:

particle serial wifi

If it’s not already in blinking blue (listening mode), hold down SETUP until it is.

When asked if you want to scan for Wi-Fi networks, respond with N and just type in the SSID. This will allow you to set up the Photon by computer without using Wi-Fi.

Works in “safe mode” but hangs up after replying ‘n’ to “Should I scan for nearby Wi-Fi networks?” when running user code.

In my user code, I have the following handler for serialEvent and I am running with the SYSTEM_THREAD enabled, could it be interfering?

void serialEvent(){
  /*
  Serial data comes in form of:
    {variableName}:{selector}:{value} for a write, and
    {variableName}:{selector} (with no ":") for a read
  followed by a newline character.
  **if a variable not requiring a selector (ex. stepsPerMlA), then {selector}
    can be any value and is ignored by the interpreter

  ex. WRITE --> flowRate:1:250
      READ  --> flowRate:1
  */


  if(messageIndex < messageBufferSize) {
    char c = Serial.read();
    if(c != '\n' && c != ':') {
      messageBuffer[messageIndex++] = c;
    }else if(c == ':'){
      messageBuffer[messageIndex] = 0;
      if(FLAG_isSelectorSetting) {
        selectorBuffer = atoi(messageBuffer); // Data was Selector Number
        FLAG_isWrite = true; // Next data is value to write
      } else {
        strcpy(variableNameBuffer, messageBuffer); // Data was variableName
        FLAG_isSelectorSetting = true; // Next data is selector setting
      }
      messageIndex = 0;
    }else {
      messageBuffer[messageIndex] = 0;
      if(FLAG_isWrite){
        strcpy(valueBuffer, messageBuffer); // Data was new value
      } else if(FLAG_isSelectorSetting){
        selectorBuffer = atoi(messageBuffer); // Data was Selector Number
      } else{
        selectorBuffer = 0; // No Selector Setting was sent
        strcpy(variableNameBuffer, messageBuffer); // Data was variable name
      }
      FLAG_isSelectorSetting = false;
      FLAG_messageReceived = true;
      messageIndex = 0;
    }
  }else {
    messageIndex = 0;
  }
}

If you are using SYSTEM_THREAD(ENABLED) you’ll need to check for WiFi.listening() before running your serial code. The reason is that your code continues to run in that case, and it’s interfering with listening mode using the serial port.

2 Likes

That makes sense. I was able to configure wifi via serial once I added the Wifi.listening() check.

Thanks!