Photon 2 frequently goes offline and eventually locks up

First project with Photon 2 and I am upgrading an existing project from an Argon to the Photon 2. The Argon has worked for over a year with no issues. Both the Argon and Photons are using 5.4.1. I have taken the existing code and only replaced the I/O portion of the code to update for the different pinouts. The new circuit board the Photon 2 is plugged into has the same components as the Argon. All I/O connections are disconnected to the circuit board except a 20x4 I2C liquid crystal display and any other components on the board a passive. I do have the Blynk library installed also but have disabled the portion of the code allowing it to connect to the cloud for troubleshooting.
My problem is randomly the Photon 2 will go offline just briefly and come back online. This is random and can happen from a few to several times an hour. At some point from 1 to several hours the Photon 2 will stop responding and the LED will be solid blue or out completely. I have two separate circuit boards with Photon 2's running the same code and both act the same and stop responding. One is USB powered by my computer so I can monitor the logs and the other uses a 5 volt power supply.
Monitoring the free memory shows no memory leak. The code shows 60k being used on the Argon and 120k being used when on the Photon 2 so I am assuming more overhead needed for the Photon 2? Below is the log file showing several times going offline and the last entry when the device failed. I could use any help to determine where to go to next in troubleshooting though I believe it should be working fine since it has worked fine on the Argon.

