# Electron suddenly stopped connecting

**URL:** <https://community.particle.io/t/electron-suddenly-stopped-connecting/28265>\
**Category:** Hardware\
**Created:** [January 1, 2017, 11:31pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265 "2017-01-01T23:31:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![noumanh](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/noumanh/32/11443_2.png) [@noumanh](https://community.particle.io/u/noumanh)\
**Post date:** [January 1, 2017, 11:31pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/1 "2017-01-01T23:31:04Z")

</div>

Hi,

I am using a 3rd party SIM with my electron and it was working perfectly until today. I came back from a holiday after a week and turned the device on. The firmware I had in it, published some data after every 5 minutes and went to sleep. I noticed that with every publish the battery charge was going up. It went from 30% all the way up to 74%, although I hadn’t connected the device with a power source. So after an hours operation the device tried to come out of sleep from the last 5 minute interval and it got stuck on blinking green. I flashed the device with tinker-usb-debugging firmware and noticed that the device is endlessly cycling between Modem Off -\> Modem ON -\> Modem Init -\> Modem Registration. It reported +CGREG: 2,2 which means it is trying to find an operator to register with. Here is the logs generated by tinker

```
    0000318938 src/dtls_protocol.cpp:47, virtual void particle::protocol::DTLSProtocol::init(const char*, const SparkKeys&, const SparkCallbacks&, const SparkDesc~: channel inited0000318938 src/system_task.cpp:101, void manage_network_connection(): WARN: Resetting WLAN due to WLAN_WD_TO()

[Modem::powerOff] = = = = = = = = = = = = = =
   318.899 AT send 12 "AT+CPWROFF\r\n"
   318.969 AT read OK 6 "\r\nOK\r\n"
0000319009 src/system_task.cpp:117, void manage_network_connection(): INFO: Network Connect: !SPARK_WLAN_STARTED
0000319009 src/system_network_internal.h:289, virtual void ManagedNetworkInterface::connect(bool): INFO: ready(): 0; connecting(): 0; listening(): 0; WLAN_SMART_CONFIG_START: 0

[Modem::powerOn] = = = = = = = = = = = = = =
   319.280 AT send 4 "AT\r\n"
   320.600 AT send 4 "AT\r\n"
   321.920 AT send 4 "AT\r\n"
   323.240 AT send 4 "AT\r\n"
   323.250 AT read UNK 3 "AT\r"
   323.260 AT read OK 6 "\r\nOK\r\n"
   323.260 AT send 7 "AT E0\r\n"
   323.270 AT read UNK 6 "AT E0\r"
   323.280 AT read OK 6 "\r\nOK\r\n"
   323.280 AT send 11 "AT+CMEE=2\r\n"
   323.290 AT read OK 6 "\r\nOK\r\n"
   323.290 AT send 19 "AT+CMER=1,0,0,2,1\r\n"
   323.300 AT read OK 6 "\r\nOK\r\n"
   323.300 AT send 15 "AT+IPR=115200\r\n"
   323.310 AT read OK 6 "\r\nOK\r\n"
   323.410 AT send 10 "AT+CPIN?\r\n"
   323.420 AT read ERR 24 "\r\n+CME ERROR: SIM busy\r\n"
   324.420 AT send 10 "AT+CPIN?\r\n"
   324.430 AT read + 16 "\r\n+CPIN: READY\r\n"
   324.440 AT read OK 6 "\r\nOK\r\n"
0000324480 src/system_network_internal.h:318, virtual void ManagedNetworkInterface::connect(bool): INFO: ARM_WLAN_WD 1

[Modem::init] = = = = = = = = = = = = = = =
   324.441 AT send 9 "AT+CGSN\r\n"
   324.461 AT read UNK 19 "\r\n352253061012984\r\n"
   324.471 AT read OK 6 "\r\nOK\r\n"
   324.471 AT send 9 "AT+CGMI\r\n"
   324.481 AT read UNK 10 "\r\nu-blox\r\n"
   324.491 AT read OK 6 "\r\nOK\r\n"
   324.491 AT send 9 "AT+CGMM\r\n"
   324.501 AT read UNK 13 "\r\nSARA-U270\r\n"
   324.511 AT read OK 6 "\r\nOK\r\n"
   324.511 AT send 9 "AT+CGMR\r\n"
   324.521 AT read UNK 9 "\r\n23.20\r\n"
   324.531 AT read OK 6 "\r\nOK\r\n"
   324.531 AT send 9 "AT+CCID\r\n"
   324.541 AT read + 31 "\r\n+CCID: 89410062304402239178\r\n"
   324.551 AT read OK 6 "\r\nOK\r\n"
   324.551 AT send 11 "AT+UPSV=1\r\n"
   324.561 AT read OK 6 "\r\nOK\r\n"
   324.561 AT send 11 "AT+CMGF=1\r\n"
   324.571 AT read OK 6 "\r\nOK\r\n"
   324.571 AT send 13 "AT+CNMI=2,1\r\n"
   324.581 AT read OK 6 "\r\nOK\r\n"
   324.581 AT send 9 "AT+CIMI\r\n"
   324.591 AT read UNK 19 "\r\n410060440223917\r\n"
   324.601 AT read OK 6 "\r\nOK\r\n"

[Modem::register] = = = = = = = = = = = = = =
   324.601 AT send 10 "AT+CREG?\r\n"
   324.612 AT read + 14 "\r\n+CREG: 0,0\r\n"
   324.622 AT read OK 6 "\r\nOK\r\n"
   324.622 AT send 11 "AT+CGREG?\r\n"
   324.632 AT read + 15 "\r\n+CGREG: 0,0\r\n"
   324.642 AT read OK 6 "\r\nOK\r\n"
   324.642 AT send 12 "AT+CGREG=2\r\n"
   324.652 AT read OK 6 "\r\nOK\r\n"
   324.652 AT send 11 "AT+CREG=2\r\n"
   324.662 AT read OK 6 "\r\nOK\r\n"
   324.662 AT send 10 "AT+CREG?\r\n"
   324.672 AT read + 14 "\r\n+CREG: 2,0\r\n"
   324.682 AT read OK 6 "\r\nOK\r\n"
   324.682 AT send 11 "AT+CGREG?\r\n"
   324.692 AT read + 15 "\r\n+CGREG: 2,0\r\n"
   324.702 AT read OK 6 "\r\nOK\r\n"
   339.702 AT send 10 "AT+CREG?\r\n"
   339.702 AT read + 14 "\r\n+CIEV: 5,1\r\n"
   341.502 AT read + 14 "\r\n+CREG: 2,0\r\n"
   341.512 AT read OK 6 "\r\nOK\r\n"
   341.512 AT send 11 "AT+CGREG?\r\n"
   341.522 AT read + 15 "\r\n+CGREG: 2,0\r\n"
   341.532 AT read OK 6 "\r\nOK\r\n"
   356.532 AT send 10 "AT+CREG?\r\n"
   358.332 AT read + 14 "\r\n+CREG: 2,0\r\n"
   358.342 AT read OK 6 "\r\nOK\r\n"
   358.342 AT send 11 "AT+CGREG?\r\n"
   358.352 AT read + 15 "\r\n+CGREG: 2,0\r\n"
   358.362 AT read OK 6 "\r\nOK\r\n"
   373.362 AT send 10 "AT+CREG?\r\n"
   375.162 AT read + 14 "\r\n+CREG: 2,0\r\n"
   375.172 AT read OK 6 "\r\nOK\r\n"
   375.172 AT send 11 "AT+CGREG?\r\n"
   375.182 AT read + 15 "\r\n+CGREG: 2,0\r\n"
   375.192 AT read OK 6 "\r\nOK\r\n"
   390.192 AT send 10 "AT+CREG?\r\n"
   390.192 AT read + 14 "\r\n+CIEV: 3,0\r\n"
   390.202 AT read + 14 "\r\n+CIEV: 7,0\r\n"
   390.212 AT read + 14 "\r\n+CIEV: 9,0\r\n"
CIEV matched: 9,0
   391.842 AT read + 14 "\r\n+CREG: 2,0\r\n"
   391.852 AT read OK 6 "\r\nOK\r\n"
   391.852 AT send 11 "AT+CGREG?\r\n"
   391.862 AT read + 15 "\r\n+CGREG: 2,0\r\n"
   391.872 AT read OK 6 "\r\nOK\r\n"
   406.872 AT send 10 "AT+CREG?\r\n"
   406.872 AT read + 12 "\r\n+CREG: 2\r\n"
   406.882 AT read + 13 "\r\n+CGREG: 2\r\n"
   408.672 AT read + 14 "\r\n+CREG: 2,2\r\n"
   408.682 AT read OK 6 "\r\nOK\r\n"
   408.682 AT send 11 "AT+CGREG?\r\n"
   408.692 AT read + 15 "\r\n+CGREG: 2,2\r\n"
   408.702 AT read OK 6 "\r\nOK\r\n"
   423.702 AT send 10 "AT+CREG?\r\n"
   425.502 AT read + 14 "\r\n+CREG: 2,2\r\n"
   425.512 AT read OK 6 "\r\nOK\r\n"
   425.512 AT send 11 "AT+CGREG?\r\n"
   425.522 AT read + 15 "\r\n+CGREG: 2,2\r\n"
   425.532 AT read OK 6 "\r\nOK\r\n"
   440.532 AT send 10 "AT+CREG?\r\n"
   440.552 AT read + 12 "\r\n+CREG: 0\r\n"
   440.562 AT read + 13 "\r\n+CGREG: 0\r\n"
   440.572 AT read + 14 "\r\n+CREG: 2,0\r\n"
   440.582 AT read OK 6 "\r\nOK\r\n"
   440.582 AT send 11 "AT+CGREG?\r\n"
   443.102 AT read + 15 "\r\n+CGREG: 2,0\r\n"
   443.112 AT read OK 6 "\r\nOK\r\n"
   458.112 AT send 10 "AT+CREG?\r\n"
   458.112 AT read + 12 "\r\n+CREG: 2\r\n"
   458.122 AT read + 13 "\r\n+CGREG: 2\r\n"
   459.912 AT read + 14 "\r\n+CREG: 2,2\r\n"
   459.922 AT read OK 6 "\r\nOK\r\n"
   459.922 AT send 11 "AT+CGREG?\r\n"
   459.932 AT read + 15 "\r\n+CGREG: 2,2\r\n"
   459.942 AT read OK 6 "\r\nOK\r\n"
   474.942 AT send 10 "AT+CREG?\r\n"
   476.742 AT read + 14 "\r\n+CREG: 2,2\r\n"
   476.752 AT read OK 6 "\r\nOK\r\n"
   476.752 AT send 11 "AT+CGREG?\r\n"
   476.762 AT read + 15 "\r\n+CGREG: 2,2\r\n"
   476.772 AT read OK 6 "\r\nOK\r\n"
   491.772 AT send 10 "AT+CREG?\r\n"
   493.572 AT read + 14 "\r\n+CREG: 2,2\r\n"
   493.582 AT read OK 6 "\r\nOK\r\n"
   493.582 AT send 11 "AT+CGREG?\r\n"
   493.592 AT read + 15 "\r\n+CGREG: 2,2\r\n"
   493.602 AT read OK 6 "\r\nOK\r\n"
   508.602 AT send 10 "AT+CREG?\r\n"
   508.602 AT read + 12 "\r\n+CREG: 0\r\n"
   508.612 AT read + 13 "\r\n+CGREG: 0\r\n"
   510.702 AT read + 14 "\r\n+CREG: 2,0\r\n"
   510.712 AT read OK 6 "\r\nOK\r\n"
   510.712 AT send 11 "AT+CGREG?\r\n"
   510.712 AT read + 12 "\r\n+CREG: 2\r\n"
   510.723 AT read + 13 "\r\n+CGREG: 2\r\n"
   510.733 AT read + 15 "\r\n+CGREG: 2,2\r\n"
   510.743 AT read OK 6 "\r\nOK\r\n"
   525.743 AT send 10 "AT+CREG?\r\n"
   525.743 AT read + 12 "\r\n+CREG: 0\r\n"
   525.753 AT read + 13 "\r\n+CGREG: 0\r\n"
   525.763 AT read + 12 "\r\n+CREG: 2\r\n"
   525.773 AT read + 13 "\r\n+CGREG: 2\r\n"
   527.533 AT read + 14 "\r\n+CREG: 2,2\r\n"
   527.543 AT read OK 6 "\r\nOK\r\n"
   527.543 AT send 11 "AT+CGREG?\r\n"
   527.553 AT read + 15 "\r\n+CGREG: 2,2\r\n"
   527.563 AT read OK 6 "\r\nOK\r\n"
   542.563 AT send 10 "AT+CREG?\r\n"
   544.363 AT read + 14 "\r\n+CREG: 2,2\r\n"
   544.373 AT read OK 6 "\r\nOK\r\n"
   544.373 AT send 11 "AT+CGREG?\r\n"
   544.383 AT read + 15 "\r\n+CGREG: 2,2\r\n"
   544.393 AT read OK 6 "\r\nOK\r\n"
   559.393 AT send 10 "AT+CREG?\r\n"
   561.193 AT read + 14 "\r\n+CREG: 2,2\r\n"
   561.203 AT read OK 6 "\r\nOK\r\n"
   561.203 AT send 11 "AT+CGREG?\r\n"
   561.213 AT read + 15 "\r\n+CGREG: 2,2\r\n"
   561.223 AT read OK 6 "\r\nOK\r\n"
   576.223 AT send 10 "AT+CREG?\r\n"
   576.223 AT read + 12 "\r\n+CREG: 0\r\n"
   576.233 AT read + 13 "\r\n+CGREG: 0\r\n"
   576.243 AT read + 12 "\r\n+CREG: 2\r\n"
   576.253 AT read + 13 "\r\n+CGREG: 2\r\n"
   576.263 AT read + 12 "\r\n+CREG: 0\r\n"
   576.273 AT read + 13 "\r\n+CGREG: 0\r\n"
   576.443 AT read + 14 "\r\n+CREG: 2,0\r\n"
   576.453 AT read OK 6 "\r\nOK\r\n"
   576.453 AT send 11 "AT+CGREG?\r\n"
   576.463 AT read + 15 "\r\n+CGREG: 2,0\r\n"
   576.473 AT read OK 6 "\r\nOK\r\n"
   591.473 AT send 10 "AT+CREG?\r\n"
   591.473 AT read + 12 "\r\n+CREG: 2\r\n"
   591.483 AT read + 13 "\r\n+CGREG: 2\r\n"
   591.493 AT read + 12 "\r\n+CREG: 0\r\n"
   591.503 AT read + 13 "\r\n+CGREG: 0\r\n"
   591.513 AT read + 12 "\r\n+CREG: 2\r\n"
   591.523 AT read + 13 "\r\n+CGREG: 2\r\n"
   593.273 AT read + 14 "\r\n+CREG: 2,2\r\n"
   593.283 AT read OK 6 "\r\nOK\r\n"
   593.283 AT send 11 "AT+CGREG?\r\n"
   593.293 AT read + 15 "\r\n+CGREG: 2,2\r\n"
   593.303 AT read OK 6 "\r\nOK\r\n"
   608.303 AT send 10 "AT+CREG?\r\n"
   610.103 AT read + 14 "\r\n+CREG: 2,2\r\n"
   610.113 AT read OK 6 "\r\nOK\r\n"
   610.113 AT send 11 "AT+CGREG?\r\n"
   610.123 AT read + 15 "\r\n+CGREG: 2,2\r\n"
   610.133 AT read OK 6 "\r\nOK\r\n"
   625.133 AT send 10 "AT+CREG?\r\n"
   626.933 AT read + 14 "\r\n+CREG: 2,2\r\n"
   626.943 AT read OK 6 "\r\nOK\r\n"
   626.943 AT send 11 "AT+CGREG?\r\n"
   626.953 AT read + 15 "\r\n+CGREG: 2,2\r\n"
   626.963 AT read OK 6 "\r\nOK\r\n"
0000627003 src/system_task.cpp:101, void manage_network_connection(): WARN: Resetting WLAN due to WLAN_WD_TO()

[Modem::powerOff] = = = = = = = = = = = = = =
   626.964 AT send 12 "AT+CPWROFF\r\n"
   627.024 AT read OK 6 "\r\nOK\r\n"
0000627064 src/system_task.cpp:117, void manage_network_connection(): INFO: Network Connect: !SPARK_WLAN_STARTED
0000627065 src/system_network_internal.h:289, virtual void ManagedNetworkInterface::connect(bool): INFO: ready(): 0; connecting(): 0; listening(): 0; WLAN_SMART_CONFIG_START: 0

[Modem::powerOn] = = = = = = = = = = = = = =
   627.335 AT send 4 "AT\r\n"
   628.655 AT send 4 "AT\r\n"
   629.975 AT send 4 "AT\r\n"
   631.295 AT send 4 "AT\r\n"
   631.305 AT read UNK 3 "AT\r"
   631.315 AT read OK 6 "\r\nOK\r\n"
   631.315 AT send 7 "AT E0\r\n"
   631.325 AT read UNK 6 "AT E0\r"
   631.335 AT read OK 6 "\r\nOK\r\n"
   631.335 AT send 11 "AT+CMEE=2\r\n"
   631.345 AT read OK 6 "\r\nOK\r\n"
   631.345 AT send 19 "AT+CMER=1,0,0,2,1\r\n"
   631.355 AT read OK 6 "\r\nOK\r\n"
   631.355 AT send 15 "AT+IPR=115200\r\n"
   631.365 AT read OK 6 "\r\nOK\r\n"
   631.465 AT send 10 "AT+CPIN?\r\n"
   631.475 AT read ERR 24 "\r\n+CME ERROR: SIM busy\r\n"
   632.475 AT send 10 "AT+CPIN?\r\n"
   632.485 AT read + 16 "\r\n+CPIN: READY\r\n"
   632.495 AT read OK 6 "\r\nOK\r\n"
0000632535 src/system_network_internal.h:318, virtual void ManagedNetworkInterface::connect(bool): INFO: ARM_WLAN_WD 1

[Modem::init] = = = = = = = = = = = = = = =
   632.495 AT send 9 "AT+CGSN\r\n"
   632.516 AT read UNK 19 "\r\n352253061012984\r\n"
   632.526 AT read OK 6 "\r\nOK\r\n"
   632.526 AT send 9 "AT+CGMI\r\n"
   632.536 AT read UNK 10 "\r\nu-blox\r\n"
   632.546 AT read OK 6 "\r\nOK\r\n"
   632.546 AT send 9 "AT+CGMM\r\n"
   632.556 AT read UNK 13 "\r\nSARA-U270\r\n"
   632.566 AT read OK 6 "\r\nOK\r\n"
   632.566 AT send 9 "AT+CGMR\r\n"
   632.576 AT read UNK 9 "\r\n23.20\r\n"
   632.586 AT read OK 6 "\r\nOK\r\n"
   632.586 AT send 9 "AT+CCID\r\n"
   632.596 AT read + 31 "\r\n+CCID: 89410062304402239178\r\n"
   632.606 AT read OK 6 "\r\nOK\r\n"
   632.606 AT send 11 "AT+UPSV=1\r\n"
   632.616 AT read OK 6 "\r\nOK\r\n"
   632.616 AT send 11 "AT+CMGF=1\r\n"
   632.626 AT read OK 6 "\r\nOK\r\n"
   632.626 AT send 13 "AT+CNMI=2,1\r\n"
   632.636 AT read OK 6 "\r\nOK\r\n"
   632.636 AT send 9 "AT+CIMI\r\n"
   632.646 AT read UNK 19 "\r\n410060440223917\r\n"
   632.656 AT read OK 6 "\r\nOK\r\n"

[Modem::register] = = = = = = = = = = = = = =
   632.656 AT send 10 "AT+CREG?\r\n"
   632.666 AT read + 14 "\r\n+CREG: 0,0\r\n"
   632.676 AT read OK 6 "\r\nOK\r\n"
   632.676 AT send 11 "AT+CGREG?\r\n"
   632.686 AT read + 15 "\r\n+CGREG: 0,0\r\n"
   632.696 AT read OK 6 "\r\nOK\r\n"
   632.696 AT send 12 "AT+CGREG=2\r\n"
   632.706 AT read OK 6 "\r\nOK\r\n"
   632.706 AT send 11 "AT+CREG=2\r\n"

```

The strange thing is that it was working perfectly fine and just stopped working. It does not make any sense. I suspect that it has got something to do with the battery. Battery appears to be working normally but since I noticed its charge percentage rising without any power source just before this issue occured I think this might have something to do with the connection problem. I have the device now connected to usb power and battery both.

Here are details of the device in question

Device: Electron 3G (South-east Asia)  
System Firmware Version: 0.6.0

Thanks

---

<div class="post-metadata">

**Author:** ![RWB](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rwb/32/22599_2.png) [@RWB](https://community.particle.io/u/RWB)\
**Post date:** [January 1, 2017, 11:37pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/2 "2017-01-01T23:37:22Z")

</div>

I’m having similar issues with reconnection after sleeping.

What code do I need to enable the same debut output over serial USB so I can see if were getting stuck for the same reason.

---

<div class="post-metadata">

**Author:** ![noumanh](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/noumanh/32/11443_2.png) [@noumanh](https://community.particle.io/u/noumanh)\
**Post date:** [January 1, 2017, 11:44pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/3 "2017-01-01T23:44:32Z")

</div>

For me its not just reconnection after sleep now. It has completely stopped connecting, no matter which firmware I upload to the device. Even a simple LED blinking firmware does not work now.

To get the debug output you need to flash your device with tinker usb debugging app [Tinker Debug Firmware](https://particle.faqt.co/share/h867h4 "Tinker Debug Firmware")

---

<div class="post-metadata">

**Author:** ![Niklas](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/niklas/32/13482_2.png) [@Niklas](https://community.particle.io/u/Niklas)\
**Post date:** [March 9, 2017, 4:25pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/4 "2017-03-09T16:25:18Z")

</div>

@RWB and @noumanh

Did you find a solution for your problem?  
I think I have the same issue with some 2G Electron:

> [@Electron flashes green with CGREG: 2,0 after CGREG: 2,2](https://community.particle.io/t/electron-flashes-green-with-cgreg-2-0-after-cgreg-2-2/30355):
>
> Hi community, can someone help me with the following issue? Some of my electrons have the struggle that they start flashing green for long time after some days or in some locations. Now I found out that the reason could be that they flash for long time green and then go to sleep forever until I reset them manually. My code structure is: reading sensors’ data publish data to Particle cloud deep sleep for fix time I use Particle SIM cards with a 2G Electron in Germany. During debugging I de…

---

<div class="post-metadata">

**Author:** ![RWB](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rwb/32/22599_2.png) [@RWB](https://community.particle.io/u/RWB)\
**Post date:** [March 9, 2017, 4:47pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/5 "2017-03-09T16:47:40Z")

</div>

@Niklas I did have this happen the other day where it required a manual reset. The code I’m using normally will reset the Electron if it does not connect within 10-11 mins. If the Electron does not connect within 5 mins of trying the Electron firmware resets the modem and then does it again if it does not reconnect again after 5 more mins.

I have an application watchdog kick in if it’s not kicked every 11 mins.

Overall I can let the Electron run for a month straight off solar power and not have any problems but last week I had it get stuck in a state where it looked liked it was connecting and sending data but it wasn’t.

I have not upgraded to the latest 0.6.1 firmware but plan on doing that today since there are lots of fixes in the new firmware which may solve this occasional issue.

---

<div class="post-metadata">

**Author:** ![Niklas](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/niklas/32/13482_2.png) [@Niklas](https://community.particle.io/u/Niklas)\
**Post date:** [March 9, 2017, 4:58pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/6 "2017-03-09T16:58:11Z")

</div>

@RWB  
Yes, I see your code in another topic and use parts of it, for example the watchdog solution.

I just change the SIM card to a third party SIM card and now it seems to work (but it is the same provider). I will let the Electron alone for a few hours and then change back to the Particle SIM. Maybe it works after this.

We should place somewhere in the docs some sample best practice solutions for typical tasks (for example a loop of collection sensor data, publish and deep sleep). These should contains all available error handlings, fall backs, secure code features and so on. I could start with the base of my solution @will

---

<div class="post-metadata">

**Author:** ![RWB](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rwb/32/22599_2.png) [@RWB](https://community.particle.io/u/RWB)\
**Post date:** [March 9, 2017, 5:00pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/7 "2017-03-09T17:00:16Z")

</div>

Post your code.

Also which firmware are you using?

What is the cellular signal strength in your location?

---

<div class="post-metadata">

**Author:** ![Niklas](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/niklas/32/13482_2.png) [@Niklas](https://community.particle.io/u/Niklas)\
**Post date:** [March 9, 2017, 5:08pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/8 "2017-03-09T17:08:28Z")

</div>

```
/* This code is under the license MIT 2017 */ 
SYSTEM_MODE(SEMI_AUTOMATIC);

#include "CellLocate.h"
#include "SparkJson/SparkJson.h"
#include "SHT1x/SHT1x.h"
#include "OneWire/OneWire.h"
#include "math.h"

PRODUCT_ID(3448);
PRODUCT_VERSION(1);

SerialLogHandler logHandler(LOG_LEVEL_ALL); // DEBUG
STARTUP(Cellular.off());
STARTUP(Cellular.setListenTimeout(30));
//STARTUP(cellular_credentials_set("m2mdetrial.telefonica.com", "", "", NULL)); // comment when a Particle SIM is used
ApplicationWatchdog wd(660000, resetMySystem);

OneWire ds = OneWire(D4); // 1-wire signal on pin D4
FuelGauge fuel;
SHT1x sht1x(0, 1); // dataPin, clockPin

const unsigned long timeToSleep = 60 * 15; // 15 minutes
const int size_of_queue = 8; // reserve var * 4 bytes for addresses = 2 hours
const int steps_to_force = size_of_queue * 1; // force sending after 2 hours
const int steps_to_admin = 2; // send admin data every 2 publishes = 4 hours
const unsigned long timeToSleepFail = 10;

int address_counter_force = 10;
int address_tempDS = 20;
int address_tempSH = 70;
int address_humiSH = 120;
int address_soc = 220;
unsigned long awakeTime = 0;

int address_tempDS_max = 270;
int address_tempDS_min = 320;
int address_tempSH_max = 370;
int address_tempSH_min = 420;
int address_humiSH_max = 470;
int address_humiSH_min = 520;
int address_counter_admin = 570;
int address_borders_were_crashed = 620;

float tempDS_array[size_of_queue];
float tempSH_array[size_of_queue];
float humiSH_array[size_of_queue];
float soc_array[size_of_queue];

// default values of borders to avoid RTEs
float ds_temp_max = 0;
float ds_temp_min = 0;
float sh_temp_max = 0;
float sh_temp_min = 0;
float sh_humi_max = 0;
float sh_humi_min = 0;
int current_counter_force = 0;
int current_counter_admin = 0;
bool border_crashed = false;
bool false_predicted = false;
bool borders_were_crashed = false;

char publishDString[60]; // max 64
char publishSString[60];
char publishHString[60];
char publishPString[60];
char pubData[256];
char pubDataLocation[256];

char* latitude = "0";
char* longitude = "0";

void resetMySystem() {
    EEPROM.put(address_counter_force, 0);
    EEPROM.put(address_counter_admin, 0);
    System.reset(); 
}

void setup() {
    Particle.function("borders", saveBorders);
    delay(3000);
    Serial.begin(9600); // DEBUG
}

// Cloud function to save changed borders from SensorDB to EEPROM
int saveBorders(String json) {
    Serial.println(json);
    
    // parse string
    int lastFound = -1; // needed to get first char
    int currentFound = 0;
    int step = 0;
    float borders[6];
    while(currentFound != -1) {
        currentFound = json.indexOf("|", lastFound + 1);
        if(currentFound != -1) {
            borders[step] = json.substring(lastFound + 1, currentFound).toFloat();
            lastFound = currentFound;
            step++;
        }
    }
    
    if(currentFound == -1 && step == 0) return -1; // if no | is found, return error.
    
    ds_temp_max = borders[0];
    ds_temp_min = borders[1];
    sh_temp_max = borders[2];
    sh_temp_min = borders[3];
    sh_humi_max = borders[4];
    sh_humi_min = borders[5];

    EEPROM.put(address_tempDS_max, ds_temp_max);
    EEPROM.put(address_tempDS_min, ds_temp_min);
    EEPROM.put(address_tempSH_max, sh_temp_max);
    EEPROM.put(address_tempSH_min, sh_temp_min);
    EEPROM.put(address_humiSH_max, sh_humi_max);
    EEPROM.put(address_humiSH_min, sh_humi_min);
  
    return 1;
}

void loop(void) {
    byte i;
    byte present = 0;
    byte data[12];
    byte addr[8];
    float tempDS, tempSH, humiSH, batterySOC;

    if (!ds.search(addr)) {
        ds.reset_search();
        delay(250);
        return;
    } 

    if (OneWire::crc8(addr, 7) != addr[7]) {
        return;
    }

    ds.reset(); // first clear the 1-wire bus
    ds.select(addr); // now select the device we just found
    ds.write(0x44, 0); // or start conversion in powered mode (bus finishes low)

    delay(1000); // maybe 750ms is enough, maybe not, wait 1 sec for conversion

    present = ds.reset();
    ds.select(addr);
    ds.write(0xB8,0); // Recall Memory 0
    ds.write(0x00,0); // Recall Memory 0

    present = ds.reset();
    ds.select(addr);
    ds.write(0xBE,0); // Read Scratchpad

    for (i = 0; i < 9; i++) { // we need 9 bytes
        data[i] = ds.read();
    }
    int16_t raw = (data[1] << 8) | data[0];
    byte cfg = (data[4] & 0x60);

    if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
    if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
    if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms

    tempDS = (float)raw * 0.0625;
    
    // read EEPROM
    EEPROM.get(address_counter_force, current_counter_force);
    EEPROM.get(address_counter_admin, current_counter_admin);
    EEPROM.get(address_tempDS, tempDS_array);
    EEPROM.get(address_tempSH, tempSH_array);
    EEPROM.get(address_humiSH, humiSH_array);
    EEPROM.get(address_soc, soc_array);

    // Read values from the SHT10 sensor
    tempSH = sht1x.readTemperatureC();
    humiSH = sht1x.readHumidity();

    // Read values of battery
    batterySOC = fuel.getSoC();
    
    // remove random errors
    if (tempDS > 84.0 || tempDS < -40.0) {
        tempDS = tempDS_array[size_of_queue-2];
    }
    if (tempSH > 84.0 || tempSH < -40.0) {
        tempSH = tempSH_array[size_of_queue-2];
    }
    if (humiSH > 100.0 || humiSH < 0.0) {
        humiSH = humiSH_array[size_of_queue-2];
    }
    if (batterySOC > 100.0 || batterySOC < 0.0) {
        batterySOC = soc_array[size_of_queue-2];
    }
    
    // routine to check a border crash
    EEPROM.get(address_tempDS_max, ds_temp_max);
    EEPROM.get(address_tempDS_min, ds_temp_min);
    EEPROM.get(address_tempSH_max, sh_temp_max);
    EEPROM.get(address_tempSH_min, sh_temp_min);
    EEPROM.get(address_humiSH_max, sh_humi_max);
    EEPROM.get(address_humiSH_min, sh_humi_min);
    EEPROM.get(address_borders_were_crashed, borders_were_crashed);
    
    if (tempDS > ds_temp_max
    || tempDS < ds_temp_min
    || tempSH > sh_temp_max
    || tempSH < sh_temp_min
    || humiSH > sh_humi_max
    || humiSH < sh_humi_min) {
        if(borders_were_crashed == false) {
            border_crashed = true;
        } else {
            border_crashed = false;
            
        }
        borders_were_crashed = true;
    } else {
        borders_were_crashed = false;
        border_crashed = false;
    }
    EEPROM.put(address_borders_were_crashed, borders_were_crashed);
    
    // move every entry one position back
    for (int n=0; n<size_of_queue - 1; n++) {
        tempDS_array[n] = tempDS_array[n + 1];
        tempSH_array[n] = tempSH_array[n + 1];
        humiSH_array[n] = humiSH_array[n + 1];
        soc_array[n] = soc_array[n + 1];
    }
    
    // if the exact value is need (break and false predict) then use them, else use the predicted. So the exact value is transmitted to the server to trigger the right events
    // in case of storing the predicted value, this is nessesary for the next prediction because the server also nows only the predict value 
    tempDS_array[size_of_queue - 1] = tempDS;
    tempSH_array[size_of_queue - 1] = tempSH;
    humiSH_array[size_of_queue - 1] = humiSH;
    soc_array[size_of_queue - 1] = batterySOC;
  
    // store new values in EEPROM
    EEPROM.put(address_tempDS, tempDS_array);
    EEPROM.put(address_tempSH, tempSH_array);
    EEPROM.put(address_humiSH, humiSH_array);
    EEPROM.put(address_soc, soc_array);
    
    // Need to do this to go in the correct sleep mode: https://community.particle.io/t/electron-sleep-mode-deep-tips-and-examples/27823
    Cellular.on();

    // dont send data every time. Store in EEPROM and send whole array sometimes.
    if ((current_counter_force >= (steps_to_force - 1)) || border_crashed) { // "- 1" because counter starts with 0

        Cellular.connect();
        waitUntil(Cellular.ready);  
        Particle.connect();
        waitUntil(Particle.connected);
        Particle.process();
      
        // build transfer string
        publishDString[0] = '[';
        publishSString[0] = '[';
        publishHString[0] = '[';
        publishPString[0] = '[';

        for (int i=0; i<size_of_queue; i++) {
            if (i == (size_of_queue - 1)) { // last iteration -> closing brake
                snprintf(publishDString, sizeof(publishDString), "%s%.2f]", publishDString, tempDS_array[i]);
                snprintf(publishSString, sizeof(publishSString), "%s%.2f]", publishSString, tempSH_array[i]);
                snprintf(publishHString, sizeof(publishHString), "%s%.2f]", publishHString, humiSH_array[i]);
                snprintf(publishPString, sizeof(publishPString), "%s%.2f]", publishPString, soc_array[i]);
            } else {
                snprintf(publishDString, sizeof(publishDString), "%s%.2f,", publishDString, tempDS_array[i]);
                snprintf(publishSString, sizeof(publishSString), "%s%.2f,", publishSString, tempSH_array[i]);
                snprintf(publishHString, sizeof(publishHString), "%s%.2f,", publishHString, humiSH_array[i]);
                snprintf(publishPString, sizeof(publishPString), "%s%.2f,", publishPString, soc_array[i]);
            }
        }

        snprintf(pubData, sizeof(pubData)
           ,"{'d':'%s','s':'%s','h':'%s','p':'%s','t':'%d'}"
           ,publishDString
           ,publishSString
           ,publishHString
           ,publishPString
           ,timeToSleep
           );
        Particle.publish("frostEvent", pubData, PRIVATE); // data max 255 bytes
        
        if (current_counter_admin >= (steps_to_admin - 1)) {
            // Get location
            uint8_t tries = 0;
            CellLocate cell;
            while (!cell.completed() && tries++ < 10) {
                if (cell.get_response()) {
                    latitude = cell.getLat();
                    longitude = cell.getLng();
                } else {
                    delay(100);
                }
            }
            // Get Cellular data
            CellularSignal sig = Cellular.RSSI();
            
            snprintf(pubDataLocation, sizeof(pubDataLocation)
            ,"{'la':'%s','lo':'%s','a':'%d'}"
            ,latitude
            ,longitude
            ,sig.rssi
            );
            Particle.publish("locationEvent", pubDataLocation, PRIVATE); // data max 255 bytes
            EEPROM.put(address_counter_admin, 0);
        } else {
            EEPROM.put(address_counter_admin, current_counter_admin + 1);
        }
        
        EEPROM.put(address_counter_force, 0);
        Particle.process();
        delay(10000); // wait 10sec for new borders

    } else {
        EEPROM.put(address_counter_force, current_counter_force + 1);
    }
    delay(1000); // could be removed with firmware 0.6.1
    awakeTime = millis() / 1000;
    if (awakeTime > 300 || awakeTime < 0) { // not allow bigger than 5mins
        awakeTime = 0;
    }
    System.sleep(SLEEP_MODE_DEEP, timeToSleep - awakeTime);
}

```

I use the current firmware 0.6.1 on Electrons version 2G.  
The ublox says that my signal strength is between 18 and 31 (scale 0 - 31). RSSI is between -72 and -51.

---

<div class="post-metadata">

**Author:** ![ctmorrison](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ctmorrison/32/7396_2.png) [@ctmorrison](https://community.particle.io/u/ctmorrison)\
**Post date:** [March 9, 2017, 5:32pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/9 "2017-03-09T17:32:55Z")

</div>

I’m having issues, too, with a new Electron I’m setting up. I initially started it with a Particle SIM and changed to an AT&T SIM only to have it fail to connect (I’ve gone through this procedure with about 10 other Electrons). I put the Particle SIM back in and flashed Tinker. The device seems to be operating erratically–sometimes on the air, sometimes not.

BTW, when I first unpacked the device, I immediately upgraded it to 0.6.1. Well…I tried using the upgrade app, but without success, so I did a `particle update` which appeared to work. I’ve since run that command, again, and that seemed to help, but it could simply be a coincidence.

[pre-post update] I put in the AT&T SIM and reflashed the app with the correct APN and it appears to be working normally now. Don’t know why I had issues. Things that make you go hmmmmm…

[yet another update] I had similar issues with the second Electron today. I registered it with the Particle SIM, did a `particle update` and confirmed it was at 0.6.1. I then flashed my application code and put in the AT&T SIM. It would not connect to the AT&T network. So…I put the Particle SIM back in and flashed Tinker. I interacted with the device a few times (D7 LED on&off) and then re-flashed my application code without changing the SIM. As expected, it would not connect (my app changes the APN to AT&T). I changed the SIM card to AT&T and voilà, the device connected to AT&T’s network.

I don’t recall having these issues prior to 0.6.1, but then again, I never went through these same steps. For all my earlier devices they were running fine on Particle SIMs prior to me switching them over to the AT&T SIMs and it was rather uneventful.

---

<div class="post-metadata">

**Author:** ![ctmorrison](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ctmorrison/32/7396_2.png) [@ctmorrison](https://community.particle.io/u/ctmorrison)\
**Post date:** [March 9, 2017, 8:51pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/10 "2017-03-09T20:51:22Z")

</div>

I now have two Electrons that have been operating just fine at a remote location that appear to be offline as of this morning. I’m assuming this is the old “device broker” issue, but may be related to the above. I’ll PM my device IDs to @rickkas7 who has checked on them in the past.

---

<div class="post-metadata">

**Author:** ![Niklas](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/niklas/32/13482_2.png) [@Niklas](https://community.particle.io/u/Niklas)\
**Post date:** [March 9, 2017, 9:20pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/11 "2017-03-09T21:20:43Z")

</div>

Which “device broker” issue do you mean? The one which happens a few weeks ago when the Electrons couldn’t connect to the cloud and cannot publish events reliable?

I also think this because two further Electrons started failing. Pressing reset results the correct led pattern until cyan breathing. And the application also is executed (saw with serial debug). But no events arrived the console and in my server side application.

---

<div class="post-metadata">

**Author:** ![ctmorrison](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ctmorrison/32/7396_2.png) [@ctmorrison](https://community.particle.io/u/ctmorrison)\
**Post date:** [March 9, 2017, 9:23pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/12 "2017-03-09T21:23:18Z")

</div>

@Niklas, yes I was referring to the device broker issue that impacted a few of my Electrons a few weeks ago. @rickkas7 indicated he’s not seeing anything in the logs, so it may be another issue.

---

<div class="post-metadata">

**Author:** ![Niklas](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/niklas/32/13482_2.png) [@Niklas](https://community.particle.io/u/Niklas)\
**Post date:** [March 9, 2017, 9:32pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/13 "2017-03-09T21:32:42Z")

</div>

I tried a third electron which was running fine until now. It also cannot publish anymore. So it has to be something wrong on Particle side? 😊

---

<div class="post-metadata">

**Author:** ![Niklas](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/niklas/32/13482_2.png) [@Niklas](https://community.particle.io/u/Niklas)\
**Post date:** [March 9, 2017, 10:14pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/14 "2017-03-09T22:14:17Z")

</div>

I tested some things which could maybe help to find the problem:

The log of a successful connection to the cloud but not be able to publish looks like this:

```
[ElectronSerialPipe::begin] = = = = = = = =

[Modem::powerOn] = = = = = = = = = = = = = =
     5.441 AT send 4 "AT\r\n"
     5.591 AT read UNK 3 "AT\r"
     5.601 AT read OK 6 "\r\nOK\r\n"
     5.601 AT send 7 "AT E0\r\n"
     5.641 AT read UNK 6 "AT E0\r"
     5.651 AT read OK 6 "\r\nOK\r\n"
     5.651 AT send 11 "AT+CMEE=2\r\n"
     5.691 AT read OK 6 "\r\nOK\r\n"
     5.691 AT send 19 "AT+CMER=1,0,0,2,1\r\n"
     5.732 AT read OK 6 "\r\nOK\r\n"
     5.732 AT send 15 "AT+IPR=115200\r\n"
     5.772 AT read OK 6 "\r\nOK\r\n"
     5.872 AT send 10 "AT+CPIN?\r\n"
     5.912 AT read ERR 37 "\r\n+CME ERROR: operation not allowed\r\n"
     6.913 AT send 10 "AT+CPIN?\r\n"
     6.923 AT read + 14 "\r\n+CIEV: 9,0\r\n"
CIEV matched: 9,0
     6.953 AT read + 16 "\r\n+CPIN: READY\r\n"
     6.963 AT read OK 6 "\r\nOK\r\n"
0000006964 [system] INFO: ready(): 0; connecting(): 0; listening(): 0; WLAN_SMART_CONFIG_START: 0
0000006965 [system] INFO: Sim Ready
0000006965 [system] INFO: ARM_WLAN_WD 1

[Modem::init] = = = = = = = = = = = = = = =
     6.964 AT send 9 "AT+CGSN\r\n"
     7.005 AT read UNK 19 "\r\n353161071128907\r\n"
     7.015 AT read OK 6 "\r\nOK\r\n"
     7.015 AT send 9 "AT+CGMI\r\n"
     7.055 AT read UNK 10 "\r\nu-blox\r\n"
     7.065 AT read OK 6 "\r\nOK\r\n"
     7.065 AT send 9 "AT+CGMM\r\n"
     7.105 AT read UNK 13 "\r\nSARA-G350\r\n"
     7.115 AT read OK 6 "\r\nOK\r\n"
     7.115 AT send 9 "AT+CGMR\r\n"
     7.155 AT read UNK 9 "\r\n08.70\r\n"
     7.165 AT read OK 6 "\r\nOK\r\n"
     7.165 AT send 9 "AT+CCID\r\n"
     7.205 AT read + 30 "\r\n+CCID: 8934076500002580389\r\n"
     7.216 AT read OK 6 "\r\nOK\r\n"
     7.216 AT send 11 "AT+UPSV=1\r\n"
     7.256 AT read OK 6 "\r\nOK\r\n"
     7.256 AT send 11 "AT+CMGF=1\r\n"
     7.296 AT read OK 6 "\r\nOK\r\n"
     7.296 AT send 13 "AT+CNMI=2,1\r\n"
     7.336 AT read OK 6 "\r\nOK\r\n"
     7.336 AT send 9 "AT+CIMI\r\n"
     7.376 AT read UNK 19 "\r\n214074300497394\r\n"
     7.386 AT read OK 6 "\r\nOK\r\n"

[Modem::register] = = = = = = = = = = = = = =
     7.386 AT send 10 "AT+CREG?\r\n"
     7.427 AT read + 14 "\r\n+CREG: 0,0\r\n"
     7.437 AT read OK 6 "\r\nOK\r\n"
     7.437 AT send 11 "AT+CGREG?\r\n"
     7.477 AT read + 15 "\r\n+CGREG: 0,2\r\n"
     7.487 AT read OK 6 "\r\nOK\r\n"
     7.487 AT send 12 "AT+CGREG=2\r\n"
     7.527 AT read OK 6 "\r\nOK\r\n"
     7.527 AT send 11 "AT+CREG=2\r\n"
     7.567 AT read OK 6 "\r\nOK\r\n"
     7.567 AT send 10 "AT+CREG?\r\n"
     7.607 AT read + 14 "\r\n+CREG: 2,0\r\n"
     7.617 AT read OK 6 "\r\nOK\r\n"
     7.617 AT send 11 "AT+CGREG?\r\n"
     7.657 AT read + 15 "\r\n+CGREG: 2,2\r\n"
     7.667 AT read OK 6 "\r\nOK\r\n"
    22.667 AT send 10 "AT+CREG?\r\n"
    22.667 AT read + 14 "\r\n+CIEV: 2,5\r\n"
    22.678 AT read + 14 "\r\n+CIEV: 9,1\r\n"
CIEV matched: 9,1
    22.688 AT read + 14 "\r\n+CIEV: 7,1\r\n"
    22.698 AT read + 14 "\r\n+CIEV: 3,1\r\n"
    22.708 AT read + 26 "\r\n+CREG: 5,\"5276\",\"616E\"\r\n"
    22.718 AT read + 27 "\r\n+CGREG: 5,\"5276\",\"616E\"\r\n"
    22.728 AT read + 14 "\r\n+CIEV: 9,2\r\n"
CIEV matched: 9,2
    22.738 AT read + 14 "\r\n+CIEV: 9,2\r\n"
CIEV matched: 9,2
    22.978 AT read + 28 "\r\n+CREG: 2,5,\"5276\",\"616E\"\r\n"
    22.988 AT read OK 6 "\r\nOK\r\n"
    22.988 AT send 11 "AT+CGREG?\r\n"
    23.028 AT read + 29 "\r\n+CGREG: 2,5,\"5276\",\"616E\"\r\n"
    23.038 AT read OK 6 "\r\nOK\r\n"
    23.038 AT send 10 "AT+COPS?\r\n"
    23.078 AT read + 27 "\r\n+COPS: 0,0,\"Telekom.de\"\r\n"
    23.088 AT read OK 6 "\r\nOK\r\n"
    23.088 AT send 9 "AT+CNUM\r\n"
    23.168 AT read OK 6 "\r\nOK\r\n"
    23.168 AT send 8 "AT+CSQ\r\n"
    23.208 AT read + 15 "\r\n+CSQ: 31,99\r\n"
    23.218 AT read OK 6 "\r\nOK\r\n"

[Modem::join] = = = = = = = = = = = = = = = =
    23.218 AT send 12 "AT+CGATT=1\r\n"
    23.259 AT read OK 6 "\r\nOK\r\n"
    23.259 AT send 14 "AT+UPSND=0,8\r\n"
    23.299 AT read + 17 "\r\n+UPSND: 0,8,0\r\n"
    23.309 AT read OK 6 "\r\nOK\r\n"
    23.309 AT send 23 "AT+UPSD=0,7,\"0.0.0.0\"\r\n"
    23.350 AT read OK 6 "\r\nOK\r\n"
    23.350 AT send 41 "AT+UPSD=0,1,\"m2mdetrial.telefonica.com\"\r\n"
    23.391 AT read OK 6 "\r\nOK\r\n"
    23.391 AT send 15 "AT+UPSD=0,6,0\r\n"
    23.431 AT read OK 6 "\r\nOK\r\n"
    23.431 AT send 14 "AT+UPSDA=0,3\r\n"
    24.201 AT read OK 6 "\r\nOK\r\n"
    24.201 AT send 14 "AT+UPSND=0,0\r\n"
    24.241 AT read + 31 "\r\n+UPSND: 0,0,\"10.42.155.129\"\r\n"
    24.252 AT read OK 6 "\r\nOK\r\n"
0000024253 [system] INFO: ARM_WLAN_WD 2
0000024253 [system] INFO: CLR_WLAN_WD 1, DHCP success
0000024254 [system] INFO: Cloud: connecting
0000024254 [system] TRACE: sparkSocket Now =-1
0000024254 [system] TRACE: HAL_FLASH_Read_ServerAddress() = type:1,domain:$id.udp.particle.io,ip: 46.100.105.36, port: 65535
0000024255 [system] TRACE: using IP/port from session
On first socketSocket use, free all open sockets
    24.255 AT send 15 "AT+USOCTL=0,1\r\n"
    24.295 AT read ERR 37 "\r\n+CME ERROR: operation not allowed\r\n"
    24.296 AT send 15 "AT+USOCTL=1,1\r\n"
    24.336 AT read ERR 37 "\r\n+CME ERROR: operation not allowed\r\n"
    24.337 AT send 15 "AT+USOCTL=2,1\r\n"
    24.377 AT read ERR 37 "\r\n+CME ERROR: operation not allowed\r\n"
    24.378 AT send 15 "AT+USOCTL=3,1\r\n"
    24.418 AT read ERR 37 "\r\n+CME ERROR: operation not allowed\r\n"
    24.419 AT send 15 "AT+USOCTL=4,1\r\n"
    24.459 AT read ERR 37 "\r\n+CME ERROR: operation not allowed\r\n"
    24.460 AT send 15 "AT+USOCTL=5,1\r\n"
    24.500 AT read ERR 37 "\r\n+CME ERROR: operation not allowed\r\n"
    24.501 AT send 15 "AT+USOCTL=6,1\r\n"
    24.541 AT read ERR 37 "\r\n+CME ERROR: operation not allowed\r\n"
socketSocket(UDP)
    24.542 AT send 18 "AT+USOCR=17,5684\r\n"
    24.582 AT read + 13 "\r\n+USOCR: 0\r\n"
    24.592 AT read OK 6 "\r\nOK\r\n"
Socket 0: handle 0 was created
0000024593 [system] TRACE: socketed udp=1, sparkSocket=0, 1
0000024594 [system] TRACE: connection attempt to 54.89.10.58:5684
0000024594 [system] INFO: Cloud socket connected
0000024594 [system] INFO: Starting handshake: presense_announce=0
0000024595 [comm.protocol.handshake] INFO: Establish secure connection
0000024610 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=0
0000024610 [comm.dtls] INFO: out_ctr 0,1,0,0,0,0,0,40, next_coap_id=16
0000024611 [comm.dtls] INFO: app state crc: 26c327d7, expected: 26c327d7
0000024611 [comm.dtls] WARN: skipping hello message
0000024612 [comm.dtls] INFO: restored session from persisted session data. next_msg_id=22
0000024612 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 2
0000024613 [comm.coap] TRACE: sending message id=17
0000024613 [system] TRACE: send 46
socketSendTo(0,54.89.10.58,5684,,46)
    24.613 AT send 34 "AT+USOST=0,\"54.89.10.58\",5684,46\r\n"
    24.664 AT read > 3 "\r\n@"
    24.714 AT send 46 "\xfe\xfe\xfd\x00\x01\x00\x00\x00\x00\x00(\x00\x14\x00\x01\x00\x00\x00\x00\x00(Y\xd9e\xc3Q\x95X\x99\xfdg\xc7\xbd=\x00:\x00\fQ434618\f"
    24.755 AT read + 16 "\r\n+USOST: 0,46\r\n"
    24.765 AT read OK 6 "\r\nOK\r\n"
0000024766 [comm.protocol.handshake] INFO: resumed session - not sending HELLO message
0000024766 [system] INFO: cloud connected from existing session.
0000024767 [system] INFO: Cloud connected
0000024788 [comm.coap] TRACE: sending message id=18
0000024789 [system] TRACE: send 295
socketSendTo(0,54.89.10.58,5684,,295)
    24.789 AT send 35 "AT+USOST=0,\"54.89.10.58\",5684,295\r\n"
    24.840 AT read > 3 "\r\n@"
    24.890 AT send 295 "\xfe\xfe\xfd\x00\x01\x00\x00\x00\x00\x00)\x01\r\x00\x01\x00\x00\x00\x00\x00)\xb3\x99@;i\x1c\xe8x>(\x04z?P\xba;\x15G}u[B\r\x0e\x81\xcd\xf59\xe9)\x88\x89\\\x91V\xcc\xca\x8c\xd1*\xe9\xd7\xc9\x16bw/\x91\x18h\xbc\f\x11\xf0]\x92\x8at\xbf\xa3k\xdd,\x92\x99\xa6\x88\xdf\xf3G\xa4\x8d\xe8\x8c\xe9\x14[\xf1\x8f9\xe0}=W\xf2\x91\xf8!\x8b\x8c\xe1\xf5\xd85\xc1\xd2\x10nW\x9aKv\xfd\xa6\xf8}\xbe$g<7|\x96[\x9chfm\x8f\xed\x82\\~Q\x9d\xf6H\xfb%[\x18!\"X\x97t\a\x8d\x1f\xf4o\xd6W)\xd2\xde\xcb\xd1\xbf-\x892\x93\nB\x10\xfa\x02J'\xb4pP[D\xc6\x81i!\xa6A\x8bS\xb0\xc9\x9de\xb3\xd7\x05\x85Q\xbd\xfa\x9aM\xc0\xe6\n\xa1\xe97&vMB\xe4\x8a5R\xaf\xb2\xba\x91\x96\xa0\xd0\xb2f\a\xd4\x9fK8@zT\x96\xf8#\xe0\xc0\x85\xa2\xb5\xf8\x0e\xe3\xc0\xdb\xd3X.\xf2\xf0\x17\xcc\xdd\xb2\xe7\xf3\x9d\n\x9f\b\x96\fA \xdb\x9cS\xae\xa1y\x02\x94\x17jS,=\x00:\x00\fQ434618\f"
    24.970 AT read + 17 "\r\n+USOST: 0,295\r\n"
    24.980 AT read OK 6 "\r\nOK\r\n"
0000029004 [system] TRACE: send 46
socketSendTo(0,54.89.10.58,5684,,46)
    29.003 AT send 34 "AT+USOST=0,\"54.89.10.58\",5684,46\r\n"
    29.044 AT read > 3 "\r\n@"
    29.094 AT send 46 "\xfe\xfe\xfd\x00\x01\x00\x00\x00\x00\x00*\x00\x14\x00\x01\x00\x00\x00\x00\x00*G\x85\xf0C\x87\xad\x8d\xac\\tM^=\x00:\x00\fQ434618\f"
    29.135 AT read + 16 "\r\n+USOST: 0,46\r\n"
    29.145 AT read OK 6 "\r\nOK\r\n"
0000031004 [system] TRACE: send 295
socketSendTo(0,54.89.10.58,5684,,295)
    31.004 AT send 35 "AT+USOST=0,\"54.89.10.58\",5684,295\r\n"
    31.055 AT read > 3 "\r\n@"
    31.105 AT send 295 "\xfe\xfe\xfd\x00\x01\x00\x00\x00\x00\x00+\x01\r\x00\x01\x00\x00\x00\x00\x00+\xb7\n\xf0\x84\xae%b>N\x1d\xa5\xae\xc0\xf6C\xa7\xbe\x12\x84z\x11Ykf(\xff\x80\xc5\xb4\xaf\xb6\xf7\xaaL\x16\x03\xbc\xd5\x90\x15\xa2\xf0\xf9d\x06(\xfb3\xa7j\x979^\x00\xdc*bWL\x80\x17_X5\xbc\xfc\xd7\xbb\xf9\x89\x9e\xea\xe3\x85\x17R\xf0\xf5\xf5\xdd\x00\x9e\xc6.\xb4\x80\x0f\b\xc3x\x04<K\xc6uP\xe1\x06\xfb\x18fna}\xce\xa0&\xc8\x8e\v\xab\xa3\xb7\xa4(\x9e\xae\x96U\xc7\x7f\b9\xbb'&<\x90\x00?\x1dG\xdf\x1f\x9d\xfb\x97;\xfe\x06H\x02\xa7\xd1\xe9-u\xee\xc1OsH\xc0\x9bXn\x91\xf5\xaf\xcc\x8dQKy\x8bR\f/\x94\x83B\xaf\xfd\x1fj\x1b\xf3\xd7X'!de-\xed\xc5a\x89\xb4%\xf3\x13{\x19t#\xc1r\xd6\x16\xc7M\x96\xc9\x9a\xce\x1f\r'\xc5!\xe1F\x1a\xb8O\xed\x8a\xa8P\xbf\x9c\xd8\xa98U\xa3\x8f\x17W\xa9|\x93=\x0f\xa9\xdf\x01R\x99\xa6\x9e\x88\xef\xaf\xe4wY\xff\xfa\xbd9\xb6Y<O\xd6\xae\xf2\x86\v=\x00:\x00\fQ434618\f"
    31.175 AT read + 17 "\r\n+USOST: 0,295\r\n"
    31.185 AT read OK 6 "\r\nOK\r\n"
0000035993 [system] TRACE: Close Attempt
socketClose(0)
    35.992 AT send 12 "AT+USOCL=0\r\n"
    36.032 AT read OK 6 "\r\nOK\r\n"
socketFree(0)
0000036033 [system] TRACE: socket_close()=success
0000036033 [system] INFO: Cloud: disconnecting
0000036034 [system] INFO: Cloud: disconnected

[Modem::disconnect] = = = = = = = = = = = = =
    36.033 AT send 14 "AT+UPSDA=0,4\r\n"
    36.944 AT read OK 6 "\r\nOK\r\n"

[Modem::detach] = = = = = = = = = = = = = = =
    36.944 AT send 12 "AT+CGATT=0\r\n"
    37.505 AT read OK 6 "\r\nOK\r\n"

[Modem::detach] = = = = = = = = = = = = = = =
    37.505 AT send 12 "AT+CGATT=0\r\n"
    37.506 AT read + 13 "\r\n+CGREG: 0\r\n"
    37.516 AT read + 14 "\r\n+CIEV: 9,1\r\n"
CIEV matched: 9,1
    37.546 AT read OK 6 "\r\nOK\r\n"

[Modem::powerOff] = = = = = = = = = = = = = =
    37.546 AT send 12 "AT+CPWROFF\r\n"
    37.547 AT read + 14 "\r\n+CIEV: 9,1\r\n"
CIEV matched: 9,1

```

This is what I tested in this order. After each step I tried to publish an event.

1. reflash current firmware with `particle update` =\> no event in console
2. particle keys server + reset button =\> no event in console
3. particle keys server \<device\_id\> (be aware that I create new keys) **=\>** first fast cyan flashing is interrupted with a single red flash (typical key error) and then it tries a second time. This works. **Publishing works again** and in all further application loops, there is no red flash anymore.

@ Particle team: what can we do, that the Electrons’ keys have not to regenerate so often? With this, you cannot create a cool and stable product :-/

---

<div class="post-metadata">

**Author:** ![RWB](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rwb/32/22599_2.png) [@RWB](https://community.particle.io/u/RWB)\
**Post date:** [March 9, 2017, 10:31pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/15 "2017-03-09T22:31:52Z")

</div>

I will rarely see the Electron start to act like it’s publishing data normally but it will not be publishing.

I’m not using the Particle cloud in my application, but instead, I’m sending data to Ubidots directly using UDP. This makes the connection times much quicker than pushing the data over the particle cloud.

But still I see the same issue where the Electron looks like its publishing the data to Ubidots just fine, but no data is sent. If I then manually reset the Electron it will start sending data correctly again.

Maybe it’s the cellular side of the data transmission that is getting messed up. I can confirm that the same thing happens to my Electron even when not using the Particle services.

I’ll have to give the new 0.6.1 firmware a try.

---

<div class="post-metadata">

**Author:** ![Niklas](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/niklas/32/13482_2.png) [@Niklas](https://community.particle.io/u/Niklas)\
**Post date:** [March 9, 2017, 10:39pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/16 "2017-03-09T22:39:51Z")

</div>

I use the firmware 0.6.1. So I think it would not help you.

Maybe it is a ublox problem? I didn’t find any comparing problem in their forum: [https://forum.u-blox.com/](https://forum.u-blox.com/) But this would not explain why new keys helps.

@RWB So when you do not use Particle services, you also do not connect to their cloud in you application? If yes, I do not really understand why new keys helps because you do not use them?

---

<div class="post-metadata">

**Author:** ![RWB](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rwb/32/22599_2.png) [@RWB](https://community.particle.io/u/RWB)\
**Post date:** [March 9, 2017, 10:47pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/17 "2017-03-09T22:47:38Z")

</div>

Yes I do not use the Particle Cloud services in my test code. I just use the cellular UDP connection to send sensor data directly to Ubidots. Once it starts not sending sensor data to Ubidots but still looks like it is it will last for days until I Manually reset it. The Electron just keeps moving along as if everything is going OK and no safety feature kicks in to reset it automatically.

I have never needed to reset any keys on a Electron.

---

<div class="post-metadata">

**Author:** ![Niklas](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/niklas/32/13482_2.png) [@Niklas](https://community.particle.io/u/Niklas)\
**Post date:** [March 9, 2017, 10:56pm UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/18 "2017-03-09T22:56:59Z")

</div>

I think this is another problem which I also have round about every 4 days with some Electrons (not with all). After pressing the reset button they work for the next few days. Then they fall in the same problem state.

The “not publishing” issue is new (it seems it is not the Particle services problem like a few weeks ago). I have this since today and can solve it with new keys (keys doctor).

---

<div class="post-metadata">

**Author:** ![Niklas](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/niklas/32/13482_2.png) [@Niklas](https://community.particle.io/u/Niklas)\
**Post date:** [March 10, 2017, 12:07am UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/19 "2017-03-10T00:07:43Z")

</div>

I’m starting to compare the log of a cloud connection where I am able to publish and where i am not able to publish:

My current insights:

1. The message ids (`[comm.coap] TRACE: sending message id=17`) are different at the same position. But they are different in every of my stored logs.

2. The remote host ip address (particle server) is often different from log to log. Does Particle have multiple endpoints? The not working ip address was in my case: 54.89.10.58. I will check whether my working Electrons connect to this IP and can publish.

3. In the problem case, there are no messages received by the Electron. In a successful case this lines are in the log:

**Update**

Starting a deep dive in the Electron firmware, I think I find a possible reason for our problems. [Fast Link to GitHub](https://github.com/spark/firmware/blob/0dd5010c48c9c3ce89e131edfec307b7420ab0ee/system/src/system_cloud_internal.cpp)

My thoughts:

- To generate the udp remote ip address for the Electron, this function is  
called: `determine_connection_address`

- There is an interesting todo comment:

- The constant `HAL_PLATFORM_CLOUD_UDP` is 1 in case of `PLATFORM_ID` is 10 or 3 (10 = Electron, 3 = GCC) see: [hal\_platform.h on GitHub](https://github.com/spark/firmware/blob/b4dd5e4ee0a7b6e0ae6a01b3a2ea72794efbf91a/hal/inc/hal_platform.h)

- The todo comment would also explain my guess that something wrong is stored of a previous cloud session. I think this because on the one hand a reset helps and on the other hand new keys help. This also explains why the problems only happen after some time.

- In this file you also see how to find the remote IPs of the cloud (the IPs in the log are not the public Electron IPs!). They are generated by resolving the domain name: `$id.udp.particle.io` - $id is replaced with the device id. This explains the differenct IPs from log to log.

Can someone confirm these points?

---

<div class="post-metadata">

**Author:** ![RWB](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rwb/32/22599_2.png) [@RWB](https://community.particle.io/u/RWB)\
**Post date:** [March 10, 2017, 1:14am UTC](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265/20 "2017-03-10T01:14:27Z")

</div>

This may be Something @BDub wants to know about. For me, this rarely happens, but it does happen.

[Next page](https://community.particle.io/t/electron-suddenly-stopped-connecting/28265.md?page=2)
