Does Particle.disconnect() Stop all Data usage?

I am trying to only use data a couple of times a day.
I need to keep the uC running.

Does Particle.disconnect() Stop all Data usage?

Or is Cellular.disconnect() also needed?

I believe Particle.disconnect() is sufficient but if you want to cut off cellular connnection, Cellular.disconnect() is the way to go.

@kennethlimcp Thanks…I am trying to stop all data including particle.keepalive.

Having much trouble with Cellular.connect() and Cellular.disconnect()
I can start in SYSTEM_MODE(MANUAL);
Use Particle.connect() and It does connect breathing cyan.

When I Use Particle.disconnect() it starts breathing green…ok
When I then try to Cellular.disconnect() … it stays breathing green and not breathing white.

I am trying a 3rd party sim and I can receive an SMS received RI_UC interrupt.
I am trying to use this to start data connection again…but have several issues.
Particle.connect() also doesn’t work after a Particle.disconnect() occurs.
I have to re-power the device…RESET does NOT solve connection issue.
I am using 0.5.3 rc2 firmware…this occured with 0.5.2 also.

You might need Cellular.connect() before Particle.connect()

This is my code.


	Serial1.println("Calling Cellular On");
	Cellular.on();
    	delay(8000);
    	Serial1.println("Calling Cellular Connect");
    	Cellular.connect();
    	delay(8000);
    	Serial1.println("Calling Particle Connect");
    	Particle.connect();
    	Particle.process();

It keeps flashing green.
I have too cold boot the Electron. then run the code again before it works.
It seems to be an issue with a setting in the U-260 modem. Something that the System does not set properly on warm boot.

Where did you place this code?

You might need to read the docs and use things like waitUntil() to confirm that cellular connection is established before connecting to the Particle cloud

Thanks again for the help.

I am using two switches
One to call the Particle.connect() etc…

Another to call Particle.disconnect() etc…
The inputs have external pullups.
Here is the full code…

#include "Particle.h"
#include "cellular_hal.h"


STARTUP(cellular_credentials_set("APN_Here", "", "", NULL));
SYSTEM_MODE(MANUAL);
//SYSTEM_THREAD(ENABLED);
int CoinIn1 = A5;
int CoinIn2 = A4;


bool connectStarted = false;


void setup() {
	Serial1.begin(9600);
   pinMode(CoinIn1, INPUT);
   pinMode(CoinIn2, INPUT);

    Cellular.off();  //doesn't seem to do anything
}

void loop() {
    
   
	if (digitalRead(CoinIn1) == LOW && !connectStarted) {
		connectStarted = true;
		Serial1.println("Calling Cellular On");
		Cellular.on();
    	delay(8000);
    	Serial1.println("Calling Cellular Connect");
    	Cellular.connect();
    	delay(8000);
    	Serial1.println("Calling Particle Connect");
    	Particle.connect();
    	Particle.process();
	}

	if (Particle.connected()) {
		Particle.process();
	}
	
		if (digitalRead(CoinIn2) == LOW && connectStarted) {
		connectStarted = false;
		Serial1.println("Calling Particle.disconnect");
		Particle.disconnect();
		delay(2000);
		Particle.process();
		delay(5000);
			Serial1.println("Calling Cellular.disconnect");
	Cellular.disconnect();
	}

	if (Particle.disconnected()) {
	//	Particle.process();
	}
	
	
}

Can you try something like this:

#include "Particle.h"
#include "cellular_hal.h"


STARTUP(cellular_credentials_set("APN_Here", "", "", NULL));
SYSTEM_MODE(MANUAL);
//SYSTEM_THREAD(ENABLED);
int CoinIn1 = A5;
int CoinIn2 = A4;


bool connectStarted = false;


void setup() {
	Serial1.begin(9600);
   pinMode(CoinIn1, INPUT);
   pinMode(CoinIn2, INPUT);

    Cellular.off();  //doesn't seem to do anything
}

void loop() {
    
   
	if (digitalRead(CoinIn1) == LOW && !connectStarted) {
		connectStarted = true;
		Serial1.println("Calling Cellular On");
		Cellular.on();
    		Serial1.println("Calling Cellular Connect");
		
		 Cellular.connect();
		if (waitFor(Cellular.ready, 10000)) {
  			Serial1.println("Celllular connected!");
			Serial1.println("Calling Particle Connect");
  			Particle.connect();
		}
		else
			Serial1.println("Cellular connect failed");
  	}

	if (Particle.connected()) {
		Particle.process();
	}
	
		if (digitalRead(CoinIn2) == LOW && connectStarted) {
		connectStarted = false;
		Serial1.println("Calling Particle.disconnect");
		Particle.disconnect();
		delay(2000);
		Particle.process();
		delay(5000);
			Serial1.println("Calling Cellular.disconnect");
	Cellular.disconnect();
	}

	if (Particle.disconnected()) {
	//	Particle.process();
	}
	
	
}
1 Like