0003677820 [net.ifapi] INFO: Netif wl3 link DOWN, profile=NONE
0003677835 [net.rltkncp] ERROR: linkOutput up=1 link_up=0
0003677849 [system.nm] INFO: State changed: IP_CONFIGURED -> IFACE_LINK_UP
0003677866 [hal] INFO: DNS server list changed
0003677878 [hal] INFO: DNS server list changed
0003677893 [system.nm] INFO: State changed: IFACE_LINK_UP -> IFACE_UP
0003677913 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0003677915 [net.lwip_rltk] INFO: is_promisc_enabled
0003677916 [ncp.rltk.client] INFO: disconnected
0003677917 [net.lwip_rltk] INFO: get_eap_phase
0003677931 [wiring] ERROR: recv error = 113
0003678124 [system] ERROR: sock_send returned -1 118
0003678159 [comm.dtls] ERROR: mbedtls_ssl_write() failed: -0x4e
0003678195 [comm.protocol] ERROR: Event loop error 33
0003678231 [system] WARN: Communication loop error, closing cloud socket
0003678282 [system] INFO: Cloud: disconnecting
0003678309 [system] INFO: Cloud: disconnected
0003682224 [ncp.rltk.client] INFO: disconnected
0003682735 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0003682737 [net.lwip_rltk] INFO: is_promisc_enabled
0003682738 [net.lwip_rltk] INFO: get_eap_phase
0003682940 [net.lwip_rltk] INFO: netif_post_sleep_processing TODO
0003686744 [net.lwip_rltk] INFO: get_eap_phase
0003686865 [net.lwip_rltk] INFO: get_eap_phase
0003686884 [net.ifapi] INFO: Netif wl3 link UP, profile=Home1
0003686895 [system.nm] INFO: State changed: IFACE_UP -> IFACE_LINK_UP
0003686923 [hal] INFO: DNS server list changed
0003686937 [system.nm] INFO: State changed: IFACE_LINK_UP -> IP_CONFIGURED
0003686956 [system] INFO: Cloud: connecting
0003686988 [system] INFO: Read Server Address = type:1,domain:$id.udp.particle.io
0003687029 [system] INFO: Loaded cloud server address and port from session data
0003687070 [system] INFO: Cloud socket=0, connecting to 3.222.143.118#5684
0003687108 [system] INFO: Cloud socket connected
0003687132 [system] INFO: Starting handshake: presense_announce=0
0003687166 [comm.protocol.handshake] INFO: Establish secure connection
0003687203 [comm.dtls] INFO: session has 0 uses
0003687232 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=0
0003687269 [comm.dtls] INFO: out_ctr 0,1,0,0,0,0,10,90, next_coap_id=9e1
0003687305 [comm.dtls] INFO: restored session from persisted session data. next_msg_id=2529
0003687351 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 2
0003688272 [comm.protocol.handshake] INFO: Skipping HELLO message
0003688307 [system] INFO: cloud connected from existing session.
0003688345 [system] INFO: Sending application DESCRIBE
0003688374 [comm.protocol] INFO: Checksum has not changed; not sending application DESCRIBE
0003688421 [system] INFO: Sending subscriptions
0003688445 [comm.protocol] INFO: Checksum has not changed; not sending subscriptions
0003688489 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 4
0003688625 [system] INFO: All handshake messages have been processed
0003688760 [system] INFO: Cloud connected
0005252247 [ncp.rltk.client] INFO: disconnected
0005252254 [net.ifapi] INFO: Netif wl3 link DOWN, profile=NONE
0005252269 [net.rltkncp] ERROR: linkOutput up=1 link_up=0
0005252283 [system.nm] INFO: State changed: IP_CONFIGURED -> IFACE_LINK_UP
0005252302 [hal] INFO: DNS server list changed
0005252314 [hal] INFO: DNS server list changed
0005252329 [system.nm] INFO: State changed: IFACE_LINK_UP -> IFACE_UP
0005252349 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0005252351 [net.lwip_rltk] INFO: is_promisc_enabled
0005252352 [ncp.rltk.client] INFO: disconnected
0005252353 [net.lwip_rltk] INFO: get_eap_phase
0005252360 [wiring] ERROR: recv error = 113
0005252558 [system] ERROR: sock_send returned -1 118
0005252587 [comm.dtls] ERROR: mbedtls_ssl_write() failed: -0x4e
0005252722 [system] ERROR: sock_send returned -1 118
0005252750 [comm.dtls] ERROR: mbedtls_ssl_read() failed: -0x4e
0005252824 [comm.protocol] ERROR: Event loop error 34
0005252852 [system] WARN: Communication loop error, closing cloud socket
0005252889 [system] INFO: Cloud: disconnecting
0005252914 [system] INFO: Cloud: disconnected
0005256661 [ncp.rltk.client] INFO: disconnected
0005257169 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0005257171 [net.lwip_rltk] INFO: is_promisc_enabled
0005257172 [net.lwip_rltk] INFO: get_eap_phase
0005261176 [ncp.rltk.client] INFO: disconnected
0005261882 [net.lwip_rltk] INFO: netif_post_sleep_processing TODO
0005265784 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0005265786 [net.lwip_rltk] INFO: is_promisc_enabled
0005265787 [net.lwip_rltk] INFO: get_eap_phase
0005269692 [net.lwip_rltk] INFO: get_eap_phase
0005269815 [net.lwip_rltk] INFO: get_eap_phase
0005269847 [net.ifapi] INFO: Netif wl3 link UP, profile=Home1
0005269857 [system.nm] INFO: State changed: IFACE_UP -> IFACE_LINK_UP
0005271413 [hal] INFO: DNS server list changed
0005271426 [system.nm] INFO: State changed: IFACE_LINK_UP -> IP_CONFIGURED
0005271443 [system] INFO: Cloud: connecting
0005271466 [system] INFO: Read Server Address = type:1,domain:$id.udp.particle.io
0005271508 [system] INFO: Loaded cloud server address and port from session data
0005271550 [system] INFO: Cloud socket=0, connecting to 3.222.143.118#5684
0005271588 [system] INFO: Cloud socket connected
0005271612 [system] INFO: Starting handshake: presense_announce=0
0005271646 [comm.protocol.handshake] INFO: Establish secure connection
0005271684 [comm.dtls] INFO: session has 0 uses
0005271713 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=0
0005271749 [comm.dtls] INFO: out_ctr 0,1,0,0,0,0,10,156, next_coap_id=a22
0005271786 [comm.dtls] INFO: restored session from persisted session data. next_msg_id=2594
0005271834 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 2
0005272740 [comm.protocol.handshake] INFO: Skipping HELLO message
0005272776 [system] INFO: cloud connected from existing session.
0005272816 [system] INFO: Sending application DESCRIBE
0005272845 [comm.protocol] INFO: Checksum has not changed; not sending application DESCRIBE
0005272892 [system] INFO: Sending subscriptions
0005272917 [comm.protocol] INFO: Checksum has not changed; not sending subscriptions
0005272961 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 4
0005273098 [system] INFO: All handshake messages have been processed
0005273233 [system] INFO: Cloud connected
0007607187 [ncp.rltk.client] INFO: disconnected
0007607194 [net.ifapi] INFO: Netif wl3 link DOWN, profile=NONE
0007607208 [net.rltkncp] ERROR: linkOutput up=1 link_up=0
0007607223 [system.nm] INFO: State changed: IP_CONFIGURED -> IFACE_LINK_UP
0007607240 [hal] INFO: DNS server list changed
0007607251 [hal] INFO: DNS server list changed
0007607266 [system.nm] INFO: State changed: IFACE_LINK_UP -> IFACE_UP
0007607286 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0007607288 [net.lwip_rltk] INFO: is_promisc_enabled
0007607289 [ncp.rltk.client] INFO: disconnected
0007607291 [net.lwip_rltk] INFO: get_eap_phase
0007607295 [wiring] ERROR: recv error = 113
0007611199 [system] ERROR: sock_send returned -1 118
0007611226 [comm.dtls] ERROR: mbedtls_ssl_write() failed: -0x4e
0007611359 [system] ERROR: sock_send returned -1 118
0007611386 [comm.dtls] ERROR: mbedtls_ssl_read() failed: -0x4e
0007611419 [comm.protocol] ERROR: Event loop error 34
0007611447 [system] WARN: Communication loop error, closing cloud socket
0007611484 [system] INFO: Cloud: disconnecting
0007611510 [system] INFO: Cloud: disconnected
0007611598 [ncp.rltk.client] INFO: disconnected
0007612108 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0007612110 [net.lwip_rltk] INFO: is_promisc_enabled
0007612111 [net.lwip_rltk] INFO: get_eap_phase
0007616116 [ncp.rltk.client] INFO: disconnected
0007616823 [net.lwip_rltk] INFO: netif_post_sleep_processing TODO
0007620725 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0007620727 [net.lwip_rltk] INFO: is_promisc_enabled
0007620728 [net.lwip_rltk] INFO: get_eap_phase
0007624632 [net.lwip_rltk] INFO: get_eap_phase
0007624766 [net.lwip_rltk] INFO: get_eap_phase
0007624795 [net.ifapi] INFO: Netif wl3 link UP, profile=Home1
0007624805 [system.nm] INFO: State changed: IFACE_UP -> IFACE_LINK_UP
0007624859 [hal] INFO: DNS server list changed
0007624873 [system.nm] INFO: State changed: IFACE_LINK_UP -> IP_CONFIGURED
0007624891 [system] INFO: Cloud: connecting
0007624919 [system] INFO: Read Server Address = type:1,domain:$id.udp.particle.io
0007624963 [system] INFO: Loaded cloud server address and port from session data
0007625005 [system] INFO: Cloud socket=0, connecting to 3.222.143.118#5684
0007625045 [system] INFO: Cloud socket connected
0007625071 [system] INFO: Starting handshake: presense_announce=0
0007625104 [comm.protocol.handshake] INFO: Establish secure connection
0007625143 [comm.dtls] INFO: session has 0 uses
0007625173 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=0
0007625209 [comm.dtls] INFO: out_ctr 0,1,0,0,0,0,10,254, next_coap_id=a83
0007625246 [comm.dtls] INFO: restored session from persisted session data. next_msg_id=2691
0007625294 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 2
0007626156 [comm.protocol.handshake] INFO: Skipping HELLO message
0007626195 [system] INFO: cloud connected from existing session.
0007626233 [system] INFO: Sending application DESCRIBE
0007626262 [comm.protocol] INFO: Checksum has not changed; not sending application DESCRIBE
0007626309 [system] INFO: Sending subscriptions
0007626334 [comm.protocol] INFO: Checksum has not changed; not sending subscriptions
0007626378 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 4
0007626514 [system] INFO: All handshake messages have been processed
0007626649 [system] INFO: Cloud connected
0009582131 [ncp.rltk.client] INFO: disconnected
0009582137 [net.ifapi] INFO: Netif wl3 link DOWN, profile=NONE
0009582152 [net.rltkncp] ERROR: linkOutput up=1 link_up=0
0009582166 [system.nm] INFO: State changed: IP_CONFIGURED -> IFACE_LINK_UP
0009582184 [hal] INFO: DNS server list changed
0009582195 [hal] INFO: DNS server list changed
0009582210 [system.nm] INFO: State changed: IFACE_LINK_UP -> IFACE_UP
0009582230 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0009582232 [net.lwip_rltk] INFO: is_promisc_enabled
0009582233 [ncp.rltk.client] INFO: disconnected
0009582234 [net.lwip_rltk] INFO: get_eap_phase
0009582240 [wiring] ERROR: recv error = 113
0009585560 [system] ERROR: sock_send returned -1 118
0009585587 [comm.dtls] ERROR: mbedtls_ssl_write() failed: -0x4e
0009585719 [system] ERROR: sock_send returned -1 118
0009585747 [comm.dtls] ERROR: mbedtls_ssl_read() failed: -0x4e
0009585778 [comm.protocol] ERROR: Event loop error 34
0009585804 [system] WARN: Communication loop error, closing cloud socket
0009585842 [system] INFO: Cloud: disconnecting
0009585866 [system] INFO: Cloud: disconnected
0009586541 [ncp.rltk.client] INFO: disconnected
0009587048 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0009587050 [net.lwip_rltk] INFO: is_promisc_enabled
0009587051 [net.lwip_rltk] INFO: get_eap_phase
0009591055 [ncp.rltk.client] INFO: disconnected
0009591763 [net.lwip_rltk] INFO: netif_post_sleep_processing TODO
0009595665 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0009595667 [net.lwip_rltk] INFO: is_promisc_enabled
0009595668 [net.lwip_rltk] INFO: get_eap_phase
0009599573 [net.lwip_rltk] INFO: get_eap_phase
0009599692 [net.lwip_rltk] INFO: get_eap_phase
0009599730 [net.ifapi] INFO: Netif wl3 link UP, profile=Home1
0009599740 [system.nm] INFO: State changed: IFACE_UP -> IFACE_LINK_UP
0009599795 [hal] INFO: DNS server list changed
0009599807 [system.nm] INFO: State changed: IFACE_LINK_UP -> IP_CONFIGURED
0009599826 [system] INFO: Cloud: connecting
0009599849 [system] INFO: Read Server Address = type:1,domain:$id.udp.particle.io
0009599885 [system] INFO: Loaded cloud server address and port from session data
0009599916 [system] INFO: Cloud socket=0, connecting to 3.222.143.118#5684
0009599947 [system] INFO: Cloud socket connected
0009599968 [system] INFO: Starting handshake: presense_announce=0
0009599994 [comm.protocol.handshake] INFO: Establish secure connection
0009600025 [comm.dtls] INFO: session has 0 uses
0009600048 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=0
0009600080 [comm.dtls] INFO: out_ctr 0,1,0,0,0,0,11,80, next_coap_id=ad4
0009600109 [comm.dtls] INFO: restored session from persisted session data. next_msg_id=2772
0009600146 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 2
0009601031 [comm.protocol.handshake] INFO: Skipping HELLO message
0009601063 [system] INFO: cloud connected from existing session.
0009601098 [system] INFO: Sending application DESCRIBE
0009601127 [comm.protocol] INFO: Checksum has not changed; not sending application DESCRIBE
0009601168 [system] INFO: Sending subscriptions
0009601189 [comm.protocol] INFO: Checksum has not changed; not sending subscriptions
0009601230 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 4
0009601364 [system] INFO: All handshake messages have been processed
0009601496 [system] INFO: Cloud connected
0017965074 [ncp.rltk.client] INFO: disconnected
0017965080 [net.ifapi] INFO: Netif wl3 link DOWN, profile=NONE
0017965095 [net.rltkncp] ERROR: linkOutput up=1 link_up=0
0017965111 [system.nm] INFO: State changed: IP_CONFIGURED -> IFACE_LINK_UP
0017965131 [hal] INFO: DNS server list changed
0017965143 [hal] INFO: DNS server list changed
0017965158 [system.nm] INFO: State changed: IFACE_LINK_UP -> IFACE_UP
0017965179 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0017965180 [net.lwip_rltk] INFO: is_promisc_enabled
0017965181 [ncp.rltk.client] INFO: disconnected
0017965183 [net.lwip_rltk] INFO: get_eap_phase
0017965193 [wiring] ERROR: recv error = 113
0017967805 [system] ERROR: sock_send returned -1 118
0017967832 [comm.dtls] ERROR: mbedtls_ssl_write() failed: -0x4e
0017967965 [system] ERROR: sock_send returned -1 118
0017967992 [comm.dtls] ERROR: mbedtls_ssl_read() failed: -0x4e
0017968025 [comm.protocol] ERROR: Event loop error 34
0017968053 [system] WARN: Communication loop error, closing cloud socket
0017968090 [system] INFO: Cloud: disconnecting
0017968114 [system] INFO: Cloud: disconnected
0017969491 [ncp.rltk.client] INFO: disconnected
0017969997 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0017969999 [net.lwip_rltk] INFO: is_promisc_enabled
0017970000 [net.lwip_rltk] INFO: get_eap_phase
0017974004 [ncp.rltk.client] INFO: disconnected
0017974710 [net.lwip_rltk] INFO: netif_post_sleep_processing TODO
0017978612 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0017978614 [net.lwip_rltk] INFO: is_promisc_enabled
0017978615 [net.lwip_rltk] INFO: get_eap_phase
0017982520 [net.lwip_rltk] INFO: get_eap_phase
0017982643 [net.lwip_rltk] INFO: get_eap_phase
0017982665 [net.ifapi] INFO: Netif wl3 link UP, profile=Home1
0017982675 [system.nm] INFO: State changed: IFACE_UP -> IFACE_LINK_UP
0017982717 [hal] INFO: DNS server list changed
0017982730 [system.nm] INFO: State changed: IFACE_LINK_UP -> IP_CONFIGURED
0017982748 [system] INFO: Cloud: connecting
0017982775 [system] INFO: Read Server Address = type:1,domain:$id.udp.particle.io
0017982819 [system] INFO: Loaded cloud server address and port from session data
0017982860 [system] INFO: Cloud socket=0, connecting to 3.222.143.118#5684
0017982899 [system] INFO: Cloud socket connected
0017982924 [system] INFO: Starting handshake: presense_announce=0
0017982957 [comm.protocol.handshake] INFO: Establish secure connection
0017982996 [comm.dtls] INFO: session has 0 uses
0017983026 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=0
0017983061 [comm.dtls] INFO: out_ctr 0,1,0,0,0,0,12,162, next_coap_id=c25
0017983099 [comm.dtls] INFO: restored session from persisted session data. next_msg_id=3109
0017983145 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 2
0017983985 [comm.protocol.handshake] INFO: Skipping HELLO message
0017984022 [system] INFO: cloud connected from existing session.
0017984061 [system] INFO: Sending application DESCRIBE
0017984090 [comm.protocol] INFO: Checksum has not changed; not sending application DESCRIBE
0017984137 [system] INFO: Sending subscriptions
0017984162 [comm.protocol] INFO: Checksum has not changed; not sending subscriptions
0017984206 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 4
0017984341 [system] INFO: All handshake messages have been processed
0017984476 [system] INFO: Cloud connected
0018058015 [ncp.rltk.client] INFO: disconnected
0018058020 [net.ifapi] INFO: Netif wl3 link DOWN, profile=NONE
0018058035 [net.rltkncp] ERROR: linkOutput up=1 link_up=0
0018058050 [system.nm] INFO: State changed: IP_CONFIGURED -> IFACE_LINK_UP
0018058067 [hal] INFO: DNS server list changed
0018058079 [hal] INFO: DNS server list changed
0018058094 [system.nm] INFO: State changed: IFACE_LINK_UP -> IFACE_UP
0018058114 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0018058115 [net.lwip_rltk] INFO: is_promisc_enabled
0018058116 [ncp.rltk.client] INFO: disconnected
0018058118 [net.lwip_rltk] INFO: get_eap_phase
0018058622 [system] ERROR: sock_send returned -1 118
0018058649 [comm.dtls] ERROR: mbedtls_ssl_write() failed: -0x4e
0018058783 [system] ERROR: sock_send returned -1 118
0018058810 [comm.dtls] ERROR: mbedtls_ssl_read() failed: -0x4e
0018058843 [comm.protocol] ERROR: Event loop error 34
0018058872 [system] WARN: Communication loop error, closing cloud socket
0018058909 [system] INFO: Cloud: disconnecting
0018058934 [system] INFO: Cloud: disconnected
0018062426 [ncp.rltk.client] INFO: disconnected
0018062937 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0018062939 [net.lwip_rltk] INFO: is_promisc_enabled
0018062940 [net.lwip_rltk] INFO: get_eap_phase
0018066943 [ncp.rltk.client] INFO: disconnected
0018067650 [net.lwip_rltk] INFO: netif_post_sleep_processing TODO
0018071552 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0018071554 [net.lwip_rltk] INFO: is_promisc_enabled
0018071555 [net.lwip_rltk] INFO: get_eap_phase
0018075459 [net.lwip_rltk] INFO: get_eap_phase
0018075587 [net.lwip_rltk] INFO: get_eap_phase
0018075616 [net.ifapi] INFO: Netif wl3 link UP, profile=Home1
0018075626 [system.nm] INFO: State changed: IFACE_UP -> IFACE_LINK_UP
0018075664 [hal] INFO: DNS server list changed
0018075678 [system.nm] INFO: State changed: IFACE_LINK_UP -> IP_CONFIGURED
0018075696 [system] INFO: Cloud: connecting
0018075721 [system] INFO: Read Server Address = type:1,domain:$id.udp.particle.io
0018075765 [system] INFO: Loaded cloud server address and port from session data
0018075806 [system] INFO: Cloud socket=0, connecting to 3.222.143.118#5684
0018075845 [system] INFO: Cloud socket connected
0018075871 [system] INFO: Starting handshake: presense_announce=0
0018075904 [comm.protocol.handshake] INFO: Establish secure connection
0018075942 [comm.dtls] INFO: session has 0 uses
0018075972 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=0
0018076008 [comm.dtls] INFO: out_ctr 0,1,0,0,0,0,12,169, next_coap_id=c2b
0018076046 [comm.dtls] INFO: restored session from persisted session data. next_msg_id=3115
0018076097 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 2
0018076910 [comm.protocol.handshake] INFO: Skipping HELLO message
0018076945 [system] INFO: cloud connected from existing session.
0018076984 [system] INFO: Sending application DESCRIBE
0018077014 [comm.protocol] INFO: Checksum has not changed; not sending application DESCRIBE
0018077061 [system] INFO: Sending subscriptions
0018077086 [comm.protocol] INFO: Checksum has not changed; not sending subscriptions
0018077132 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 4
0018077268 [system] INFO: All handshake messages have been processed
0018077404 [system] INFO: Cloud connected
0020752959 [ncp.rltk.client] INFO: disconnected
0020752966 [net.ifapi] INFO: Netif wl3 link DOWN, profile=NONE
0020752982 [net.rltkncp] ERROR: linkOutput up=1 link_up=0
0020752998 [system.nm] INFO: State changed: IP_CONFIGURED -> IFACE_LINK_UP
0020753019 [hal] INFO: DNS server list changed
0020753031 [hal] INFO: DNS server list changed
0020753046 [system.nm] INFO: State changed: IFACE_LINK_UP -> IFACE_UP
0020753066 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0020753068 [net.lwip_rltk] INFO: is_promisc_enabled
0020753070 [ncp.rltk.client] INFO: disconnected
0020753071 [net.lwip_rltk] INFO: get_eap_phase
0020753088 [wiring] ERROR: recv error = 113
0020757379 [ncp.rltk.client] INFO: disconnected
0020757886 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0020757888 [net.lwip_rltk] INFO: is_promisc_enabled
0020757889 [net.lwip_rltk] INFO: get_eap_phase
0020760679 [system] ERROR: sock_send returned -1 118
0020760706 [comm.dtls] ERROR: mbedtls_ssl_write() failed: -0x4e
0020760839 [system] ERROR: sock_send returned -1 118
0020760867 [comm.dtls] ERROR: mbedtls_ssl_read() failed: -0x4e
0020760899 [comm.protocol] ERROR: Event loop error 34
0020760927 [system] WARN: Communication loop error, closing cloud socket
0020760965 [system] INFO: Cloud: disconnecting
0020760989 [system] INFO: Cloud: disconnected
0020761893 [ncp.rltk.client] INFO: disconnected
0020762600 [net.lwip_rltk] INFO: netif_post_sleep_processing TODO
0020766502 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0020766504 [net.lwip_rltk] INFO: is_promisc_enabled
0020766505 [net.lwip_rltk] INFO: get_eap_phase
0020770410 [net.lwip_rltk] INFO: get_eap_phase
0020770536 [net.lwip_rltk] INFO: get_eap_phase
0020770574 [net.ifapi] INFO: Netif wl3 link UP, profile=Home1
0020770584 [system.nm] INFO: State changed: IFACE_UP -> IFACE_LINK_UP
0020770618 [hal] INFO: DNS server list changed
0020770632 [system.nm] INFO: State changed: IFACE_LINK_UP -> IP_CONFIGURED
0020770650 [system] INFO: Cloud: connecting
0020770680 [system] INFO: Read Server Address = type:1,domain:$id.udp.particle.io
0020770723 [system] INFO: Loaded cloud server address and port from session data
0020770765 [system] INFO: Cloud socket=0, connecting to 3.222.143.118#5684
0020770803 [system] INFO: Cloud socket connected
0020770828 [system] INFO: Starting handshake: presense_announce=0
0020770861 [comm.protocol.handshake] INFO: Establish secure connection
0020770899 [comm.dtls] INFO: session has 0 uses
0020770929 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=0
0020770965 [comm.dtls] INFO: out_ctr 0,1,0,0,0,0,13,25, next_coap_id=c99
0020771002 [comm.dtls] INFO: restored session from persisted session data. next_msg_id=3225
0020771049 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 2
0020771936 [comm.protocol.handshake] INFO: Skipping HELLO message
0020771972 [system] INFO: cloud connected from existing session.
0020772010 [system] INFO: Sending application DESCRIBE
0020772038 [comm.protocol] INFO: Checksum has not changed; not sending application DESCRIBE
0020772086 [system] INFO: Sending subscriptions
0020772110 [comm.protocol] INFO: Checksum has not changed; not sending subscriptions
0020772154 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 4
0020772370 [system] INFO: All handshake messages have been processed
0020772505 [system] INFO: Cloud connected
0020931905 [ncp.rltk.client] INFO: disconnected
0020931911 [net.ifapi] INFO: Netif wl3 link DOWN, profile=NONE
0020931926 [net.rltkncp] ERROR: linkOutput up=1 link_up=0
0020931940 [system.nm] INFO: State changed: IP_CONFIGURED -> IFACE_LINK_UP
0020931958 [hal] INFO: DNS server list changed
0020931969 [hal] INFO: DNS server list changed
0020931982 [system.nm] INFO: State changed: IFACE_LINK_UP -> IFACE_UP
0020932002 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0020932004 [net.lwip_rltk] INFO: is_promisc_enabled
0020932005 [ncp.rltk.client] INFO: disconnected
0020932006 [net.lwip_rltk] INFO: get_eap_phase
0020936314 [ncp.rltk.client] INFO: disconnected
0020936822 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0020936824 [net.lwip_rltk] INFO: is_promisc_enabled
0020936825 [net.lwip_rltk] INFO: get_eap_phase
0020939970 [system] ERROR: sock_send returned -1 118
0020939997 [comm.dtls] ERROR: mbedtls_ssl_write() failed: -0x4e
0020940131 [system] ERROR: sock_send returned -1 118
0020940158 [comm.dtls] ERROR: mbedtls_ssl_read() failed: -0x4e
0020940190 [comm.protocol] ERROR: Event loop error 34
0020940218 [system] WARN: Communication loop error, closing cloud socket
0020940256 [system] INFO: Cloud: disconnecting
0020940280 [system] INFO: Cloud: disconnected
0020940829 [ncp.rltk.client] INFO: disconnected

