Argon Cloud Connection and Flash Problem

I am experiencing difficulties connecting any of my three Argon’s to the Particle Cloud. The problem seems to start already in the first step when the Argon tries to connect to my local WiFi network indicated by the LED blinking green, this already takes more time than connecting any of my Photon’s. For the Photon’s this mostly takes less than a few seconds, for the Argon’s this step takes mostly more than 20 seconds.

In the second step the situation is even worse when the Argon tries to connect to the Particle Cloud indicated by the LED fast blinking cyan, this usually takes minutes where my Photon’s achieve this within a few seconds.

I have also tried to connect the Argon’s through the hotspot network broadcasted by my iPhone. This is working fine for my Photon’s, but none of the Argon’s is able to connect to the Particle Cloud in this way.

Once, after considerable time, connected (breathing cyan) via my local WiFi network to the Particle Cloud the Argons can be inspected via the Particle Console. The console health check does not report any problems, e.g. the following is reported:

EVERYTHING LOOKS GOOD!

All diagnostic tests have passed. This device is healthy.

Jul 2nd, 2019, 10:38AM

Strong Wi-Fi signal

291ms round-trip time

100kB of 166kB RAM used

0 disconnect events

0 rate-limited publishes

But sadly in contrast to this ‘healthy’ report not everything is OK:

  • it is almost impossible to flash (OTA) code to the Argon (via dfu flashing is OK)
  • the Argon is not capable of retrieving the IP address of the connected dnsServer, the same code that works fine for Photons results in: 0.0.0.0 which is clearly wrong.
  • it is not possible to set the cipher to AES; the same code that is working fine for Photon’s sets the credentials cipher attribute to WLAN_CIPHER_AES (1) but when retrieved gets the value WLAN_CIPHER_AES_TKIP (3) instead.

Are there any other Argon users experiencing the same problem? If so, do you have an explanation and hopefully also a solution. I would be most grateful to get this problem solved and get the Argon’s implemented in a new project.

@Jack_v_D, what DeviceOS version are you using? What firmware are you running on the Argons? Can you place an Argon in Listening Mode and run (on latest Particle CLI) particle serial inspect and post the output?

Hello Peekay, thanks for your prompt response! The DeviceOS that I’m running is the latest 1.3.0-rc.1, I have tried older versions with the same result. The firmware that I’m running is a very basic program which is based on the Blink example and extended with some code mostly copied from the reference docs allowing me to inspect (WiFi) attributes on the device.
I have run particle serial inspect. The result is as follows:

jacks-mbp:BlinkPWB jackvandongen$ particle serial inspect
Platform: 12 - Argon
Modules
  Bootloader module #0 - version 311, main location, 49152 bytes max size
    Integrity: PASS
    Address Range: PASS
    Platform: PASS
    Dependencies: PASS
  System module #1 - version 1301, main location, 671744 bytes max size
    Integrity: PASS
    Address Range: PASS
    Platform: PASS
    Dependencies: PASS
      Bootloader module #0 - version 311
  User module #1 - version 6, main location, 131072 bytes max size
    UUID: 4CDA325A88CD985B24D198C1F0D1D4F954DD0E98B56983BE895FEC9B2A7557B4
    Integrity: PASS
    Address Range: PASS
    Platform: PASS
    Dependencies: PASS
      System module #1 - version 1301
  NCP module #0 - version 5, main location, 1536000 bytes max size
    Integrity: PASS
    Address Range: PASS
    Platform: PASS
    Dependencies: PASS
jacks-mbp:BlinkPWB jackvandongen$

@Jack_v_D, the inspect looks fine. Can you post your code?

Of course:

/*
 * Project BlinkPWB
 * Description: Simple Particle Device WiFi Connection Test Program
 * Author: JvD
 * Date:25 06 2019
 */

String versionNumber = "0.57";

int LED = D7;
WiFiCredentials credentials;
WiFiAccessPoint ap[5];
byte mac[6];
byte bssid[6];
const char* ssid;
int rssi = WiFi.RSSI();

// Open a serial terminal and see the IP address printed out
void handler(const char *topic, const char *data) {
    Serial.println("received " + String(topic) + ": " + String(data));
}



