Random power cycle on device

my device likes to do this randomly especially when i write code involving the button
how do i prevent this or at least understand why it is doing it

00040360 [comm.coap] TRACE: Received CoAP message
0000040362 [comm.coap] TRACE: ACK 0.00 size=4 token= id=2341
0000041504 [comm.coap] TRACE: Received CoAP message
0000041505 [comm.coap] TRACE: CON POST /f/setMaxPublishes?1 size=26 token=02 id=35318
0000041507 [comm.coap] TRACE: Sending CoAP message
0000041508 [comm.coap] TRACE: ACK 0.00 size=4 token= id=35318
0000041512 [comm.coap] TRACE: Sending CoAP message
0000041513 [comm.coap] TRACE: CON 2.04 size=10 token=02 id=2342
0000041639 [comm.coap] TRACE: Received CoAP message
0000041640 [comm.coap] TRACE: ACK 0.00 size=4 token= id=2342

Serial connection closed. Attempting to reconnect...
Serial monitor opened successfully:
0000001229 [ModelGauge] INFO: read original OCV: 204, 191
0000001229 [ModelGauge] INFO: verify model access unlocked: success
0000001539 [ModelGauge] INFO: load model successfully
0000001847 [system.nm] INFO: State changed: IFACE_UP -> IFACE_LINK_UP
0000001849 [system.nm] INFO: State changed: IFACE_LINK_UP -> IP_CONFIGURED
0000001851 [net.pppncp] TRACE: Negotiated MTU: 1500
0000001852 [system] INFO: Cloud: connecting
0000001855 [system] INFO: Cloud socket connected
0000001855 [comm.protocol.handshake] INFO: Establish secure connection
0000001857 [comm.dtls] INFO: session has 0 uses
0000001865 [ModelGauge] INFO: model verify success
0000001870 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=0
0000001871 [comm.dtls] INFO: out_ctr 0,1,0,0,0,0,6,139, next_coap_id=926
0000001872 [comm.dtls] INFO: restored session from persisted session data. next_msg_id=2342
0000001873 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 2
0000002929 [hal] TRACE: Cached ESP32 NCP firmware version: 7
0000002942 [comm.protocol.handshake] INFO: Skipping HELLO message
0000002943 [comm.coap] TRACE: Sending CoAP message
0000002944 [comm.coap] TRACE: CON 0.00 size=4 token= id=2343
0000002945 [comm.coap] TRACE: Sending CoAP message
0000002945 [comm.coap] TRACE: CON POST /E/particle/device/updates/enabled size=45 token= id=2344
0000002947 [comm.coap] TRACE: Sending CoAP message
0000002948 [comm.coap] TRACE: CON POST /E/particle/device/updates/forced size=44 token= id=2345
0000002959 [app] INFO: loading config monitoring: {"version":1,"hash":"F93B80A644D2E602AECCFADE6A569CED","monitoring":{"device_monitor":true}}
0000002967 [app] INFO: loading config sleep: {"version":1,"hash":"8E9D079E453B3A2824D69F608677ADBB","sleep":{"mode":"disable","exe_min":10,"conn_max":90}}
0000002976 [app] INFO: loading config tracker: {"version":1,"hash":"F53736A0E3B271B9273988F4273988F4","tracker":{"usb_cmd":true}}
0000003211 [app] INFO: loading config temp_trig: {"version":1,"hash":"43D8B242CC34C6EF56DEB9496EEE66E0","temp_trig":{"high":150.0000000000,"high_en":false,"high_latch":false,"low":-~
0000003271 [app] INFO: loading config location: {"version":1,"hash":"A2727250BC9CE43FE693AC9A66D09E1C","location":{"radius":0.0000000000,"interval_min":900,"interval_max":3600,"min_~
0000003282 [app] INFO: loading config geofence: {"version":1,"hash":"6CE85D94B8F034A46564CED95B216984","geofence":{"interval":0,"zone1":{"enable":false,"lat":44.4980400000,"lon":-80~
0000003294 [app] INFO: loading config imu_trig: {"version":1,"hash":"5E5488D40858A17D5C214BA3319647FD","imu_trig":{"motion":"disable","high_g":"disable"}}
0000003313 [app] INFO: loading config store: {"version":1,"hash":"947DA4BF9A8EE9924B93CD9CD58FB995","store":{"enable":true,"quota":64,"policy":"drop_old"}}
0000003318 [comm.coap] TRACE: Sending CoAP message
0000003318 [comm.coap] TRACE: CON POST /E/particle/device/updates/enabled size=44 token= id=2346
0000003327 [MonitorOne] INFO: Detected a basic IO expansion card with RS-485 and CAN bus
0000003340 [app] INFO: loading config iocal: {"version":1,"hash":"154BDF98910F00EF183A1C98EBA642AC","iocal":{"voltage":{"calgain":1.0000000000,"caloffset":0.0000000000},"current":{"~
0000003350 [app] INFO: loading config io: {"version":1,"hash":"EE0EDB15C5800648C05557D22E0D4860","io":{"voltage":{"sensorlow":0.0000000000,"sensorhigh":10.0000000000,"sensorfc":1.00~
0000003363 [app] INFO: loading config modbus_rs485: {"version":1,"hash":"BA9243CF1B5A788CB96722F7E0376F92","modbus_rs485":{"baud":"38400","parity":"none","imd":0}}
0000003377 [app] INFO: loading config modbus1: {"version":1,"hash":"43545634A2CA558E593C985DD316EA8D","modbus1":{"enable":false,"id":1,"timeout":2000,"poll":1,"publish":"always","fu~
0000003389 [app] INFO: loading config modbus2: {"version":1,"hash":"F2BBB6C396C95369E3001D75E20BDC28","modbus2":{"enable":false,"id":1,"timeout":2000,"poll":1,"publish":"always","fu~
0000003400 [app] INFO: loading config modbus3: {"version":1,"hash":"6F726C637FDF3C89B59D9B622C54B8AD","modbus3":{"enable":false,"id":1,"timeout":2000,"poll":1,"publish":"always","fu~
0000003427 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 4
0000003427 [comm.coap] TRACE: Received CoAP message
0000003428 [comm.coap] TRACE: ACK 0.00 size=4 token= id=2343
0000003450 [comm.coap] TRACE: Received CoAP message
0000003450 [comm.coap] TRACE: ACK 0.00 size=4 token= id=2344
0000003467 [comm.coap] TRACE: Received CoAP message
0000003468 [comm.coap] TRACE: ACK 0.00 size=4 token= id=2346
0000003518 [app] INFO: CAN initialization succeeded
0000003519 [comm.coap] TRACE: Received CoAP message
0000003520 [comm.coap] TRACE: ACK 0.00 size=4 token= id=2345
0000003521 [system] INFO: Cloud connected
0000003527 [comm.protocol] INFO: Checksum has not changed; not sending application DESCRIBE
0000003528 [comm.protocol] INFO: Checksum has not changed; not sending subscriptions
0000004635 [comm.coap] TRACE: Received CoAP message
0000004636 [comm.coap] TRACE: CON POST /E/particle/device/updates/pending size=47 token=01 id=35319
0000004638 [comm.coap] TRACE: Sending CoAP message
0000004639 [comm.coap] TRACE: ACK 0.00 size=4 token= id=35319
0000010008 [comm.coap] TRACE: Sending CoAP message
0000010008 [comm.coap] TRACE: CON POST /e/edge-metric size=356 token= id=2347
0000010012 [app] INFO: Publishing all messages: {"id":5,"lat":0,"lon":0,"data":[{"id":"482","b":["00","00","00","00","00","00","00","00"]},{"id":"682","b":["00","00","00","00","00",~
0000010128 [comm.coap] TRACE: Received CoAP message
0000010128 [comm.coap] TRACE: ACK 0.00 size=4 token= id=2347
0000020008 [comm.coap] TRACE: Sending CoAP message
0000020008 [comm.coap] TRACE: CON POST /e/edge-metric size=356 token= id=2348
0000020012 [app] INFO: Publishing all messages: {"id":5,"lat":0,"lon":0,"data":[{"id":"482","b":["00","00","00","00","00","00","00","00"]},{"id":"682","b":["00","00","00","00","00",~
0000020128 [comm.coap] TRACE: Received CoAP message
0000020129 [comm.coap] TRACE: ACK 0.00 size=4 token= id=2348
0000030008 [comm.coap] TRACE: Sending CoAP message
0000030008 [comm.coap] TRACE: CON POST /e/edge-metric size=356 token= id=2349
0000030013 [app] INFO: Publishing all messages: {"id":5,"lat":0,"lon":0,"data":[{"id":"482","b":["00","00","00","00","00","00","00","00"]},{"id":"682","b":["00","00","00","00","00",~
0000030127 [comm.coap] TRACE: Received CoAP message
0000030128 [comm.coap] TRACE: ACK 0.00 size=4 token= id=2349
0000040008 [comm.coap] TRACE: Sending CoAP message

Which device? Several devices use a double-tap of MODE to power off the device. This can't be turned off, and it's easy to accidentally get a double tap when trying for a triple tap.

Also beware of what you do in the button handler. It can be run at an interrupt context (ISR).

Things you should not do from an ISR:

  • Any memory allocation or free: new, delete, malloc, free, strdup, etc.
  • Any Particle class function like Particle.publish, Particle.subscribe, etc.
  • Most API functions, with the exception of pinSetFast, pinResetFast, and analogRead.
  • delay or other functions that block.
  • Log.info, Log.error, etc.
  • sprintf, Serial.printlnf, etc. with a %f (float) value.
  • attachInterrupt and detachInterrupt cannot be called within the ISR.
  • Mutex locks. This includes SPI transactions and I2C lock and unlock.
  • Start an SPI.transaction with DMA.

It's best to only set a flag from a button handler and handle it from loop. Doing things in the list above may not immediately crash the device, but could cause memory corruption that causes it to fault later.

I definitely put a log.info in there at some point. Any idea how I should proceed?

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