[solved]WiFi scan fails in manual/semi_automatic mode


I want to scan for nearby WiFi networks and send the list through a serial connection to an Uno while being outside the range of my own network. I’m using a Photon. For some reason my program only works in the automatic system mode connected to the cloud, and thus not outside. Whenever the scan starts the status LED is white for a moment and then sends an SOS followed by one blink, indicating a hard fault of some kind. What am I doing wrong? Should I be calling Particle.process() somewhere?

SOLUTION: put WiFi.on() in setup loop



void setup() {
// USB serial
Serial.println(“Hello world.”);


void loop() {
// Scan for acces points
WiFiAccessPoint aps[20];
int found = WiFi.scan(aps, 20);

for (int i=0; i<found; i++) {
    WiFiAccessPoint& ap = aps[i];
    Serial.print(String(i+1) + ": ");
    Serial.print(" [");
    Serial.printf("%02X:%02X:%02X:%02X:%02X:%02X", ap.bssid[0], ap.bssid[1], ap.bssid[2], ap.bssid[3], ap.bssid[4], ap.bssid[5]);
    Serial.print("] (");
    Serial.println(String(ap.rssi) + ")");


Try %02x instead of %02X. (Small x).

Thank you for your input!

In automatic mode, this turned the BSSID lowercase, program functions like it did before. In any other mode the device keeps failing to do anything other then SOS.

So the white flash it key here I think–that means that you are having trouble talking to the WiFi chip.

Is this a Core or a Photon?

Oops, I didn’t specify. I’m using a Photon.

I’ve noticed that the led remains white until Particle.connect() is called with other programs.

I should’ve spend more time in the reference documentation…

If you don’t call Particle.connect() yourself in semi_automatic or manual mode, the WiFi chip is not turned on . I added WiFi.on() in my setup loop and now it works. Sweet! :see_no_evil:

Thanks for your input everybody!