No cloud local wifi

Want to know if it is possible to sent commands and receive data such as timer from spark core without cloud using local wifi with no internet. i am unable to connect it to my local wifi (no internet, tried setting it up with usb without success of connecting to wifi, it ended up glowing green.) I did SYSTEM_MODE(MANUAL); .

Sure it is and there are several topics in this forum to search for, that will show you how :wink:

hmmm i just want to control it with C# program with local Wi-Fi.
It’s just
Start up -> Start Timer -> Sensor trip -> stop timer
do i need cloud for this simple stuff?
i can just flash my spark via usb

Yep its totally possible to do that, this link should get you started. make sure to read to the bottom. you can use wifi without cloud

I did
SYSTEM_MODE(MANUAL); -> WiFi.on(); -> WiFi.connect(); -> WiFi.setCredentials(“TP-LINK_0134CC”);

it ended up glowing green

Start by connecting the core to a normal network and claim it and set everything up. program it with your code you want to run on its normal network. put the core in listening mode by pushing the mode button for 3 seconds till it flashes blue, enter your wifi logon details using usb. once you have connected your core to the wifi you should be able to run in manual mode or semi auto. all you need is wifi.on and wifi.connect. if you call wifi.setcredentials it will put the core back to flashing blue waiting for wifi logon details.

pretty sure flashing green is connecting to wifi, breathing green is connected to wifi but not the cloud

I remember some new LED color patterns being introduced a while back, maybe @bko can confirm this is still the case, i cant find the full list of color patterns anywhere. I've searched the docs and support sites, but cant see anything besides the standard colors and troubleshooting colors.

i did manual mode and connected it to my wifi
but where should i put the connection part at? the setup?
i am not able to run the code after it is breathing green.
i did a simple button led code

SYSTEM_MODE(MANUAL);

int LED = D3;
int b1 = D1;
int b2 = D0;
int LCD = D2;


void setup()
{

pinMode(b1, INPUT);
pinMode(LED, OUTPUT);
pinMode(b2, INPUT);
pinMode(LCD, OUTPUT);
}

void loop() {
   
    if(digitalRead(b1) == LOW) {
    digitalWrite(LED, HIGH);
    //WiFi.off();
                          
  }
    if(digitalRead(b1) == HIGH) {
        digitalWrite(LED, LOW);
    }
    
    if(digitalRead(b2) == LOW) {
    digitalWrite(LCD, HIGH);
    delay(1000);
    digitalWrite(LCD, LOW);
    
    //WiFi.on(); < i commented out the wifi so it will not connect to wifi to show my superviser >
    //WiFi.connect();
    //WiFi.setCredentials("TP-LINK_0134CC"); <------ i tried both ways of seting up wifi listen and setcredentials
    //WiFi.listen();
    
    }
   /* if(digitalRead(Red) ==HIGH) {
        digitalWrite(LED, LOW);
    }*/
}

@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().

i did it with wifi on and connect only but after it breath green the button dont work

Can you share the code you are trying at the moment and a picture of the setup you are testing with showing how the buttons are wired? it would help us a lot to debug whats happening.

code are above the wiring is just button resis to D0 D1 button D2 D3 Led to resis to ground
button works fine as i did test it without the wifi and stuff in manual mode

try this code, ive changed the input to input_pullup. so your buttons will need to pull the pins to ground

SYSTEM_MODE(MANUAL);

int LED = D3;
int b1 = D1;
int b2 = D0;
int LCD = D2;


void setup()
{
pinMode(b1, INPUT_PULLUP);
pinMode(LED, OUTPUT);
pinMode(b2, INPUT_PULLUP);
pinMode(LCD, OUTPUT);
}

void loop() {
   
    if(digitalRead(b1) == LOW) {
        digitalWrite(LED, HIGH);
    }
    if(digitalRead(b1) == HIGH) {
        digitalWrite(LED, LOW);
    }
    
    if(digitalRead(b2) == LOW) {
        digitalWrite(LCD, HIGH);
        delay(1000);
        digitalWrite(LCD, LOW);
        WiFi.on(); 
        WiFi.connect();
    }

}
2 Likes

thx i works fine now

2 Likes