0

There are 5 ESP8266s being used. Three act as a middleman (in AP_STA mode), one sends the message, and the last one receives the message after being passed over the middlemans (imagine it as a line, starting with nr. 1 in STA mode, sending the date to middleman 1. M1 sends it to M2, M2 sends it to M3, M3 sends it to the receiver, set in AP mode).

After like 10 min. of sending a message, one chip always stops. Stops as in, not receiving or sending the message. Every time a message is send, I use the command Client21.flush() (Client21 is just a name).

My idea is that I have to somehow also flush() after recieving a message, not just after sending one. Is there like a "receive buffer" that I can flush(), and how is it possible?

(no code provided)

Update 1: This is what the first middleman (chip no.3) printed in serial monitor when he "crashed":

Exception (29):
epc1=0x4000e1c3 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000018 depc=0x00000000

ctx: sys 
sp: 3fffebc0 end: 3fffffb0 offset: 01a0

stack
3fffed60:  3fffc278 40101fe8 3fffc200 00000000  
3fffed70:  3ffed93c 3fffb374 000000c0 401004e4  
3fffed80:  40000f83 3fffb374 402384b0 401068b0  
3fffed90:  402268ac 00000023 00000000 402268d1  
3fffeda0:  000000c0 4021403b 00000018 3ffed6cc  
3fffedb0:  00000000 00000000 00000020 40100f22  
3fffedc0:  4021881e 4021873c 3ffef80c 40100f22  
3fffedd0:  01004e43 4010000d 3ffee034 4021cb7d  
3fffede0:  00000018 3ffed750 3ffed6cc 00000000  
3fffedf0:  402188df 3ff20a00 3ffef80c 3ffe9be6  
3fffee00:  3ffe9bcc 3fffee90 3fffee90 00000000  
3fffee10:  4c4c4148 3331324f 40102200 3ffe9bcc  
3fffee20:  3ffe9be6 0000002c 00000004 40100518  
3fffee30:  3ffe9bd6 3ffefc74 402154a0 3ff20a00  
3fffee40:  3ffef80c 3fffbfcc 00000015 40215373  
3fffee50:  4000050c 3ffef45c 00000000 4021b377  
3fffee60:  40106afd 00000030 00000011 ffffffff  
3fffee70:  00000000 4bc6a7f0 7645a1ca 00000000  
3fffee80:  00000000 00000000 4bc6a7f0 00000000  
3fffee90:  4020cb8c 3ffe8f84 40106520 00190810  
3fffeea0:  00000000 4bc6a7f0 3ffe8f84 40212cbc  
3fffeeb0:  1cf15308 00000000 00000002 4020bad8  
3fffeec0:  4021d149 ffffffa2 00000000 000001f4  
3fffeed0:  40214baf 3ffe9bcc 3ffecd80 3ffef80c  
3fffeee0:  00000000 3ffe9bd6 3ffe9bf0 3ffeeec4  
3fffeef0:  4020cb8c 00000000 00000000 3ffe9bd6  
3fffef00:  61c78017 000000c3 00000000 3ffefc74  
3fffef10:  3ffe9bc0 00000000 00000002 4022463a  
3fffef20:  3ffecd80 3ffe9bc0 3fffdcc0 3ffe9370  
3fffef30:  3ffe9bdc 3ffefab4 00000040 3ffe9370  
3fffef40:  00000040 3ffecd80 00000000 3ffe85e0  
3fffef50:  40223f17 3fffdab0 00000000 40204ac7  
3fffef60:  3ffe9370 40000f49 3fffdab0 40000f49  
3fffef70:  40000e19 40001878 00000002 00000000  
3fffef80:  3fffff10 aa55aa55 0000008f 40104424  
3fffef90:  4010442a 00000002 00000000 056f21c7  
3fffefa0:  4010000d 31c0f00e 8b4afbe9 f30f0180  
3fffefb0:  00000000 3fffef4c 00000000 3fffff28  
3fffefc0:  3fffffd0 00000000 00000000 feefeffe  
3fffefd0:  feefeffe feefeffe feefeffe feefeffe  
3fffefe0:  feefeffe feefeffe feefeffe feefeffe  
3fffeff0:  feefeffe feefeffe feefeffe feefeffe  
3ffff000:  feefeffe feefeffe feefeffe feefeffe  
3ffff010:  feefeffe feefeffe feefeffe feefeffe  
3ffff020:  feefeffe feefeffe feefeffe feefeffe  
3ffff030:  feefeffe feefeffe feefeffe feefeffe  
3ffff040:  feefeffe feefeffe feefeffe feefeffe  
3ffff050:  feefeffe feefeffe feefeffe feefeffe  
3ffff060:  feefeffe feefeffe feefeffe feefeffe  
3ffff070:  feefeffe feefeffe feefeffe feefeffe  
3ffff080:  feefeffe feefeffe feefeffe feefeffe  
3ffff090:  feefeffe feefeffe feefeffe feefeffe  
3ffff0a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff100:  feefeffe feefeffe feefeffe feefeffe  
3ffff110:  feefeffe feefeffe feefeffe feefeffe  
3ffff120:  feefeffe feefeffe feefeffe feefeffe  
3ffff130:  feefeffe feefeffe feefeffe feefeffe  
3ffff140:  feefeffe feefeffe feefeffe feefeffe  
3ffff150:  feefeffe feefeffe feefeffe feefeffe  
3ffff160:  feefeffe feefeffe feefeffe feefeffe  
3ffff170:  feefeffe feefeffe feefeffe feefeffe  
3ffff180:  feefeffe feefeffe feefeffe feefeffe  
3ffff190:  feefeffe feefeffe feefeffe feefeffe  
3ffff1a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff200:  feefeffe feefeffe feefeffe feefeffe  
3ffff210:  feefeffe feefeffe feefeffe feefeffe  
3ffff220:  feefeffe feefeffe feefeffe feefeffe  
3ffff230:  feefeffe feefeffe feefeffe feefeffe  
3ffff240:  feefeffe feefeffe feefeffe feefeffe  
3ffff250:  feefeffe feefeffe feefeffe feefeffe  
3ffff260:  feefeffe feefeffe feefeffe feefeffe  
3ffff270:  feefeffe feefeffe feefeffe feefeffe  
3ffff280:  feefeffe feefeffe feefeffe feefeffe  
3ffff290:  feefeffe feefeffe feefeffe feefeffe  
3ffff2a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff300:  feefeffe feefeffe feefeffe feefeffe  
3ffff310:  feefeffe feefeffe feefeffe feefeffe  
3ffff320:  feefeffe feefeffe feefeffe feefeffe  
3ffff330:  feefeffe feefeffe feefeffe feefeffe  
3ffff340:  feefeffe feefeffe feefeffe feefeffe  
3ffff350:  feefeffe feefeffe feefeffe feefeffe  
3ffff360:  feefeffe feefeffe feefeffe feefeffe  
3ffff370:  feefeffe feefeffe feefeffe feefeffe  
3ffff380:  feefeffe feefeffe feefeffe feefeffe  
3ffff390:  feefeffe feefeffe feefeffe feefeffe  
3ffff3a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff400:  feefeffe feefeffe feefeffe feefeffe  
3ffff410:  feefeffe feefeffe feefeffe feefeffe  
3ffff420:  feefeffe feefeffe feefeffe feefeffe  
3ffff430:  feefeffe feefeffe feefeffe feefeffe  
3ffff440:  feefeffe feefeffe feefeffe feefeffe  
3ffff450:  feefeffe feefeffe feefeffe feefeffe  
3ffff460:  feefeffe feefeffe feefeffe feefeffe  
3ffff470:  feefeffe feefeffe feefeffe feefeffe  
3ffff480:  feefeffe feefeffe feefeffe feefeffe  
3ffff490:  feefeffe feefeffe feefeffe feefeffe  
3ffff4a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff500:  feefeffe feefeffe feefeffe feefeffe  
3ffff510:  feefeffe feefeffe feefeffe feefeffe  
3ffff520:  feefeffe feefeffe feefeffe feefeffe  
3ffff530:  feefeffe feefeffe feefeffe feefeffe  
3ffff540:  feefeffe feefeffe feefeffe feefeffe  
3ffff550:  feefeffe feefeffe feefeffe feefeffe  
3ffff560:  feefeffe feefeffe feefeffe feefeffe  
3ffff570:  feefeffe feefeffe feefeffe feefeffe  
3ffff580:  feefeffe feefeffe feefeffe feefeffe  
3ffff590:  feefeffe feefeffe feefeffe feefeffe  
3ffff5a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff600:  feefeffe feefeffe feefeffe feefeffe  
3ffff610:  feefeffe feefeffe feefeffe feefeffe  
3ffff620:  feefeffe feefeffe feefeffe feefeffe  
3ffff630:  feefeffe feefeffe feefeffe feefeffe  
3ffff640:  feefeffe feefeffe feefeffe feefeffe  
3ffff650:  feefeffe feefeffe feefeffe feefeffe  
3ffff660:  feefeffe feefeffe feefeffe feefeffe  
3ffff670:  feefeffe feefeffe feefeffe feefeffe  
3ffff680:  feefeffe feefeffe feefeffe feefeffe  
3ffff690:  feefeffe feefeffe feefeffe feefeffe  
3ffff6a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff700:  feefeffe feefeffe feefeffe feefeffe  
3ffff710:  feefeffe feefeffe feefeffe feefeffe  
3ffff720:  feefeffe feefeffe feefeffe feefeffe  
3ffff730:  feefeffe feefeffe feefeffe feefeffe  
3ffff740:  feefeffe feefeffe feefeffe feefeffe  
3ffff750:  feefeffe feefeffe feefeffe feefeffe  
3ffff760:  feefeffe feefeffe feefeffe feefeffe  
3ffff770:  feefeffe feefeffe feefeffe feefeffe  
3ffff780:  feefeffe feefeffe feefeffe feefeffe  
3ffff790:  feefeffe feefeffe feefeffe feefeffe  
3ffff7a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff800:  feefeffe feefeffe feefeffe feefeffe  
3ffff810:  feefeffe feefeffe feefeffe feefeffe  
3ffff820:  feefeffe feefeffe feefeffe feefeffe  
3ffff830:  feefeffe feefeffe feefeffe feefeffe  
3ffff840:  feefeffe feefeffe feefeffe feefeffe  
3ffff850:  feefeffe feefeffe feefeffe feefeffe  
3ffff860:  feefeffe feefeffe feefeffe feefeffe  
3ffff870:  feefeffe feefeffe feefeffe feefeffe  
3ffff880:  feefeffe feefeffe feefeffe feefeffe  
3ffff890:  feefeffe feefeffe feefeffe feefeffe  
3ffff8a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff900:  feefeffe feefeffe feefeffe feefeffe  
3ffff910:  feefeffe feefeffe feefeffe feefeffe  
3ffff920:  feefeffe feefeffe feefeffe feefeffe  
3ffff930:  feefeffe feefeffe feefeffe feefeffe  
3ffff940:  feefeffe feefeffe feefeffe feefeffe  
3ffff950:  feefeffe feefeffe feefeffe feefeffe  
3ffff960:  feefeffe feefeffe feefeffe feefeffe  
3ffff970:  feefeffe feefeffe feefeffe feefeffe  
3ffff980:  feefeffe feefeffe feefeffe feefeffe  
3ffff990:  feefeffe feefeffe feefeffe feefeffe  
3ffff9a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9f0:  feefeffe feefeffe feefeffe feefeffe  
3ffffa00:  feefeffe feefeffe feefeffe feefeffe  
3ffffa10:  feefeffe feefeffe feefeffe feefeffe  
3ffffa20:  feefeffe feefeffe feefeffe feefeffe  
3ffffa30:  feefeffe feefeffe feefeffe feefeffe  
3ffffa40:  feefeffe feefeffe feefeffe feefeffe  
3ffffa50:  feefeffe feefeffe feefeffe feefeffe  
3ffffa60:  feefeffe feefeffe feefeffe feefeffe  
3ffffa70:  feefeffe feefeffe feefeffe feefeffe  
3ffffa80:  feefeffe feefeffe feefeffe feefeffe  
3ffffa90:  feefeffe feefeffe feefeffe feefeffe  
3ffffaa0:  feefeffe feefeffe feefeffe feefeffe  
3ffffab0:  feefeffe feefeffe feefeffe feefeffe  
3ffffac0:  feefeffe feefeffe feefeffe feefeffe  
3ffffad0:  feefeffe feefeffe feefeffe feefeffe  
3ffffae0:  feefeffe feefeffe feefeffe feefeffe  
3ffffaf0:  feefeffe feefeffe feefeffe feefeffe  
3ffffb00:  00000000 00000000 00000020 40100f22  
3ffffb10:  3ffe92f0 40104304 3ffefd44 feefeffe  
3ffffb20:  00000001 40103523 3ffed470 feefeffe  
3ffffb30:  40103986 feefeffe feefeffe feefeffe  
3ffffb40:  feefeffe feefeffe feefeffe feefeffe  
3ffffb50:  4010346a 0000007f 7fffffff 00000000  
3ffffb60:  0000007f feefeffe feefeffe feefeffe  
3ffffb70:  401022eb 00080000 00000020 40100f22  
3ffffb80:  00000000 00000000 00000000 4000050c  
3ffffb90:  3fffc278 40101fe8 3fffc200 00000022  
3ffffba0:  3ffffbb0 00000030 00000008 ffffffff  
3ffffbb0:  00000000 00000000 0000001f 40104bfd  
3ffffbc0:  4000050c 3ffedf28 00000002 00008e88  
3ffffbd0:  40226856 00000030 00000008 ffffffff  
3ffffbe0:  4021744b 00000000 00000001 3ffec950  
3ffffbf0:  00000002 00000000 3fffab2a 00000001  
3ffffc00:  00000003 00020021 00000001 3fff02f8  
3ffffc10:  00000000 00000000 0000001f 40104bfd  
3ffffc20:  4000050c 00ffffff 0000003f 3ffeca10  
3ffffc30:  40000f83 00000030 00000008 ffffffff  
3ffffc40:  4020b372 00000023 3fffdcc0 3fffb452  
3ffffc50:  0000003a 000000f1 000000b9 00000003  
3ffffc60:  00000001 fffffffd 00000001 3ffeee88  
3ffffc70:  00000000 00000000 0000001f 40104bfd  
3ffffc80:  4000050c 00000000 40225077 00000001  
3ffffc90:  40000e86 00000030 0000001f fffffffe  
3ffffca0:  40000e86 00000023 00000002 00000010  
3ffffcb0:  00000010 00000000 3fffdbc0 3ffe93a8  
3ffffcc0:  00000000 3fffc6fc 00000002 00000000  
3ffffcd0:  3ffed440 00000001 00000000 00000030  
3ffffce0:  00000000 3ffed470 20110486 00000000  
3ffffcf0:  ffffffff 3fffc6fc 00000000 3ffefd44  
3ffffd00:  3ffed440 00000001 00000000 00000030  
3ffffd10:  3fffb41c 00000000 00000020 40100f22  
3ffffd20:  3ffe92f0 4020b391 3ffeee88 3ffefc74  
3ffffd30:  3fffb452 0000003a 3ffed470 40100f22  
3ffffd40:  0000000c 00000000 00000020 3ffef2e1  
3ffffd50:  000005e0 00000000 40103125 3ffed470  
3ffffd60:  0000003c 00000000 3fffb452 00000100  
3ffffd70:  0000001c 00000001 4010426a 3ffed470  
3ffffd80:  3ffed440 4010431f 00000000 3ffed094  
3ffffd90:  00000005 00000000 00000020 40100f22  
3ffffda0:  3ffe92f5 4010431f 3ffecd80 40100f22  
3ffffdb0:  40101c3d 3ffecd80 3ffefd44 40100f22  
3ffffdc0:  00000023 61c7d6c4 3ffed750 40101e0e  
3ffffdd0:  3ffe9b70 00000000 00000000 40100f22  
3ffffde0:  00000023 61c7d6c4 4010224e 00000100  
3ffffdf0:  7fffffff 3ffe9b70 3ffe9b70 00000001  
3ffffe00:  00000001 00000040 3ffed750 40101e0e  
3ffffe10:  3ffe9ba0 61c7d6c4 00000000 4000050c  
3ffffe20:  3fffc278 40101fe8 3fffc200 00000022  
3ffffe30:  3ffe9bac 3ffe9ba0 3ffe9ba0 00000001  
3ffffe40:  40204bf3 00000030 00000010 ffffffff  
3ffffe50:  40204bf3 00000001 00000001 00000000  
3ffffe60:  00000000 00000000 00000000 fffffffe  
3ffffe70:  ffffffff 3fffc6fc 00000001 00000064  
3ffffe80:  3ffeebc8 3ffeeb98 3ffeec60 00000030  
3ffffe90:  40204b9b 00000000 3ffeee68 00000000  
3ffffea0:  00000000 00000000 00000000 fffffffe  
3ffffeb0:  ffffffff 3fffc6fc 00000001 00000000  
3ffffec0:  00000000 3fffdad0 3ffeed20 00000030  
3ffffed0:  00000000 00000000 00000001 3ffeed18  
3ffffee0:  00000000 3fffdad0 3ffeed20 00000030  
3ffffef0:  ffffffff 3fffc6fc 00000001 3ffeed18  
3fffff00:  00000000 3fffdad0 3ffeed20 00000030  
3fffff10:  00000000 3fffdad0 3ffeed20 00000030  
3fffff20:  3ffeeb98 3ffeebc8 3fffff60 401006dc  
3fffff30:  3ffeeb98 3ffeec60 40204b0c 40204734  
3fffff40:  4020158e 00000000 3ffeed18 40204f14  
3fffff50:  3ffeeb98 3ffeebc8 3ffeed18 40202b38  
3fffff60:  00000000 00000000 00000000 0106a8c0  
3fffff70:  00000000 00000000 00000000 00000000  
3fffff80:  00000000 3ffeec14 3ffeec60 40202a43  
3fffff90:  40205198 6407a8c0 00000000 3ffeed20  
3fffffa0:  00000000 00000000 00000001 40204b2d  
stack