// setup() runs once, when the device is first turned on.
void setup() {
  // Temporarily switch the mesh network off
  // 
  #if Wiring_Mesh
    Mesh.on();
  #endif


  // Put initialization like pinMode and begin functions here.
  pinMode(LED, OUTPUT);

  // some WiFi experiments

  if (Particle.connected() == false) {
    WiFi.off();
    delay(100);
    WiFi.on();
    delay(100);
    Particle.connect();
    };
  delay(100);

  Particle.variable("VersionNumber",versionNumber);

  Serial.begin(9600);   // open serial over USB
  // Make sure your Serial Terminal app is closed before powering your device
  // Now open your Serial Terminal!
  while(!Serial.isConnected()) Particle.process();
  delay(250);

  Serial.println("Serial port is now connected, checking credentials....");

  int found = WiFi.getCredentials(ap, 5);
  for (int i = 0; i < found; i++) {
      Serial.print("ssid: ");
      Serial.println(ap[i].ssid);
      // security is one of WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA, WLAN_SEC_WPA2, WLAN_SEC_WPA_ENTERPRISE, WLAN_SEC_WPA2_ENTERPRISE
      Serial.print("security: ");
      Serial.println(ap[i].security);
      // cipher is one of WLAN_CIPHER_AES, WLAN_CIPHER_TKIP or WLAN_CIPHER_AES_TKIP
      Serial.print("cipher: ");
      Serial.println(ap[i].cipher);
  }

  Serial.println("Clearing credentials....");

  WiFi.clearCredentials(); 

  Serial.println("Checking cleared credentials....");

  // now see if the credentials have been cleared as excpected...
  found = WiFi.getCredentials(ap, 5);
  if (found==0) {
    Serial.println("No credentials found....");
  }
  for (int i = 0; i < found; i++) {
      Serial.print("ssid: ");
      Serial.println(ap[i].ssid);
      // security is one of WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA, WLAN_SEC_WPA2, WLAN_SEC_WPA_ENTERPRISE, WLAN_SEC_WPA2_ENTERPRISE
      Serial.print("security: ");
      Serial.println(ap[i].security);
      // cipher is one of WLAN_CIPHER_AES, WLAN_CIPHER_TKIP or WLAN_CIPHER_AES_TKIP
      Serial.print("cipher: ");
      Serial.println(ap[i].cipher);
  }

  Serial.println("Setting new credentials....");
  // Fast method:
  //WiFi.setCredentials("Apple Network van Jack", “*******”, WPA2);
  //WiFi.setCredentials("iPhone van Jack", “*******”, WPA2);

  // More elaborate method  
  credentials.setSsid("Apple Network van Jack")
            .setSecurity(WLAN_SEC_WPA2)
            .setCipher(WLAN_CIPHER_AES)
            .setPassword(“********”);
  WiFi.setCredentials(credentials);


  Serial.println("Checking credentials after setting on device....");

  // now see what the newly set credentials look like...
  found = WiFi.getCredentials(ap, 5);
  for (int i = 0; i < found; i++) {
      Serial.print("ssid: ");
      Serial.println(ap[i].ssid);
      // security is one of WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA, WLAN_SEC_WPA2, WLAN_SEC_WPA_ENTERPRISE, WLAN_SEC_WPA2_ENTERPRISE
      Serial.print("security: ");
      Serial.println(ap[i].security);
      // cipher is one of WLAN_CIPHER_AES, WLAN_CIPHER_TKIP or WLAN_CIPHER_AES_TKIP
      Serial.print("cipher: ");
      Serial.println(ap[i].cipher);
  }

  Serial.println();

  WiFi.macAddress(mac);
  Serial.printf("MAC          = ");
  for (int i=0; i<6; i++) {
    Serial.printf("%02x%s", mac[i], i != 5 ? ":" : "");
  }
  Serial.println();

  WiFi.BSSID(bssid);
  Serial.printlnf("BSSID        = %02X:%02X:%02X:%02X:%02X:%02X", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]);
  
  ssid = WiFi.SSID();
  Serial.print("SSID         = ");
  Serial.println(ssid);

  Serial.printlnf("RSSI         = %d", (int8_t) WiFi.RSSI());

  Serial.print("local IP     = ");
  Serial.println(WiFi.localIP());

  Serial.print("subnet mask  = ");
  Serial.println(WiFi.subnetMask());

  Serial.print("gateway IP   = ");
  Serial.println(WiFi.gatewayIP());

  Particle.process(); 
  //delay(5000);
  Serial.print("dnsServer IP = ");
  Serial.println(WiFi.dnsServerIP());

  Serial.println();
  Particle.subscribe("particle/device/ip", handler, MY_DEVICES);
  Particle.publish("particle/device/ip", PRIVATE);

  Particle.subscribe("particle/device/name", handler, MY_DEVICES);
  Particle.publish("particle/device/name", PRIVATE);
  

}

