Electron breathing "blue" and other 3rd party SIM issues

Hi all,

I’ve been unsuccessfully trying to send SMS with a third party SIM card recently, following different threads of the forum. Now I’m trying this one (albeit a bit modified as I don’t have a light sensor handy).

Now I’m struggling with the connection to the network. My Electron will breathe white, then blink green. Sometimes, it will just keep blinking green, and after a few minutes, reset back to breathing white and start back the connection attempt. I think that there is an internal timer, some kind of watchdog, that resets the whole thing if the connection is not established after a while, am I right?

Some other times though, the Electron will blink cyan (with some red blinking sequences here and there). I read here that this could mean that the device indeed did successfully connect to my carrier’s network, yet without being able to connect to the Particle Cloud.

Anyways, from there I encountered two scenarios:

  1. Breathing Cyan (only once). Hourray! :smiley: But the problem was that my code wasn’t running actually, no LED blinking or SMS being sent. :cold_sweat:
  2. Back to the beginning and to the white breathing and so on.
  3. Once the Electron was breathing blue and then started everything again.

I verified the code with Build, then compiled and downloaded it.
I flashed it with particle flash --usb firmware.bin after putting the Electron in DFU mode.

So I guess that as there might be many different issues here, my question would be: as the Electron won’t run my code unless it’s connected to the Particle Cloud, is there a way to prevent it from doing so? It would help me test the code quickier…

Here is the code just in case it itself would be the cause of this erratic behavior.

#define MAX_PHONE_NUMBER    14
#define CTRL_Z 0x1A
#define TIMEOUT 10000

#include "cellular_hal.h"
STARTUP(cellular_credentials_set("sl2sfr", "", "", NULL));
// Credential here are for RED by SFR network, here in France

char szPhoneNumber[MAX_PHONE_NUMBER] = "+???????????";

bool smsSend = false;

const int Sec = 1000;
const int Min = 60*Sec;
unsigned long Millis_Previous = 0;
unsigned long Millis_Interval = 1*Sec;
unsigned long Millis_Actual;
// bool de_lay;

const int LED = D0;
bool LED_State = 0;
const int LED_SMS = D2;
bool LED_SMS_State = 0;

int Timer_Value = 0;

char szMessage[64];

void setup() {

	Serial.begin(9600);
	
	// Spark.function("setmin", setLowerLimit);		// unused particle function from the original code
}

void loop() {
	LED_OnOff();

	Timer();
	
	sendMessage(szMessage);

	delay(1000);
}

void LED_OnOff(){
	Millis_Actual = millis();
	if(Millis_Actual - Millis_Previous >= (Millis_Interval/2)){
		Millis_Previous = Millis_Actual;
		if(LED_State = false){
			LED_State = true;		
		} else {
			LED_State = false;
		}
		digitalWrite(LED, LED_State);
	}
}

void Timer(){
	Millis_Actual = millis();
	if(Millis_Actual - Millis_Previous >= ((2*Min))){
		Timer_Value = millis();
		Millis_Previous = Millis_Actual;
		sprintf(szMessage, "Timer value = (%.4i Timer_Value)", Timer_Value);
		smsSend = true;
	}
}

int callback(int type, const char* buf, int len, char* param){  
	Serial.print("Return: ");
	Serial.write((const uint8_t*)buf, len);
	Serial.println();
	
	return WAIT;
}

int sendMessage(char* pMessage){
	if(!smsSend) return EXIT_SUCCESS;

	char szCmd[64];
	
	sprintf(szCmd, "AT+CMGS=\"+%s\",145\r\n", szPhoneNumber);
	
	Serial.print("Sending command ");
	Serial.print(szCmd);
	Serial.println();
	
	char szReturn[32] = "";
	
	Cellular.command(callback, szReturn, TIMEOUT, "AT+CMGF=1\r\n");
	Cellular.command(callback, szReturn, TIMEOUT, szCmd);
	Cellular.command(callback, szReturn, TIMEOUT, pMessage);
	
	sprintf(szCmd, "%c", CTRL_Z);
	
	int retVal = Cellular.command(callback, szReturn, TIMEOUT, szCmd);
	
	if(RESP_OK == retVal){
		Serial.println("+OK, Message Sent");
	}
	else{
		Serial.println("+ERROR, error sending message");
	}
	
	return retVal;

	smsSend = false;
}

Using SYSTEM_THREAD(ENABLED) will decouple the system tasks from your own code, just be aware that you can’t rely on any connection (cellular or cloud) being available without checking.
You may also use SYSTEM_MODE(SEMI_AUTOMATIC).

Another thing to consider with a 3rd party SIM is the Particle.keepAlive() setting you’ll have to adjust in setup() or STARTUP() according to your providers needs.

Thanks ScruffR!

Ok, I skipped this part :frowning:
Thanks again.

btw: any idea of that breathing blue led meaning? It was definitely breathing, and definitely not cyan…

This is breathing blue
https://docs.particle.io/guide/getting-started/connect

For the Photon it means that
https://docs.particle.io/guide/getting-started/connect

Here’s a link for “Breathing Blue”: https://docs.particle.io/guide/getting-started/modes/electron/#cellular-module-not-connected

1 Like

I am using SYSTEM_MODE(SEMI_AUTOMATIC)
At startup, I am connecting to celullar (Cellular.on()) but not to the cloud. The electron is breathing blue.
When I connect to the cloud (Particle.connect())., the electron is breathing cyan.
However if I disconnect from the cloud, the electron is now breathing green.
I beleive there might be a mistake here. I don’t really mind, but it could be corrected for better clarity.

Cellular.on() only switches the module on, but does not connect to the cellular network.
For that you’d use Cellular.connect()

  • Breathing white: Cellular module off and hence not connected at all
  • Breathing blue: Cellular module on but not connected to any network (after Cellular.on())
  • Breathing green: Cellular module connected to the cellular network but not to the Particle cloud (after Cellular.connect()when reaching Cellular.ready() == true)
  • Breathing cyan: connected to the Particle cloud (after Particle.connect() after reaching Particle.connected() == true)

And if you Particle.disconnect() you are only going back from the last state to the last but one.[quote=“Fabien, post:6, topic:28719”]
I beleive there might be a mistake here. I don’t really mind, but it could be corrected for better clarity.
[/quote]

Yea, but only in your understanding of the situation and not on the Particle side :wink: