I have the following code, designed to let my Electron try 3 tries in total to connect to the Cloud. The first time the Electron comes online, it can manage to connect just fine. However, after it has gone to sleep mode and wakes up again, it will blink green and occassionally breathe white for a second or two. I'm not really sure why this is; it's running in Semi_Automatic Mode and am not calling any other modem commands previously in my code.
case ANCHOR: {
Serial.println("enabling modem");
Cellular.on();
delay(10000);
anchorTime = millis();
connectWaitTime = millis();
state = CONNECT;
break;
}
case CONNECT: {
if (millis() - lastConnectSample >= 8000) {
lastConnectSample = millis();
Cellular.on();
Particle.connect();
}
if (Particle.connected()) {
Serial.println("connection established!");
stateTime = millis();
state = PUBLISH;
break;
}
if (millis() - connectWaitTime >= 10000) {
connectWaitTime = millis();
Serial.println("connecting...");
}
if (millis() - anchorTime >= 60000) {
connectCount = connectCount + 1;
Serial.println("failed to connect - re-attempting in 5m...");
Serial.println("turning off cellular modem...");
Serial.print("connectCount=");
Serial.println(connectCount);
Cellular.off();
delay(5000);
System.sleep(D0, RISING, 5); // set to 5 seconds for now...
delay(50);
state = ANCHOR;
break;
}
if (connectCount >= 3) {
Serial.println("connection attempt limit reached!");
state = CONFIG;
break;
}
}
break;
@Scruff and I were just talking about this in another thread where a guy was seeing the white breathing LED during connection due to low voltage. He supplied a higher voltage and that fixed his problem which I have also noticed.
Low voltage will cause the modem to not connect quickly or at all. I suspect your batteries are not up to the task of these constant higher current spikes and this is eventually causing your units to slowly or never connect. An easy way to test is the use a scope on the bat pins on the Electron to see what the voltage is dropping down to during connection.
Publishing the RSSI readings also so make sure it’s not a weak signal issue.
I will attempt tomorrow with the 3.7V LiPo, see if the same issue persists. For clarification, I do see the blinking green light most of the time, but sometimes for 1-2 seconds a white led shows…Interestingly it’s only present when anchorTime >= 60000 and it comes out of its 5-seconds sleep (when it makes its second connection attempt). On the first connection attempt it is able to connect even after 50 seconds of trying
The battery voltage drop makes sense, but doesn’t explain yet why it would only occur at the 2nd and 3rd connection attempt, and not the 1st one?
This is at my own desk by the way where the reception is very good
It makes perfect sense to me. The more you use the battery the lower the voltage drops so the 2nd and 3rd attempts are just putting more discharge pulses on it which can cause the white led and a lack of successful connections.
If you can graph the voltage at a high resolution during these processes you would have a really good idea of what is actually going on. Right now we can only guess, the batteries may be fine but they also may just not be able to handle the discharge current the Photon is wanting.
Depending on the quality of the cells the batteries may or may not behave consistently although they should if they were manufactured in a professional way.
Stupid me; I actually just realized I wasn’t even using the batteries for these tests, but the USB port. For sure the USB port is going to act up delivering that much amp…
Still though, 1st attempts always work, 2/3rd attempts never seem to work. Would this actually be explainable with the same logic? There shouldn’t be a voltage drop with the USB port right? I still feel there must be something to the code as it doesn’t matter whether I set the connection times to 30, 60 or 90 seconds, the 2nd and 3rd one always are failing on me. I will do more tests tomorrow
A 1A USB port should be sufficient to run the Electron 3G but add the battery to just be sure there is enough power for connection because not all 1A USB ports are created equal.
Sometimes it just takes a few mins or 5 mins to connect to the particle cloud from my experience. Especially if you’re not using Sleep Network Standby where the modem is staying connected and ready to reconnect. 90 seconds may not be long enough, try waiting longer and see if it improves.
I read somewhere a typical USB port on the PC delivers 500mA though?
5mins. is a long time…I’m considering getting a better antenna now as I find the Taoglas Particle antenna isn’t that great for the more remote areas
Thanks for the help, I will test it some more tomorrow and see what the exact problem is.
The older ports were .5 amp standard but most of the modern USB ports are 1 amp usually. Just depends on what you’re plugging into.
Send the RSSI data back from each unit and see if it’s a signal issue before buying antennas you may not need. Haven’t heard many complaints about the stock antennas.
The current rating is not the only thing that counts. A standard USB port's impedance is not allowing the current demand to be satisfied in time. Dynamic processes play a role her and hence the issue with subsequent wakes may well be due to the fact that waking from Stop Sleep produces the current demand much quicker than from cold start.
I doubt that. Manufacturers tend to only do what they must and for USB 2.0 500mA is that limit and for USB 3.0 it's 600mA. So I'd not rely in the generosity of HW manufacturers or guess the inner wiring of devices to bet on "shared" port power
Tested with a 2A LiPo and the same thing happens; it blinks green, then (I guess when it picked up the signal?) it shows a weak-blue led for 1 second, then a strong-white led for about 2 seconds, and then continues blinking green.
Like I said data reception is very good here, I’ve never needed to connect for more than about 10 seconds to establish the connection. I even plugged in a stronger antenna, but same issue. Reduced connection-time from 60 to only 30 seconds to account for possible voltage drop, but no effect here either.
I really do think I’m doing something wrong in my code so it doesn’t follow the correct steps when it finds the signal?
Keeping Sim out completely: breathes white
Taking Sim out during 1st connection attempt: blinks green
Taking Sim out and put back in after 1st connection attempt: blinks green, still unable to connect
Looks like whether sim was or wasn’t in the Electron at boot-up determines if I get blinking green or breathing white. But regardless of my actions the 2nd/3rd attempts still fail
Looked back at it, I do think the 60-second timer for connections I had before may have been too little. I’m also noticing it’s mostly happening on a select few sensors, not all of them, so the reception for those must be bad because of metal lids, nearby buildings or whatever.
Testing the connection here at my desk with the new firmware still results in the same issue; the 1st connection attempt usually takes 5-10 seconds to establish a connection, and I can let the 2nd one run for 2-3 minutes and it will still keep blinking green
I've seen this myself in the past. Sometimes it connects quickly and other times it takes much longer. Frustrating but it just seems to be the way it goes for reasons unknown to me. Sleep Network Standby helps but not always.
Push an update to them to get the RSSI data sent to you so you know what the signal strength is.
What could the faint-blue + white-led mean though? I see it pop up only during the 2nd attempt, and it typically occurs at a point where I'd expect it to connect (about 10-20 seconds in). It's connected by USB and a 2A LiPo. Changed my code slightly so it makes more sense:
case ANCHOR: {
connectCount = connectCount + 1;
Serial.print("This is attempt: ");
Serial.println(connectCount);
Serial.println("enabling modem");
Cellular.on();
delay(10000);
Serial.println("attempting to establish connection");
anchorTime = millis();
state = CONNECT;
break;
}
case CONNECT: {
if (millis() - lastConnectSample >= 8000) {
lastConnectSample = millis();
Serial.println("connecting...");
Particle.connect();
}
if (Particle.connected()) {
Serial.println("connection established!");
stateTime = millis();
state = PUBLISH;
break;
}
if (millis() - anchorTime >= 60000) {
if (connectCount < 3) {
Serial.println("failed to connect - re-attempting in 5m...");
Serial.println("turning off cellular modem...");
Cellular.off();
delay(5000);
System.sleep(D0, RISING, 5);
delay(50);
state = ANCHOR;
break;
}
else {
Serial.println("connection attempt limit reached!");
state = CONFIG;
break;
}
}
stateTime = millis();
}
break;
To me it seems like it might did establish a connection but is confused by something?
Even in Network_Standby, while not calling Cellular.off, it's the same issue still. I noticed in the 2nd attempt every 10-15 seconds or so it will go blue-white for a few seconds...presumably this is when it finds the connection, doesn't know what to do with it, and just re-attempts it again when Particle.connect() is called
case ANCHOR: {
connectCount = connectCount + 1;
Serial.print("This is attempt: ");
Serial.println(connectCount);
Serial.println("enabling modem");
Cellular.on();
delay(10000);
Serial.println("attempting to establish connection");
anchorTime = millis();
state = CONNECT;
break;
}
case CONNECT: {
if (millis() - lastConnectSample >= 8000) {
lastConnectSample = millis();
Serial.println("connecting...");
Particle.connect();
}
if (Particle.connected()) {
Serial.println("connection established!");
stateTime = millis();
state = PUBLISH;
break;
}
if (millis() - anchorTime >= 90000) {
if (connectCount < 3) {
Serial.println("failed to connect - re-attempting in 5m...");
delay(500);
System.sleep(D0, RISING, 300, SLEEP_NETWORK_STANDBY);
delay(50);
state = ANCHOR;
break;
}
else {
Serial.println("connection attempt limit reached!");
state = CONFIG;
break;
}
}
stateTime = millis();
}
break;
Would be great to have some insight on my code...am I doing anything wrong? I know it's not really sleep related, as before Anchor_State theres another state that already puts in sleep mode...it comes out of that and connects just fine on the first attempt
@rickkas7 Would you be able to assist a bit? Thanks a lot in advance
I would keep your original code and drive around the city keep trying the to connect in different parts of the city and see if makes any difference.
My guess is that it will connect successfully in different areas of town and it will connect as normal as time passes at your current location. Doesn’t make sense but it seems to work that way for me when I was testing.