Did this every resolve itself? Sometimes these non-connecting issues can be related to your SIM card going over the data usage limit and getting paused. You can check your data usage in the Console under Billing. If that looks ok I would contact support.particle.io and see if something recently changed with your local network provider for Particle SIMs.
When you switch back and fourth between APPs that use Particle SIMs and 3rd Party SIMs, are you power cycling your Electron? If you do not, the modem typically stays powered and retains the settings from the previous connection with previous SIM card. A power cycle or special AT commands are required to drop the current network settings.
Your logs seem to indicate all SEND operations and no RECEIVED operations before sleeping. This indicates there is no ACK on the Publish for one, but might also indicate you are putting the device to sleep well before the Electron has even finished handshaking with the Cloud, let alone started the Publish. Try using Publish with the WITH_ACK flag to make the operation fully synchronous:
causes Particle.publish() to return only after receiving an acknowledgement that the published event has been received by the Cloud
For me, the never ending green blinking was happening because my modem was not able to connect to the network. I was using 3rd party SIM. It is my experience that electron sometimes ends up confused what network mode it should select, 2G, 3G. This happens if I frequently switch between particle SIM and 3rd party SIMs. Which network band your modem selects to connect depends on how it is configured. There are few different configurations for it
Dual mode with 2G preferred
Dual mode with 3G preferred
Now your electron could end up in any of these configs. and if your SIMs network and your modem configs do not match you can end up in never ending green blinking state. So to absolutely make sure that the SIM and network you are using do match with your modem configuration, you need to set it explicitly to be very sure. There is a very nice utility firmware available at the following link that you can run on your electron to configure your modem settings.
Try running this utility and set your modem configuration to match your SIM network. For 3G electrons the best setting is ‘dual mode with 3G preferred’ but for testing purpose try setting it to ‘3G only’ mode so that it does not fallback to 2G in case the 3G coverage in your area is not 100%. Play around with it, use different settings and I am sure you will find the right one that works for you.
Unless specified otherwise, events sent to the cloud are sent as a reliable message. The Electron waits for acknowledgement from the cloud that the event has been received, resending the event in the background up to 3 times before giving up.
What is the different between this quote (no flag) and WITH_ACK flag? What will happen if I use the WITH_ACK flag and the acknowledge is never received? Will the application delay forever or is there a timeout? I could handle this with the watchdog.
Like you see in my code, I have a delay(10000) after the publishes. It seems that this is too short for receive the default ack (sent without the WITH_ACK flag, see docs) or does the delay block cloud communications?
@noumanh I only have the 2G version of the Electron. So the ublox modem only can GSM/GPRS.
As ScruffR pointed out already, a reset does not power cycle the modem. This was an intentional part of the design of the Electron, such that operations like flashing firmware OTA or DFU, short sleeping and waking, do not cause the modem to power cycle and go through a long connection process with the cell tower.
If you are manually switching SIMs, the easiest thing to do is just remove power (battery and USB) and then plug them back in after your new SIM card is inserted and new code is on the device. Sometimes this is a three step process, you might OTA new firmware first, remove power, switch SIMs and apply power again.
It’s a good idea to perform the steps above when switching SIMs. Changing the Band Select is an advanced feature and not recommended if you are switching cards or your device is moving to different locations. It’s best to keep the Electron in the most automatic mode possible to ensure it’s radio access technology (RAT) aligns with what is currently available.
Not using a flag only makes the Publish block until the message is sent to the Cloud, it does not ensure the ACK is received. Electrons are also supposed to wait for all confirmable messages to be ACK’d before sleeping, and I don’t see that happening with your logs even though you say that’s with firmware 0.6.1 right? I’m currently looking into if the device needs to receive the ACK before the message is posted to the event stream.
If you use WITH_ACK and the ACK is never received, it will timeout after 30 seconds. The function call would return false.
You mean 1000. Possibly yes, but I’m not certain by looking at your logs that your Published message is represented there either. Try WITH_ACK and please post your logs and results. Thanks!
@Niklas I think even if you have 2G only device it’s worth making sure that the modem is configured correctly. Also, keep in mind that telcos are gradually phasing out 2G so make sure thats not the case in your area.
Though I would like to clarify a few parts from @rickkas7 or a Particle Engineer as @ScruffR mentioned.
This repository was last update a couple years ago and want to confirm that this is the most appropriate method to fully reset the device since System.reset() doesn’t reset the cellular modem.
Also, according to the SARA-UBLOX-R4 datasheet, AT+CFUN=16 will not work and instead should use AT+CFUN=15. This also states that this will reset the SIM card on the unit. Will this cause any issues with the 4G boards? Should we not reset the SIM card and go a different route?
I would not use the AT+CFUN=16 technique in electronsample. Device OS itself will power cycle the modem after 5 minutes of failing to connect. And it knows how to do it on all device models, and can also toggle the GPIO that powers it down.
However, Device OS will not reset the device itself, and that could fix some failures. What I would do is after failing to connect for more 7 minutes or so, reset. On Gen 2, go into SLEEP_MODE_DEEP for 10-30 seconds. On Gen 3, you can’t do that, so just System.reset().
Thank you for sharing the circuit to power cycle the entire device as this may come in handy for us!
Can you elaborate on why you do not recommend on using the AT+CFUN=16 technique?
In your first reply, you state
“can also toggle the GPIO that powers it down”
Are you referring to the enable pin that will power down the modem or the device itself, or both?
In manual mode with system threading enabled, will waiting ~5 minutes for the device to power cycle the modem still be used since its up to the user to handle the connectivity of the device?
You mentioned Gen 2 and Gen 3 devices. We know that Argon, Boron, and Xenon are Gen 3 while Electron, Photon are Gen 2. Is there anywhere in the documentation that states whether a device is Gen 3 or Gen 2 as I can’t find it anywhere? I am specifically asking for E-Series, both 3G and 4G units?
There does not appear to be any advantage of using AT+CFUN=16, and because the command varies between modules, it’s not worth the effort of using it, in my opinion.
The modem can be hardware reset using an internal, undocumented, GPIO. Device OS itself knows how to use it, which varies depending on the device and the amount of time the pin needs to be held in various states varies depending on the modem, which is why I recommend letting Device OS reset the modem, because it’s hard to do properly across all devices.
Yes, the modem will still reset automatically in manual mode.
Gen 2 devices include the Photon, P1, Electron, and E Series. They all have STM32F205 processors.
Gen 3 devices include the Argon, Boron, Xenon, and B Series SoM. They all have nRF52840 processors.
Both generations include a variety of cellular modems including 2G, 3G, and LTE Cat M1. The only exception is that only the Electron has 2G-only (G350), 3G Americas (U260), and 3G Europe/Asia/Africa (U270). The E Series and Gen 3 devices use a world-wide 2G/3G model (U201) instead.