How can Serial.print stop working but the program is still running?

I have a program to control certain lights and it write to "thingspeak. com" to tell me what it does, well today all day, no matter what I try, it will work and send data but after 20 minutes, it varies, I stop getting any messages from the device, a nodemcu esp8266.

I'm happy to post all the code but maybe this is a familiar phenomenon. I have never seen this in over 4 years of playing with these things.

Thanks as always!!

Thoughts and prayers.

Please read and follow the directions in the "How to use the forum" post.

jremington:
Please read and follow the directions in the "How to use the forum" post.

a bit harsh as OP said he could post the code but was more interested at first to know if this is a common issue

To OP’s question, no this is not something I’ve seen in years playing with arduino and esp, so likely something fishy happening in your code or hardware.

Could be the PC/Mac driver loosing the USB connection after a while (driver bug, poor usb cable?) or USB-port can not provide sufficient current. Check your computer’s console to see if the port drops

a bit harsh as OP said he could post the code but was more interested at first to know if this is a common issue

I've noticed that since day one, some sort of reflexive read the instructions advice. Now, given the fact that this is still going on, clearly posts saying read the instructions are not effective at stopping people from posting questions that will end with a post saying read the instructions. This behavior probably drive a lot of people away and it certainly isn't very effective.

As to what you said, on a Mac, does one just look at system report in about this Mac to see if the port has dropped? On that I see the Seagate external drive and something called a CP1202 USB to Bridge Controller from Silicon Labs. Not sure it that is the ESP device or not.

Also, I commented out everything except for one loop that simply writes the following two items to Serial.monitor every second.

05:14:21.601 -> ###mainloop is alive now
05:14:21.601 -> millis()= 848793

It stopped after 14 minutes. So now in a program that does nothing but write to the monitor, nothing is happening. That's weird.

well - in the general case we tell newcomers (this is usually their first post) to read the instructions as their post lacks the bare minimum to get some help. Your statement was clearer (but still source code and wiring diagram is always good to have)

on a Mac you could look at the Console (in /Applications/Utilities) and see if anything fishy is happening to the CP1202 driver

Not sure which driver you've got. On my Mac I'm using the drivers from mac-usb-serial.com for PL-2303, CH341 and CP2102 USB to Serial devices. Their drivers for Catalina and Mojave are notarized.

From their web site it seems they have a promotion on Sunday:

Sunday, we offer a special discount of 42%. Buy the driver for €6.90 instead of €11.98!

I don't recognize much in console but this was diagnostic reports and had the word Arduino so I copied it here.

Date/Time:        2020-09-25 04:11:58 -0500
End time:         2020-09-25 04:13:15 -0500
OS Version:       Mac OS X 10.15.6 (Build 19G2021)
Architecture:     x86_64
Report Version:   29
Incident Identifier: 1C8FA6D1-AF92-46FC-BD31-ED30806CE491

Data Source:      Microstackshots
Shared Cache:     0x4728000 6E6DE4C5-D633-309A-9801-8DA3570938A8

