Using spark on on WiFi only without connecting to cloud [Solved]


#1

Hello,

I am using the Spark Cores (as clients) successfully to connect to a TCP/IP server.

Right now the router I am using it connected to the internet and the Spark Cores connect to the internet everytime I reset them.

Is there a way I can only connect to the WiFi network and not the cloud and still connect to the locally running TCP/IP server which I have implemented in C++.

I will be completely fine if the cores don’t connect to internet at all and function fully on Wifi.

Thanks


WiFi but no internet
Argon and Xenon network without internet access
#2

I have done this before using the Arduino and the CC3000, I just feel that the spark core is tiny and has both the things combined. I wonder If I can use the spark core like that?


#3

Yes, it is possible.

In your WebIDE application, change SYSTEM_MODE(AUTOMATIC); to SYSTEM_MODE(SEMI_AUTOMATIC); then use WiFi.ready() check before TCPClient::connect


#4

To add on to @satishgn’s point,

you can read the documentation at: http://docs.spark.io/firmware/#eeprom-semi-automatic-mode :wink:


#5

@satishgn and @kennethlimcp

Thank you so much for your help, but I fairly new to this and a little confused.
I know I need to change the SYSTEM_MODE to "Semi_ Automatic"
But, do I need to set the Wifi credentials in the code itself or will the Core handle that automatically?
Also does the semi automatic mode connect to the spark cloud by default?

Can you please help me kickstart by sharing some sample code?


#6

1.) The Wifi Credentials are stored in the CC3000 profile when you send them to the core. They will remain unless you perform a factory reset or delete them with code.

2.) All you need to do is to use the following template:

SYSTEM_MODE(SEMI_AUTOMATIC);

void setup(){
}

void loop(){
}

In SYSTEM_MODE(SEMI_AUTOMATIC);, the core will only attempt to connect to Wifi and NOT the Spark Cloud. User code will run immediately once Wifi connection is established.

Also mentioned in the documentation:

The semi-automatic mode will not attempt to connect the Core to the Cloud automatically. However once the Core is connected to the Cloud (through some user intervention), messages will be processed automatically, as in the automatic mode above.

#7

It works brilliantly well…!!! Thanks for the help
Never realized it needed just one Line of code.


#8

Hello there @satishgn,

I’m trying to implement the WiFi connection only, and for some reason I can’t get my Core to be assigned an IP address.
I changed the mode to SEMI_AUTOMATIC and am doing a Serial.println(WiFi.ready()) in my void loop() to check if I’m getting connected, but I’m only getting a zero returned for some reason.
My core is breathing cyan. Not sure if this should happen no matter what since I am in SEMI_AUTOMATIC mode vs. AUTOMATIC.

This is the overlying structure of my code

void setup()
{
//setup stuff
}

void loop()
{
   if (WiFi.ready())
      {
          //actual code stuff
      }
   Serial.println(WiFi.ready());
}

I am running a Local Cloud, and prior to this, I had my Core in AUTOMATIC mode and connecting to the Local Cloud. I have determined I don’t need the services of the Local Cloud since I am not actually using any spark variables or types etc and uploading all my code over USB with DFU-UTIL. I had successfully connected to my network prior to this. My network is a local network with no internet connection.

Let me know if anything is to vague and I’ll gladly update.

Regards,
Nick


#9

Hi @greenoutlet,

You need to call WiFi.connect() explicitly once in SEMI_AUTOMATIC mode to get connected to the local network without connecting to the cloud. For connecting to cloud, just calling Spark.connect() will do everything i.e. connect to network and then to the cloud.

Thanks,
Satish