last failed alloc call: 3FFED93C(192)

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
vbb28d4a3
~ld

Update 2: It isn't only the first middleman (chip no.1) which crashes, now it happened to be the second one (chip no.4)

  • 1
    Are you sure it's not receiving, and not that the whole chip has crashed? What attempts at debugging it have you made? – Majenko Mar 8 '19 at 16:23
  • can you use ESP-NOW instead of wifi? it's a lot faster/more stable for ad-hoc p2p – dandavis Mar 8 '19 at 19:45
  • @dandavis I can't use ESP-NOW, because the project requires more abilities to control the system (I'd like to explain the project but it's way too big already). The chain reaction (sending) works fine for like 20 min. tho which is kinda weird – Zunzulla alagaty Mar 8 '19 at 21:40
  • @Majenko I'll try to hook all up and wait until it "crashes" (takes around 20 min.). Sending info tomorrow – Zunzulla alagaty Mar 8 '19 at 21:42
  • 1
    do you know about github.com/me-no-dev/EspExceptionDecoder ? it will give you the actual line number of your code where the problem occurs. When things go bad for more than 5 mins, it's time to bust it out... – dandavis Mar 9 '19 at 6:33
0

I've swapped through 25 ESP8266-12 chips hoping I just had bad luck when receiving these things. I also tried changing the baud-rate, which resulted into some chips becoming a so called "brick" (don't set the baud-rate to 9600, or else you will have to flash them again). Changing the power supply wasn't helpful too. I tried to see if this was caused by a memory leak, so I included the method ESP.getFreeHeap() and printed the results. They didn't seem suspicious at all.

What I think did the trick was to put a delay(1) at the end of the loop and reduce the time interval of messages being sent from five seconds to one. For now this seems stable and reliable.

Update: I changed the delay(1) to the method yield(). As the ESP8266 runs a lot of utility functions in the background (keeping WiFi connected, managing the TCP/IP stack, and performing other duties) blocking these functions from running can cause the ESP8266 to crash and reset itself. To avoid these mysterious resets, avoid long, blocking loops in your sketch. Blocking loops can be for example sending messages with the TCP/IP.

Still delay(1) also worked for me because delays don't "freeze" the chip completely. There are multiple layers, some which are reachable for us and some which are not (keeping WiFi connected etc.), so delay() has a similar outcome as yield(). You can even find yield() in the delay() method in wiring.c.

void delay(unsigned long ms)
{
    uint32_t start = micros();

    while (ms > 0) {
        yield();                       //<-------
        while ( ms > 0 && (micros() - start) >= 1000) {
            ms--;
            start += 1000;
        }
    }
}

But to set a delay() one needs to know how long it has to be so the duties get finished in time. yield() on the other hand pauses reading the script until the background duties are finished (that doesn't take too long).

Editing your script so that the chip keeps executing the yield() method often enough per run fixed it for me.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.