One thing you could try is to borrow a Wi-Fi antenna from an Argon and connect it to the Photon 2. Enable it using

BLE.selectAntenna(BleAntennaType::EXTERNAL);

This would help isolate whether the disconnects are occurring because of Wi-Fi signal, or some other cause.

I connected them to an Argon antenna and set external. I am still getting it going offline. I do have several Photons and two Argons on the same wifi with no issues. The Photon 2's are only about 20 feet from the router. Below is the log in case it is different output.

0006247807 [ncp.rltk.client] INFO: disconnected
0006247818 [net.ifapi] INFO: Netif wl3 link DOWN, profile=NONE
0006247833 [net.rltkncp] ERROR: linkOutput up=1 link_up=0
0006247847 [system.nm] INFO: State changed: IP_CONFIGURED -> IFACE_LINK_UP
0006247865 [hal] INFO: DNS server list changed
0006247877 [hal] INFO: DNS server list changed
0006247892 [system.nm] INFO: State changed: IFACE_LINK_UP -> IFACE_UP
0006247913 [ncp.rltk.client] INFO: Try to connect to ssid: Home1
0006247914 [net.lwip_rltk] INFO: is_promisc_enabled
0006247915 [ncp.rltk.client] INFO: disconnected
0006247917 [net.lwip_rltk] INFO: get_eap_phase
0006247936 [wiring] ERROR: recv error = 113
0006249021 [system] ERROR: sock_send returned -1 118
0006249051 [comm.dtls] ERROR: mbedtls_ssl_write() failed: -0x4e
0006249185 [system] ERROR: sock_send returned -1 118
0006249213 [comm.dtls] ERROR: mbedtls_ssl_read() failed: -0x4e
0006249245 [comm.protocol] ERROR: Event loop error 34
0006249273 [system] WARN: Communication loop error, closing cloud socket
0006249310 [system] INFO: Cloud: disconnecting
0006249334 [system] INFO: Cloud: disconnected
0006252224 [ncp.rltk.client] INFO: disconnected

