Photon operation w/o cloud connection

Using a Photon without Wi-Fi

In its default configuration (system mode AUTOMATIC without system threading), the Photon requires a Wi-Fi connection to operate, and won’t even run your user firmware.

This is just the default configuration, however, and there are numerous ways to use the Photon without Wi-Fi or the cloud.

Running with or without cloud

The easiest way to make your code run whether you have Wi-Fi or a cloud connection is to use SYSTEM_THREAD mode.

SYSTEM_THREAD(ENABLED);

You insert this at the top of your source file. What it does is run the cloud processing in a separate system thread and your code will run regardless of whether you have a connection or not.

The only thing to be careful is that when you do this, your loop code will run before connected to the cloud. Because of this, it’s useful to check for a connection before publishing events:

You might also do something like this in loop() when using Particle.publish:

if (Particle.connected()) {
	Particle.publish("myEvent", PRIVATE);
}

The same should be done for Particle.subscribe.

It’s not necessary to check before Particle.variable or Particle.function. These should always be made early in setup() and should not wait for a cloud connection.

Running with Wi-Fi off

If you don’t intend to use Wi-Fi at all, you can turn it off using the MANUAL system mode.

SYSTEM_MODE(MANUAL);

When you do this, the Photon will breathe white instead of cyan (light blue) and will not attempt to connect to the cloud.

If you want to over-the-air (OTA) flash your Photon with new code, you can use Safe Mode.

Press RESET and SETUP at the same time. Release RESET and continue to hold down SETUP until the status LED blinks magenta (red and blue at the same time). Release SETUP.

Safe mode connects to the cloud but does not run your user firmware, so Wi-Fi and the cloud connection will stay on so you can do an OTA flash.

Running with Wi-Fi but no cloud

It’s also possible to run the Photon with Wi-Fi enabled but no cloud connection. You might do this if you are using the Photon on an isolated network, not connected to the Internet, but you still have a Wi-Fi access point to connect to.

This mode allows communication between devices on the local Wi-Fi network using TCP or UDP. You can’t use things like Particle.publish without cloud access.

To do this you’ll probably use SEMI_AUTOMATIC system mode, though sometimes you may prefer MANUAL.

SYSTEM_MODE(SEMI_AUTOMATIC);

In your setup() function, you’ll probably use WiFi.connect.

WiFi.on();
WiFi.connect();

This will connect Wi-Fi only, not the cloud, and you’ll get breathing green instead of breathing cyan (light blue).

Running with SoftAP

In SoftAP mode, the Photon itself acts as a Wi-Fi access point. In this mode, another computer or phone can connect to the Photon Wi-Fi (“Photon-XXXX”) and communicate data directly by using TCP or UDP. You can’t use things like Particle.publish without cloud access.

To do this, you’ll need to use SYSTEM_THREAD mode.

SYSTEM_THREAD(ENABLED);

You’ll also need to probably use SEMI_AUTOMATIC system mode, though sometimes you may prefer MANUAL.

SYSTEM_MODE(SEMI_AUTOMATIC);

In your setup() function, you’ll probably use WiFi.listen.

WiFi.on();
WiFi.listen();

In listening mode, the Photon will blink dark blue.

2 Likes