ESP Clock Needs More Power

[Victor-Chew] is tired of setting clocks. After all, here we are in the 21st century, why do we have to adjust clocks (something we just did for daylight savings time)? That’s why [Victor] came up with ESPClock.

Based on a $2 Ikea analog clock, [Victor] had a few design goals for the project:

  • Automatically set the time from the network
  • Automatically adjust for daylight savings time
  • Not cost much more than a regular clock
  • Run for a year on batteries

The last goal is the only one that remains unmet. Even with a large battery pack, [Victor’s] clock runs out of juice in a week or so. You can see some videos of the clock syncing with network time, below.

It is easy to armchair quarterback, but we think [Victor] should investigate putting the processor in a deep sleep mode for most of the time. That probably means you’d need a button to wake it up for configuration and there might be some other modifications required.

If you want to waste a few more ESP modules, you could try this clock instead.

49 thoughts on “ESP Clock Needs More Power

  1. I’d suggest for power:-
    1. Run an antenna of suitable tuned length re RF & Pin diode rectifier etc
    2. Solar panel face – must be enough light even indoors for topup
    3. Daily windup key – retrograde but cute if yah get the kids to be involved
    4. Have it above the fireplace/woodstove so get the thermoelectric
    5. No thermonuclear (yet) :/

    1. I think that would not be enough juice, if it drains the battery now in one week. Also for this energy harvesting approaches you have to get the power drain way down.
      Let it wake up once a day (when the hour hand touches an index contact you should have anyway) and otherwise the original circuit shall pulse the stepper motor.

      1. I am sure there is an extra timer somewhere that you can program to wake up once a day. Or you could use the stepper contact to increment a value and activate every 3600 seconds. No need for a mechanical contact.

      1. *Cough* Of course the *source* of those photons in daylight is from our Sun which is
        thermonuclear in origin despite its very low efficiency and immense distance from us.

        I wrote about solar indoors getting some trickle from other lights at night as well as
        daylight reflection across the room or direct via windows…

        Solar in terms of panels, their production, conversion, utility etc is NOT intrinsically
        thermonuclear in operation – suggest we be really clear on this so any aggressive
        uneducated rednecks who might randomly read through your posts looking for some
        reason to lash out don’t get manipulated to get on the anti-solar bandwagon making
        up another reason for us to use nuclear fission or worse burn more oil instead of
        using the clean free energy from the Sun :-)

        And sure Ren, based on your logic you can claim fossil fuels are all thermonuclear
        as the light which produced massive plant growth & animal predation over long prehistoric
        periods also came from thermonuclear reactions re Sol but, of course that would be plain
        silly and we don’t want to mislead or carry forth idle prejudice to muddy the waters now do we :P

  2. neat project, but I have a better question:why in the 21st century do we still employ something as out-dated as daylight savings time, given that its costs far outweigh its benefits by pretty much every sensible measure?

      1. @ Carl S.
        Ah well thats cause we saved it in the summer so we don’t need to in the winter :P
        @ Chris P.
        Any really good refs that show precisely well your idea its costs really do outweigh benefits
        & doesn’t it depend on continent size/time zones & whether agri or 9 to 5 type business overlaps,
        yah don’t wanna be caught talking through yer teeth yah hear :D

      1. If there’s one group who shouldn’t mind what a wall clock says, it’s farmers. Given that the animals don’t mind, they can work whatever hours they choose and don’t need the clock to change to tell them that!

        1. Ahem..

          He had a point. Following a 1968 to 1971 trial, when BST was employed all year round northern Scotland saw a net increase in the number of people killed or seriously injured.

          The sun wouldn’t rise fully until 10am in parts of Scotland and the country’s 1,000-or-so dairy farmers, who wake up before 5am, would have to work for hours in the dark. Other farmers and construction workers, who need sunlight to perform their jobs, would end up having to work later into the evening.

          1. I doubt there are 1000 or so dairy farmers in the north of scotland any more and times and tech have changed. It’s about time the experiment was given another go.
            The country is no longer agricultural / outdoor working. We work in offices mostly. It’s ridiculous being light at 6am and dark at 6pm for the majority of people in the UK.

    1. I don’t know really about the costs, but I like the benefits. Having longer daylight in summer after work. In winter it would not do anything good, as would be dark after work anyway, but it is more easy to get up “not so early” and have some daylight in the morning.
      So I am happy with daylight savings time as it is and do not have any problems with the changeover.

    2. Always hated this DST nonsense. My company allows flexible hours, so I do not change time, I just arrive and leave one hour earlier in the winter.
      I can’t believe our lives are still revolving around an 8 hour fixed worked schedule that was invented during the industrial revolution. Time to rethink all this!

  3. I would use a very small microcontroller in deep power down mode most of the time that just powers up a tiny radio board a few times a day to get the exact time from a house computer.

    1. The problem is that you don’t know where’s the clock at… In this project the esp directly control the clock motor and replace all the electronic of the original clock. Thus needing to be awake on each second.

      1. Except it doesn’t – it looks like he’s not cut any tracks on the original mechanism (and indeed suggests that it should still work), so that’ll fight the arduino.

        Also it only ‘know where’s the clock at’ because it’s manually entered when connecting the ESP.

        My comments on the hungriness of the ESP and it’s unsuitabilty for embedded devices don’t need repeating – though the ULP on the ESP32 (8051 or similar?) sounds a sensible addition.

  4. Hmm, I may actually go and replicate this with the ESP32… the ULP should be able to generate the 1-second signals needed to drive the clock without too much power consumption, and the clock could wake up once an hour or so to actually sync to ntp. That should make the battery last for a fairly long time (a year or so?)

    1. You leave the clock drive circuit alone to keep the clock running, because it’ll run for months/years on its own and by and large even cheap clocks will keep time to a few seconds over at least a month. Only interfere when necessary.

      Wake the ESP32 every 24-48 hours and correct the time. Shouldn’t take more than a 556 to do it – one to time how often to wake the ESP32, and one to time how long it stays awake. Virtually zero power draw.

    2. Why do you need to sync once an hour? Once a day would be enough IMHO.

      If you can anticipate when the changes you’re syncing for might occur (you have a fair idea when DST will change) then you could get pretty smart about when you sync, cut it right down to maybe once a week or month, with an “extra” sync or two around the time DST is going to change.

      1. Want to anticipate daylight savings time? Feel free to ask the timezone database. An example listing shows the UT seconds before and after the switches:

        $ zdump -v -c 2016,2018 CET
        CET -9223372036854775808 = NULL
        CET -9223372036854689408 = NULL
        CET Sun Mar 27 00:59:59 2016 UT = Sun Mar 27 01:59:59 2016 CET isdst=0 gmtoff=3600
        CET Sun Mar 27 01:00:00 2016 UT = Sun Mar 27 03:00:00 2016 CEST isdst=1 gmtoff=7200
        CET Sun Oct 30 00:59:59 2016 UT = Sun Oct 30 02:59:59 2016 CEST isdst=1 gmtoff=7200
        CET Sun Oct 30 01:00:00 2016 UT = Sun Oct 30 02:00:00 2016 CET isdst=0 gmtoff=3600
        CET Sun Mar 26 00:59:59 2017 UT = Sun Mar 26 01:59:59 2017 CET isdst=0 gmtoff=3600
        CET Sun Mar 26 01:00:00 2017 UT = Sun Mar 26 03:00:00 2017 CEST isdst=1 gmtoff=7200
        CET Sun Oct 29 00:59:59 2017 UT = Sun Oct 29 02:59:59 2017 CEST isdst=1 gmtoff=7200
        CET Sun Oct 29 01:00:00 2017 UT = Sun Oct 29 02:00:00 2017 CET isdst=0 gmtoff=3600
        CET 9223372036854689407 = NULL
        CET 9223372036854775807 = NULL

        It’s not a terrible amount of stuff to keep in memory, either. It’s when to apply the change (the UT timestamp) and what to change the offset to (the gmtoff field). OP uses google maps timezone api to extract this data for one particular timestamp, which will take more time (another internet query after getting the time) and not hint when it’s necessary to load it again. One could do a reasonable probe into the future to see if DST is likely to change, but finding precisely when would be expensive.

        As for the power consumption, the MCU does indeed waste a lot by busylooping (delay) instead of sleeping, but there’s an electrical culprit as well; the 100ms pulse on the clock coil. The clock circuitry is designed to operate off nominal 1.5V, not 3.3V; driving it with that strong a pulse will dissipate much more power than necessary, including possibly in the clock logic. describes how these motors work. If it’s protected by a diode with a forward drop of 1.6V, for instance, the output is effectively shorted out during the pulse. Drop the pulse voltage using for instance another diode or resistor (it probably doesn’t even need 1V) and shorten the pulse; a look with a memory oscilloscope can show how big pulses the original circuit used.

  5. I’d be starting at what I would consider the obvious – NTP has two effective “modes” – either it’s catching the drift and correcting (in which case continually running wifi and *burning* battery power) or it’s running direct queries (ala ntpdate). If it’s running for the drift and correcting as it goes this is going to mean a lot of power in play.

    A custom script every hour or so, with a flag for “successfully set ntp” so you can keep polling until the clock confirms, that starts up the wifi and polls.

    Sight unseen, and with a nod to the power savings as well.

  6. Need to do a project like this, have all the parts around.
    I’d add a small magnet to the hands(Maybe just seconds and hours) and reed switches behind the clockface so it can detect 12:00 and go from there.
    If it runs off mains and sets via NTP, then it needs to be able to self set up or recover from power loss. The fun of internet connected clock is not having to set them.
    Maybe even add some LEDs around the edges so it can be seen at night and show status?

    1. I don’t think it would be accurate enough – the reed switch would be triggered over an area that was poorly defined and way more than a minute? A hall effect sensor might be precise enough though, any one know if that’s the case?

  7. oh, and for good power savings in a microcontroller, remove the second had from the clock, and then you can “deep sleep” for each 59.9999seconds, wake for 0.0001, and repeat. batteries should last for ever. :-)

    1. @meme
      Yeah that sec tick ain’t useful most of the “time” – ha ha, cept once when the mins tickle :)

      Though !
      If we are talking uP generating pulses for a cheap clock movement then we need the
      1 sec pulses for the plastic geared minute & Hr hand drive, so may as well keep the sec
      hand so we know its moving as there is nothing worse that doubt yer clock actually works
      when waiting for anyone to turn up !

      I’d do a bunch of things like the first poster as a collection and then some more…

      .. implement power scavenging; RF, solar, windup, yeah why not, fun for kids &
      .. run a wire loop through the wall behind the clock & wrap it around the main
      3-phase that runs the water heater and or air con so it will often get tickled AC mains
      so by induction can recharge the lowest quiescent rechargeable cells which of
      course have a long life dry cell low internal discharge cheapie backup
      .. replace electronics driving cheap movement with a uP & a garage door receiver
      so it is the brains to handle min power whilst keeping clock alive. Oh and
      have a hall effect/magnet on hr & min hands as long term feedback eg 12 noon/midnight
      .. have the main pc, home theatre, house security system generate the garage
      door transmit comms each min as a properly coded data sequence so listener (uP/clock)
      can decide if it needs to stop to wait or speed up & when such as daylight savings
      adjust overnight local time when all yer are asleep so visitors don’t get freaked by
      clock speeding or stopping if they are drunk or had a joint or on meds or from tax office

      Simple stuff yeah and why not ?

  8. How about going analog in a way, stick a magnet on the hour hand and use a reed switch on a counter. 2 per day, X number of days between daylight savings, you’ve got date counting. Once the processor wakes after a certain number of counts, it can cut the power to the clock for either 1 hour or 11 hours, depending on if it needs to set the clock forward or back. Then it goes back to sleep and starts counting again.

    1. Slight modification, since daylight savings time comes on at 1am and off at 2am. Or the other way round. So if you set it at 12, you’ll have it being wrong all morning on the change days. I suppose you could just program in the DST yourself, and do it on the right dates, taken from NTP.

    2. You would really like a clock that deliberately stands still for 11h? You should rethink your suggestion. Better give it extra ticks between the seconds. The original electronics gives positive (P) and negative pulses like this:

      for fast advancement you do this (“-“=100ms, n,p are the extra pulses)
      With this pulse scheme it advances 9 times faster. You could do also a higher number, but it has to be odd, due to the positive/negative drive scheme. Do this for 400 seconds (6,67min) and you have advanced 1h without interference with the original drive pulses. You just have to sense them, so you can insert your extra pulses.

  9. For years we Hoosiers were guinea pigs as controls in a very big experiment. We were free of such crap, always -5 GMT. Then we went on DST (Daniels Stupid Time) (the gov) and kids have to go to school in the dark. We are average 1:50 minutes off of the sun.
    DST causes 3 to 5 % MORE energy consumption. So the (public records) data shows.
    Just follow the money. Legistature and Golf.
    We are now on Darklight Spending Time. Burn more coal!

    1. Indiana should be on CST anyway. It’s just that the parts that are too far away from Chicago would rather the convenience of being in the same time zone as customers in EST5EDT.

      Meanwhile, Boston (and east) should be in AST, but they’re in EST5EDT for more-or-less the same reason. Makes winters there miserable.

    1. Hopefully your clock moves :-) and does not stand still
      Of course that is somehow right. But I do not have outlets everywhere I have a clock. e.g above a door. But here we have DCF77 longwave broadcast radio control for clocks and this receivers are really low power.

  10. I’ll admit I didn’t read the whole article, and I don’t know much about the esp, I haven’t gotten one yet, waiting for ones with built in USB that are as easy to use as the Arduino. But it seems leaving the actual timekeeping to the original movement and having the esp completely power down for the majority of the time would be the best way to handle power consumption.

  11. low-hanging-fruit here seems (as suggested in the article) deep-sleep most of the time. Rather than a button, though, you have an electromechanical time keeper there – just have the hands at a particular position close your wakeup circuit.

    Now you’re in deep sleep except for twice a day when you can pick up NTP changes. This may not be a 12x power-consumption reduction, but it ought to be *something* right?

    But yeah, this is me being an armchair quarterback. Apologies. it’s a cool clock.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.