Hi, are you using 5GHz or 2.4GHz WiFi on the Photon2?
I think 5GHz signals are more likely to be weakened or blocked by obstacles like walls, floors, and ceilings than 2.4GHz.

I am using 2.4 Ghz for that reason and I am in a rural area and no other wifi signals in the area.

@jstobaugh is this issue still live?

Yes it is still alive. I am still isolating to the part of the code that fails and am very close. I didn't want to post anything until I was certain it wasn't something in my code that may not be proper.
I have had many issues isolating it because it will at some point fail on OTA programming and Workbench didn't report it had failed. I had to find out by looking at the web console. Once a Photon 2 fails an OTA update the only way to get it back to working is Device Doctor. I have also had one Photon 2 partially brick while in the middle of a local flash from Workbench. I can't recover it with Device Doctor or Device Restore but it still connects to the cloud.
Hopefully tomorrow I will have determined if it is a problem I created or a possible bug.

@marekparticle Here is the code I have isolated that is causing the problems. The first issue is the device will momentarily go offline and then back online. The second issue is after a period of time the Photon 2 will freeze. I am using 5.5.0. I use Workbench and compile OTA and then I have been flashing by USB. I have removed a large portion of the programming so this function isn't doing anything because counter was manipulated by removed code.



#include "math.h"
const int CabFan = D3;
const int CabHeatRelay = D4;
const int SiloRelay = D5;
const int BurnerRelay = D6;
const int AugerRelay = D10;
const int ValueUp = TX;
const int ValueDwn = SCK;
const int NextStepUp = MISO;
const int NextStepDn = RX;
int servoPin = MOSI;
boolean SmokeEn = false;
boolean Stage1Run = false;
boolean Stage2Run = false;
boolean Stage3Run = false;
boolean Stage1ram = false;
float chksum;
float setramStage1Temp;
float setswStage1Temp;
float setramStage1Counter;
float setswStage1Counter;
byte ramstatus;
SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);
unsigned long Stepprevmillis1 = 0;
unsigned long Outtimer1;
unsigned long Outtimer2;
unsigned long steptimer1;
float NextSeq = 11;
unsigned long lastStage1timeCheck;
unsigned long lastBlynkCheck;
bool SwState = LOW;
bool Stepstate = HIGH;
bool swselect;
Servo myservo;
#define Publishinterval 1800000
unsigned int Publishreset2;
unsigned int Publishreset;
int buttonpush1 = 0;
bool writeenable = false;
void setup()
{
  Serial.begin(9600);

  Particle.connect();
  
  pinMode(AugerRelay, OUTPUT);
  pinMode(SiloRelay, OUTPUT);
  pinMode(CabHeatRelay, OUTPUT);
  pinMode(BurnerRelay, OUTPUT);
  pinMode(CabFan, OUTPUT);
  pinMode(ValueUp, INPUT_PULLUP);
  pinMode(ValueDwn, INPUT_PULLUP);
  pinMode(NextStepUp, INPUT_PULLUP);
  pinMode(NextStepDn, INPUT_PULLUP);
  myservo.attach(servoPin);
  digitalWrite(CabHeatRelay, LOW);
  digitalWrite(CabFan, LOW);
  digitalWrite(SiloRelay, LOW);
  digitalWrite(BurnerRelay, LOW);
  EEPROM.get(0, chksum);
  EEPROM.get(4, ramstatus);
  EEPROM.get(8, setramStage1Temp);
  EEPROM.get(16, setramStage1Counter);
  lastBlynkCheck = 0;
  setswStage1Temp = setramStage1Temp;
  setswStage1Counter = setramStage1Counter;
  Publishreset = millis();
  Outtimer2 = millis();
  if (ramstatus == 10)
  {
    Stage1Run = true;
    SmokeEn = true;
  }

}
void loop()
{
 
  CounterStage1swset();

 

}
void CounterStage1swset()
{
  if ((digitalRead(ValueUp) == 0) && (millis() - Outtimer1 >= 200) && (NextSeq == 7))
  {
    (setswStage1Counter = setswStage1Counter + .1);
    if ((setswStage1Counter < 0) || (setswStage1Counter > 25))
    {
      setswStage1Counter = 1;
    }
    Outtimer1 = millis();
  }
  if ((digitalRead(ValueDwn) == 0) && (millis() - Outtimer1 >= 200) && (NextSeq == 7))
  {
    (setswStage1Counter = setswStage1Counter - .1);
    if ((setswStage1Counter < 0) || (setswStage1Counter > 25))
    {
      setswStage1Counter = 1;
    }
    Outtimer1 = millis();
  }
  EEPROM.get(16, setramStage1Counter);
  if ((setramStage1Counter != setswStage1Counter) && (isnan(setramStage1Counter) == false))
  {
    EEPROM.put(16, setswStage1Counter);
  }
}

