You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • Errata: ...but keep reading... bottom line: output GPIO pins are still driven, even in deep-sleep, and issue was cause by - now fixed - firmware.


    I wonder anyway why to go to a deepsleep and expecting the the pins still to power something... To me, a deep sleep is switching everything possible off but the mechanism to be woken up by some timer...

    Looking at the code it is clear why the LED is only on for that much time:

    • The interval wakes Espruino up and the 'outer' anonymous function executes:
      • LED is switched on
      • Timeout is set for LED to go out
    • Espruino is done with what has to be done in the interval and goes back to deep sleep... which of course switches the LED off.

    What this code and observations say: it takes 3ms for Espruino to setup the timout and to be back in deep sleep ;)

    @Gordon may fix the issue with the timeout waking the thing up again (separate time event replacing the first one and every other event would have to be recalced... time event list could fix that... but such a list may not be there and there is only on time event handled for now). Coming back, I would expected - at best - that the pin state is to be restored(?), even though it makes not much sense - it would light the LED for an other few ms to the point where it is turned off for good.

    Since the LED is drawing power anyway, you might need to go for a different approach: have an external (CMOS) flip flop (built with 4011 quad NAND gates) that is never gona sleep, but is triggered by Espruino with two different, catch-22 cycling timeouts pulsing on two different pins the flip-flop's R and R-, respective. The remaining 2 NANDs you may use in parallel to get the current for the LED... or even parallel one of the flip-flop's NAND - to tripple it to get enought current. The CMOS 4011 is living on a very frugal budget - and with Espruino in deep sleep practically all the time, it is just the LEDs 50% duty-cycle that runs the battery down.

    Looking at a datasheet, you get about 1..1.5mA from that: Not a bright LED. Adding a (Darlington) transistor will give you the current you need...

    Said so - Darlington - you may get away just with that: every 10 seconds you give a pulse for some time to charge a capacitor that then feeds the Darlington for 5 seconds LED-on time... This saves you a pint AND a 4011. The LED is though not that steady... it fades (I have a cheap digital multi-meter that works like this. A button press charges the capacitor, then the backlight is on steady for few seconds, before it begins to fade and go out completely).

    Nice 'problem' solving challenge!

About

Avatar for allObjects @allObjects started