// loop() runs over and over again, as quickly as it can execute.
void loop() {
// The core of your code will likely live here.
// some WiFi experiments

digitalWrite(LED, HIGH);
delay(5000);
digitalWrite(LED, LOW);
delay(5000);

WiFiSignal sig = WiFi.RSSI();
Particle.publish("WiFi StrengthValue: ", String(sig.getStrengthValue()), PUBLIC);
Particle.publish("WiFi QualityValue : ", String(sig.getQualityValue()), PUBLIC);

Serial.print("dnsServer IP = ");
Serial.println(WiFi.dnsServerIP());

}

Yup, that is a problem I have already pointed out to the engineers but it seems to be something we need to live with :pensive:

1 Like

That would be really sad… so OTA updating Agon firmware is then out of the question???

No, the slow reconnect doesn't really prevent OTA updating, it just makes it tedious when the update also involves a device OS update.
I can OTA update my devices just fine, but slow. While with Gen3 most my testing was done with Photons, with Gen3 I'm more often using the Boron to test as it typically reconnects quicker than the Argon :upside_down_face:

BTW, I'd advise against calling WiFi.clearCredentials() by default.
Also "permanently" calling WiFi.RSSI() isn't best practice and will well contribute to your OTA update issues.

I have tried OTA many times where only the user firmware was changed (so no new DeviceOS needed). But also then I run almost always in a situation where the Argon seems dead (LED constant magenta). I think I have done at least 100 runs and perhaps three have succeeded in correctly loading the new firmware.

for how long?

As pointed out above. WiFi.RSSI() and (additionally) your delay(5000) calls don't help responsiveness and will bog down the OTA update download.
Try adding SYSTEM_THREAD(ENABLED) and avoid using delay() (and the use of String :wink: ) wherever possible.

This would be one way to make your loop() less blocking

void loop() {
  static uint32_t ms = 0;
  // The core of your code will likely live here.
  // some WiFi experiments

  if (millis() - ms < 5000) return;
  ms = millis();
  digitalWrite(LED, !digitalRead(LED));

  if (!digitalRead(LED)) {
    char data[64];
    WiFiSignal sig = WiFi.RSSI();
    snprintf(data, sizeof(data), "S: %.2f, Q %.2f", sig.getStrengthValue(), sig.getQualityValue());
    Particle.publish("WiFi", data, PRIVATE); // don't use PUBLIC unless you absolutely must
    Serial.printlnf("dnsServer IP = %s", (const char*)WiFi.dnsServerIP().toString());
  }
}

I have used WiFi.clearCredentials() on purpose in this test program in order to be sure to get a clean device. Before this line of code I already had the same problems. I do not intent to use WiFi.clearCredentials() in ‘normal’ program.

Can you tell me what the result of “frequently” calling WiFi.RSSI() is? And how does this affect the OTA issue?

WiFi.RSSI() is a blocking function and the device will be unresponsive to the cloud during these periodes.

LED constant magenta lasts for more than five minutes.

I see your points in (NOT) using calls to WiFi.RSSI() and delay(5000). I wil rewrite the code tomorrow using SYSTEM_THREAD(ENABLED). I have to go out in half an hour. Tomorrow I will let you know the new results. Thanks already for your prompt support!!

1 Like

Dear ScruffR,
sadly I did not have much time available today to proceed, here are the results so far.
I have carried out some changes along your suggestions.

  • Connecting to the Particle Cloud via my local WiFi network is now faster (although not comparable to Photon’s).
  • But I’m still not able to connect to my iPhone’s hotspot network.
  • I’m also not able to retrieve the IP address of the dns server.
  • Flashing of changed (user)firmware via the Particle Cloud now sometimes succeeds, but is very very slow and many time does not succeed (steady magenta LED after more than 5 minutes).
    I’m using now SYSTEM_THREAD(ENABLED) and I don’t have repetitive calls to WiFi.RSSI() and also no usage of ‘delay(…)’ anymore.
    I hope to have some more time tomorrow. Then I will clean up my code and send you the latest version to check with my results.

Kind regards,
Jack

1 Like