Hm, this is still a little on the complex side for us to work through. Do you mind cleaning this up just a bit more until it's <100 lines and super easy to follow? Have you identified where the hang occurs in that function?

@rickkas7 any immediate concerns here?

I will continue to work thru it. I don't know where the hang occurs.

@jstobaugh, just a few comments.

The logic is odd. First, since you are adding to the value of setswStage1Counter it will never be less than zero. I believe the rule should be:

if (setswStage1Counter > 25)
  setswStage1Counter = 25;

Similarly,

Can be changed to:

 if (setswStage1Counter < 1)
  setswStage1Counter = 1;

Once thing I noticed is that you call EEPROM.get(16, setramStage1Counter); every time loop runs! The EEPOM on the Photon 2 is actually implemented as a LittleFS file. From what I see, loop() will run every 1ms! I'm not sure if this could be part of the offline problem.

You already have the EEPROM value loaded in the global setramStage1Counter variable so simply maintain the value there and store it back to EEPROM only when it changes, (setramStage1Counter != setswStage1Counter) in your case.

2 Likes

Thanks for the response @peekay123. The counter is a hourly timer controlled in tenths of an hour between 0 and 25 and is programmed with the time using two switches. The valueup switch increases the time by tenths and the valuedwn switch decreases the value by tenths. The code to do that is a separate function that has been removed. The hourly counter value is limited to be between 0 and 25. The EEPROM issue I hadn't thought about when creating it and will change it to your example and see if that fixes the problem. I will let you know if it does fix it.