Command:          Arduino
Path:             /Users/USER/Desktop/*/Arduino-2.app/Contents/MacOS/Arduino
Version:          ??? (???)
PID:              522

Event:            wakeups
Action taken:     none
Wakeups:          45001 wakeups over the last 77 seconds (587 wakeups per second average), exceeding limit of 150 wakeups per second over 300 seconds
Wakeups limit:    45000
Limit duration:   300s
Wakeups caused:   45001
Wakeups duration: 77s
Duration:         76.73s
Duration Sampled: 29.33s
Steps:            6

Hardware model:   MacPro6,1
Active cpus:      12

Fan speed:        790 rpm

Heaviest stack for the target process:
  4  ??? [0x118be729c]
  4  ??? [0x1194a5fe8]
  4  Java_jssc_SerialNativeInterface_waitEvents + 142 (libjSSC-2.8_x86_64.jnilib + 5870) [0x161cbe6ee]
  4  __ioctl + 10 (libsystem_kernel.dylib + 17246) [0x7fff6bb5135e]


Powerstats for:   Arduino [522]
UUID:             BB530F2A-4771-3AC1-B1A3-10797B850005
Path:             /Users/USER/Desktop/*/Arduino-2.app/Contents/MacOS/Arduino
Architecture:     x86_64
Footprint:        393.14 MB -> 413.51 MB (+20.37 MB)
Pageins:          12 pages
Start time:       2020-09-25 04:12:43 -0500
End time:         2020-09-25 04:13:13 -0500
Num samples:      6 (100%)
CPU Time:         1.349s
Primary state:    5 samples Frontmost App, Non-Suppressed, Kernel mode, Effective Thread QoS Default, Requested Thread QoS Default, Override Thread QoS Unspecified
User Activity:    0 samples Idle, 6 samples Active
Power Source:     0 samples on Battery, 6 samples on AC
  4  ??? [0x118be729c]
    4  ??? [0x1194a5fe8]
      4  Java_jssc_SerialNativeInterface_waitEvents + 142 (libjSSC-2.8_x86_64.jnilib + 5870) [0x161cbe6ee]
        4  __ioctl + 10 (libsystem_kernel.dylib + 17246) [0x7fff6bb5135e]
  2  thread_start + 15 (libsystem_pthread.dylib + 7051) [0x7fff6bc10b8b]
    2  _pthread_start + 148 (libsystem_pthread.dylib + 24841) [0x7fff6bc15109]
      2  java_start(Thread*) + 250 (libjvm.dylib + 4552803) [0x10fbc8863]
        1  JavaThread::run() + 409 (libjvm.dylib + 5390927) [0x10fc9524f]
          1  JavaThread::thread_main_inner() + 130 (libjvm.dylib + 5391242) [0x10fc9538a]
            1  thread_entry(JavaThread*, Thread*) + 120 (libjvm.dylib + 3218825) [0x10fa82d89]
              1  JavaCalls::call_virtual(JavaValue*, Handle, KlassHandle, Symbol*, Symbol*, Thread*) + 87 (libjvm.dylib + 2888535) [0x10fa32357]
                1  JavaCalls::call_virtual(JavaValue*, KlassHandle, Symbol*, Symbol*, JavaCallArguments*, Thread*) + 325 (libjvm.dylib + 2888059) [0x10fa3217b]
                  1  JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*) + 1681 (libjvm.dylib + 2892591) [0x10fa3332f]
                    1  ??? [0x1188624e7]
                      1  ??? [0x11989c77c]
                        1  ??? [0x1199f22aa]
                          1  Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer + 583 (libawt_lwawt.dylib + 243535) [0x113dd374f]
                            1  OGLRenderer_FillRect + 49 (libawt_lwawt.dylib + 248409) [0x113dd4a59]
                              1  OGLRenderQueue_CheckPreviousOp + 244 (libawt_lwawt.dylib + 246612) [0x113dd4354]
                                1  glBegin_Exec + 126 (GLEngine + 109877) [0x7fff3c43cd35]
                                  1  gleDoDrawDispatchCore + 693 (GLEngine + 933827) [0x7fff3c505fc3]
                                    1  gldUpdateDispatch + 2682 (AMDRadeonX4000GLDriver + 6195) [0x11470c833]
                                      1  glrATI_SI_UpdateHardwareState + 727 (AMDRadeonX4000GLDriver + 27441) [0x114711b31]
                                        1  glrATI_SI_ValidatePipelinePrograms + 3630 (AMDRadeonX4000GLDriver + 394231) [0x11476b3f7]
                                          1  glrATI_SI_LoadHwVertexShader + 42 (AMDRadeonX4000GLDriver + 85302) [0x11471fd36]
                                            1  glrATI_SI_LoadHwShaderCommon + 187 (AMDRadeonX4000GLDriver + 403330) [0x11476d782]
                                              1  <User mode>
        1  WatcherThread::run() + 71 (libjvm.dylib + 5387983) [0x10fc946cf]
          1  WatcherThread::sleep() const + 110 (libjvm.dylib + 5387788) [0x10fc9460c]
            1  Monitor::wait(bool, long, bool) + 121 (libjvm.dylib + 4416981) [0x10fba75d5]
              1  Monitor::IWait(Thread*, long) + 165 (libjvm.dylib + 4415783) [0x10fba7127]
                1  os::PlatformEvent::park(long) + 364 (libjvm.dylib + 4560996) [0x10fbca864]
                  1  __psynch_cvwait + 10 (libsystem_kernel.dylib + 14466) [0x7fff6bb50882]

  Binary Images:
           0x10db0c000 -                ???  Arduino                                          <BB530F2A-4771-3AC1-B1A3-10797B850005>  /Users/USER/Desktop/*/Arduino-2.app/Contents/MacOS/Arduino
           0x10f771000 -        0x10fd7dfff  libjvm.dylib (0)                                 <2C8E9CBD-4DC4-350F-A6DD-A28F275D7D17>  /Users/USER/*/Arduino-2.app/Contents/PlugIns/jre8u252-b09.jre/Contents/Home/lib/server/libjvm.dylib
           0x113d98000 -        0x113df3fff  libawt_lwawt.dylib (0)                           <E02595F7-77CF-31D6-AB93-A938A18A7666>  /Users/USER/*/Arduino-2.app/Contents/PlugIns/jre8u252-b09.jre/Contents/Home/lib/libawt_lwawt.dylib
           0x11470b000 -        0x1147d1fff  com.apple.AMDRadeonX4000GLDriver 3.10.16 (3.1.0) <E4C5C939-F1C3-3982-8DE0-058F92EFB948>  /System/Library/Extensions/AMDRadeonX4000GLDriver.bundle/Contents/MacOS/AMDRadeonX4000GLDriver
           0x161cbd000 -        0x161cbefff  libjSSC-2.8_x86_64.jnilib (0)                    <42816ADC-83A4-F3FF-6E2F-422A583B0174>  /Users/USER/*/libjSSC-2.8_x86_64.jnilib
        0x7fff3c422000 -     0x7fff3c59bfff  GLEngine (17.10.22)                              <B902FF53-A960-3137-99BD-1F9774F9586C>  /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine
        0x7fff6bb4d000 -     0x7fff6bb79fff  libsystem_kernel.dylib (6153.141.1)              <2B6311E6-6240-3EF7-8C87-475B66F7452C>  /usr/lib/system/libsystem_kernel.dylib
        0x7fff6bc0f000 -     0x7fff6bc19fff  libsystem_pthread.dylib (416.100.3)              <62CB1A98-0B8F-31E7-A02B-A1139927F61D>  /usr/lib/system/libsystem_pthread.dylib

How do you know Serial.print stop working but the program is still running?
An idea may be monitoring TX pin. If you have other usb to uart adapter (or scopemeter/logic analyzer), pick the TX pin and see when or if your program really stop talking.

some sort of reflexive read the instructions advice.

Experienced forum members waste less time that way. If the OP won't cooperate, ignore them.

Good luck with your project!

How do you know Serial.print stop working but the program is still running

.

Because the program has a webserver part that still operates.