Setting/Reseting wifi credentials using Particle Javascript SDK

Hey everyone,

I’m looking to be able to reset, or update the wifi credentials on photons that will be in varies locations without actually have to be there. Any suggestions?

1 Like

Hi @pres_10

You can set unto 5 credentials ahead of time using

WiFi.setCredentials("SSID", "PASSWORD", WPA2, WLAN_CIPHER_AES));

The doc is here:

https://docs.particle.io/reference/firmware/photon/#setcredentials-

Here is the thing that trips people up: for offline networks, you must pass in the security type (i.e. WLAN_CIPHER_AES) since this cannot be discovered later.

1 Like

Thanks!

I notice from other threads that if someone wanted to add a new creds, or replace one of the existing 5 creds they would have to do it manually. Can I do that remote?

Seeing as the call @bko mentioned is in firmware, I see no reason why you couldn’t use a Particle.function() to do that. Your device will need to be online for that to work though, so you’ll have to set the new credentials before disconnecting from the current network.

2 Likes

@bko @Moors7

Trying it out now.