1 Like

Moving the Get EEPROM to after a change is detected appears to have fixed the wifi going offline. I need to monitor for a day to see if the Photon 2 doesn't crash anymore. Thanks very much for the help. Below is the change I had to do so the EEPROM wasn't constantly loaded.

 if ((setramStage1Counter != setswStage1Counter) && (isnan(setramStage1Counter) == false))
  {
    EEPROM.put(16, setswStage1Counter);
    EEPROM.get(16, setramStage1Counter);
  }
1 Like

@jstobaugh, I'm not sure I understand why you get setramStage1Counter from EEPROM when you already have it loaded for your if() statement.

Maybe there is a different way that I am not doing but without the get statement the EEPROM is never updated when I change the setramStage1Counter manually with the switch. Also the Photon 2 is working properly now with no wifi offline or locking up.

This doesn't quite make sense to me. I would need to see your code to understand what may be causing what you see.

@peekay123 below is the code related to what I am doing with the EEPROM. I use the Blynk app to load the value into the counter and then once started the counter is decremented every .1 hour. The Blynk app starts the counter setting the (Stage1Run == true).

float setramStage1Counter; //EEPROM location
float setswStage1Counter; 
void setup()
{
EEPROM.get(16, setramStage1Counter);
setswStage1Counter = setramStage1Counter;
}

void loop()
{
CounterStage1timer();
CounterStage1swset();
}
void CounterStage1swset()
{
  if ((setramStage1Counter != setswStage1Counter) && (isnan(setramStage1Counter) == false))
  {
    EEPROM.put(16, setswStage1Counter);
    EEPROM.get(16, setramStage1Counter);
  }
}
 
void CounterStage1timer()//decriment counter every .1 hour
{
  if (Stage1Run == true)
  {
    if (setswStage1Counter <= 0)
    {
      Stage2Run = true;
      Stage1Run = false;
      SmokeEn = false;
      Particle.publish("SmokerJim", "Stage 2 started", PRIVATE);
    }
    unsigned long now1 = millis();
    if (now1 - lastStage1timeCheck >= 360000) 
    {
      setswStage1Counter = setswStage1Counter - .1;
      lastStage1timeCheck = millis();
    }
  }
}
BLYNK_WRITE(V24)////Use Blynk app to load value into setswStage1Counter
{
  setswStage1Counter = param.asDouble(); // assigning incoming value from pin V1 to a variable
}

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.