No cloud local wifi

@Jeffery, could you please reformat your code as outlined here :wink:

Then next, since the Core does remember WiFi networks it was previously connected to, you won't need WiFi.setCredentials() each time (use WiFi.hasCredentials() to find out).
But if you must, I'd call WiFi.setCredentials() before the attempt to connect, otherwise the Core will go into listening mode, if there aren't any credentials already set.

And as for breathing green, this is how it's supposed to be when connected to WiFi but not to cloud - as @Hootie81 has told you already.

I've tested your code with some minor alterations reflecting my above suggestions, and it does what it should.

Additionaly, how did you connect your button? If not pressed the pins might float, giving you wrong readings, and some debounce would be good too.


Edit: For your questions above

That solely depends on your own use case.
If you need it from the first breath of the Core, then setup() is a good place.
If you only want it on demand, you'll put it somewhere where it will be called when it's time for - e.g. in some function the gets called from within loop(), like in your sample.

What do you exactly mean by this?
When I run that code (with WiFi.connect() and WiFi.off()) loop() just keeps looping as ever, "despite" breathing green.
Just try it without WiFi.setCredentials() and WiFi.listen().