Get Months of Battery Life from an ESP8266!

Поділитися
Вставка
  • Опубліковано 29 вер 2024
  • EDIT: By using ESP.deepSleep(time to sleep or 0); rather than
    ESP.deepSleep(time to sleep, WAKE_RF_DEFAULT); the power usage is even lower, like 0.02mA or 22uA!!! The Arduino sketch has been updated to reflect is change.
    By putting an ESP8266 into deep sleep mode you can get months (if not years) of battery life on a single charge. In this video I go through how to do this and show you guys all a cool program to send push notifications to your phone at the same time!
    Links to the schematics for both regular deep sleep mode as well as internal interrupt based deep sleep
    Button Deep Sleep: github.com/ItK...
    Internal Interrupt Deep Sleep: github.com/ItK...
    Link to Arduino Sketch:
    gist.github.co...
    Links to the libraries used in this video:
    ESPHelper: github.com/ItK...
    EspProwl: github.com/mar...
    WiFiUdp: github.com/esp...
    Metro: github.com/tho...
    TimeLib: github.com/Pau...
    Support the It Kinda Works Patreon (And help keep IKW going!!!): / itkindaworks
    Subscribe for more weekly videos!
    Follow me on Twitter @itkindaworksinc
    My site with even more tutorials is itkindaworks.com!
  • Наука та технологія

КОМЕНТАРІ • 97

  • @ItKindaWorks
    @ItKindaWorks  6 років тому

    Got a question or something to add to this video? Or even an idea for a new tutorial/video that you'd like to see? Check out the IKW forums at itkindaworks.com/forum/

  • @dosgos
    @dosgos 7 років тому +2

    Didn't know deep sleep mode required such tweaking for max battery life. Thanks for this helpful vido

  • @thomasvnl
    @thomasvnl 7 років тому +21

    Removing the LED should help some more, because 0.77mA is still a lot

    • @ItKindaWorks
      @ItKindaWorks  7 років тому +3

      y'know I actually did that to test it out. If you look closely, the ESP that had the deep sleep on a timer is missing its red LED. That little red led only draws about .1mA. It dropped it from .77 to around .65 if I remember correctly. Enough to make a difference but given it didn't make a giant difference and having something to indicate power is present is nice, I figure .1mA is worth it.

    • @thomasvnl
      @thomasvnl 7 років тому

      Oh sorry, had not noticed it. On a battery, if you can save a little, even if it's only 0.1mA, you do it. It sounds like a little, but it's roughly 14% of it's usage in deep sleep, just indicating that it's using battery power (because it does not imply that your device works). In my opinion it's better to have a temporary indication that the device is working instead.

    • @ItKindaWorks
      @ItKindaWorks  7 років тому +1

      Eh, I'm more than happy to have the little red led on all the time and have slightly less battery but to each his own. Obviously if I were going crazy I'd probably opt for a non-ESP based project or do even more tweaking to suck as much juice out of the battery as possible but thats just not the way I roll :)

    • @thomasvnl
      @thomasvnl 7 років тому +2

      ItKindaWorks haha, well like you say to each his own way of working. I have been able to run an esp with a few sensors for about 4 months on a single 3000mAh li-ion battery, with the unit waking up every 15 minutes so you can get quite some battery life out of these cheap chips!

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      Fair enough, fair enough :)

  • @sats4eva81
    @sats4eva81 6 років тому

    Hey thanks for the great video. I have a question on the esp8266. I am trying to use this as a door sensor where it will tell me when the door opens and closes based on a reed switch. I also want it to go to deep sleep just after it sends the MQTT message for close state. I’m confused about the GPIO0 connection. If i connect the GPIO to ground, can i not send this pin to go low which means close and high when open? So i have my reed switch connected to GPIO0 and ground. Then i have a jumper between VCC and CHPD. Am i doing something wrong? My code basically set pin 0 to digital read ? Let me know if you can help...great video btw..thanks

  • @upendrachaudhari4635
    @upendrachaudhari4635 5 років тому +3

    in my project i have powered esp8266-01 with 3.3v output of pir motion sensor HC-SR501 with triggering time of 18 seconds. In this way only PIR needs to powered through 4x1.5v 6v battery with power consumption of 0.05mA in idle state, so instead of powering 2 devices (esp + pir)with battery, only 1 is powered which greatly reduces battery consumption.
    Your project was a great inspiration for my project! Thanks alot :)

  • @tforgo
    @tforgo 7 років тому +6

    You can use few transistors to create soft latch circuit. This would eliminate need for deep sleep waste of energy. Your battery will last for years since its zero current while offline. Guy with sweedish accent did it with relay. Take a look at his video.

    • @Pacemaker476
      @Pacemaker476 7 років тому +1

      Do you have a link to this video? Please provide if you can thx.

    • @tforgo
      @tforgo 7 років тому

      I can't find that specific video. google soft latch circuit, it can be done with few transistors, and if you have any esp8266 project than can be started with external trigger like pushbutton magnetic reed switch etc this is perfec solution as it's zero power consumption while it is a sleep. instead of using deepsleep command you will short transistor of latch circuit collapsing power until external pushbutton is pressed again.

    • @cymeriandesigns
      @cymeriandesigns 6 років тому +2

      For anyone else encountering this, I think it's the guy with the Swiss accent, Andreas Speiss. The video is about a mod to the Amazon Dash button. I think he used a single mosfet. I myself did something similar to that except I used a pair of bipolar transistors. One transistor turns on when the switch is closed, and the other transistor is used by the esp8266 to keep the current flowing once it starts. My switch will get opened before the processor is done with making a notification, so I needed a way for the ESP8266 to keep itself powered until it was done. This is for a mailbox notification system and the batteries have lasted 18 months so far.

  • @c0r0y
    @c0r0y 6 років тому +1

    Why is the ESP needed to be in Deep Sleep if nothing happens until an event e.g. postbox is opened (=switch is pressed)? Isn´t it possible to activate it by pressing, then it runs its code and then is completely shut down again till the next event.

  • @alexandruconstantinsirbu4697

    how did you enable deep sleep on it? I see online tutorials with people soldering some pin to the miniscule chip pin?

  • @G6EJD
    @G6EJD 7 років тому +3

    184-days using a 3400mAHr and load of 0.77mA

    • @sagitario26XD
      @sagitario26XD 6 років тому +1

      0.77 is a lot for deep sleep, i read than this is for the LED, if you remove this, you can get the 20uA of the datasheet

    • @dh2081
      @dh2081 3 роки тому

      @@sagitario26XD it can even run with less power than that you can have a relay which holds the power on for a few sec via a gpio when the mailbox opens and push a button that powers on the device

  • @quoit99training83
    @quoit99training83 7 років тому +4

    Finally, a simple explanation of deep sleep mode!

  • @richierich3135
    @richierich3135 3 роки тому

    battery 3.7 and esp high limit 3.5 ???

  • @tfujdiler
    @tfujdiler 3 роки тому

    very nice video but where is subtitels :)

  • @marekmatej5971
    @marekmatej5971 3 роки тому

    expression defined in MINUTES and HOUR should be in the parentheses, otherwise you can possibly end up solving lots of mysteries :)

  • @mdijkens
    @mdijkens 6 років тому

    You can go way and way lower: ua-cam.com/video/6SdyImetbp8/v-deo.html
    I have a sensor running in my boat during the winter months that only uses 20uA in deep sleep

  • @JuliusLedoux
    @JuliusLedoux 7 років тому

    Hi There, Great video! One question, is the schematic described here: github.com/ItKindaWorks/Bits-Pieces/blob/master/ESP-01_deepSleep.png correct? It seems to me that the black wire on the left side of the button should go to ground.... Thanks!

  • @Pacemaker476
    @Pacemaker476 7 років тому +1

    I have tried for days to get this to work. I get a different error message each time I attempt to compile depending on what version of the arduino version I use. Please share what version you used. Thx

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      I currently use arduino 1.8.1. Make sure that you have all of the libraries needed for the program installed. ESPHelper requires both Metro and pubsubclient (links for those can be found on the ESPHelper github page).

    • @Pacemaker476
      @Pacemaker476 7 років тому

      Thanks for the reply. I have all of the libraries sorted out and am using 1.8.1. One constant is still present. This error message: netInfo homeNet = {.name = "NETWORK NICKNAME", .mqtt = "YOUR MQTT-IP", .ssid = "Linkin32", .pass = "0000test0000"}; ^exit status''netInfo' has no non-static data member named 'name'I Have about 10 uses for this program so If a donation is required for you to help me out I am good with that. Greg prime.greg@gmail.com

  • @jayare7750
    @jayare7750 5 років тому

    In a door sensor sort of use, is there a way to, instead of deep sleep use a completely off state? and have an external trigger power it back on long enough to transmit the status of a reed switch. And then power itself back off until another external event?

  • @kevinchen4375
    @kevinchen4375 7 років тому +1

    without any led esp-07s is a good choice.

  • @Des0war0ich0netAgentNoMiss
    @Des0war0ich0netAgentNoMiss 4 роки тому

    The ESP.deepSleep() function takes the time in micro seconds not miliseconds.
    e.g. sending the Board to deepsleep for 60sec the function looks like this:
    ESP.deepSleep(60L * 1L * 1000000) Or ESP.deepSleep(60000000)

    • @ItKindaWorks
      @ItKindaWorks  4 роки тому

      Oh sheet you right. Gotta love those powers of ten!

  • @svendragonion6792
    @svendragonion6792 7 років тому

    With a little more hardware, it's even more economical: ua-cam.com/video/-HtSMk6jyEo/v-deo.html

  • @mrteausaable
    @mrteausaable 5 років тому

    Why no Android push notification? Why use Prowlapp that only works for IOS and not even free? Also why need timeserver? Does the Prowlapp do not have timestamp when message arrive?

    • @darktherapy
      @darktherapy 5 років тому

      Mr. T Prowl does have its own time stamp when receiving notifications. But adding your own doesn’t hurt, especially if you’re in a different time zone, the notification will include local and remote times if needed.

  • @joshthynne6866
    @joshthynne6866 4 роки тому

    Is there a way to program it so it sleeps in the day and wakes at night?

  • @beanedtown
    @beanedtown 7 років тому

    You don't need a pop filter. You need to learn how to speak towards your microphone properly. You put it to the side, not directly in front of your mouth.

    • @ItKindaWorks
      @ItKindaWorks  7 років тому +1

      Thank you for telling me what I need to learn... Or I already had roughly proper placement and just needed a pop filter to finish the job.

  • @dand8282
    @dand8282 7 років тому

    Fun Fact: the ESP-01S (note the "S") model doesn't need the stupid jumper from VCC to CHPD

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      Good to know! It must be a fairly new model as I haven't seen it anywhere before

  • @0miker0
    @0miker0 7 років тому

    Strange question here: what software are you using to view and edit the code?

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      Not strange at all! It's called sublime text. It's not free but they do have a trial version that I believe is full featured and doesn't expire (it just every once in a while gives you a little pop-up asking to buy it but it's like once a day so it's really not a bother).

  • @jalbarracin
    @jalbarracin 6 років тому

    You can remove the LED and get extra juice

  • @alessiosaggiomo8348
    @alessiosaggiomo8348 6 років тому

    Hi, I tried a deepsleep on a Nodemcu (I wired the pin D0 (GPIO16) with RST pin) but when i check with the voltmeter i saw 80.5 in normal mode and 10.1 in deepsleep mode even if i write the function without WAKE_RF_DEFAULT parameter.
    Why?

    • @ItKindaWorks
      @ItKindaWorks  6 років тому

      My guess would be that the NodeMCU draws more power for the usb chip and other peripherals than a stand-alone ESP module. This is going to be especially true if you are using the onboard voltage regulator which usually is an AMS1117 which is not known to be power efficient.

    • @alessiosaggiomo8348
      @alessiosaggiomo8348 6 років тому

      ItKindaWorks ok thanks! And you don't know how i solve this? Is there another type of board that draws less power? I would wire an e-ink screen that I want to refresh remotely and use all with battery because I must put this on a wall where I don'have electric power.

    • @ItKindaWorks
      @ItKindaWorks  6 років тому

      For minimal power usage I would use an ESP-01 (shown in this video) or an ESP-07 or ESP-12 which have more pins exposed but can be hard to work with.

    • @alessiosaggiomo8348
      @alessiosaggiomo8348 6 років тому

      yes, i agree with you about esp8266 but i don't know how i could wire it with an e-ink display. Do you have an idea? the display is this
      www.waveshare.com/4.2inch-e-paper-module.htm
      Thank you very much

  • @MPElectronique
    @MPElectronique 7 років тому

    72 ma from the esp8266 ? i is way too much :(

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      I completely agree - That is the power usage before deep sleep. After deep sleep it is closer to .72ma and if you read the updated description I got it far lower than that by tweaking some of the code.

  • @tforgo
    @tforgo 7 років тому

    How its passible to run esp8266 directly of 4.2V?

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      You can do it. I've done it for a while but now that I have some nice LDO regulators I tend to just use those.

    • @jayherde0
      @jayherde0 6 років тому

      Try putting a diode between power and the board.

    • @johncongerton7046
      @johncongerton7046 6 років тому

      Better not to. HT7333A 3.3V regulator will get you there

  • @frightrisk7407
    @frightrisk7407 6 років тому

    I am assuming I can't use a regular ESP8266 for this to come out of sleep because I don't have access to GPIO 16?

    • @ItKindaWorks
      @ItKindaWorks  6 років тому +1

      It's definitely possible to use deep sleep on an ESP8266-01 if you dont need to do a timed sleep (ie using an external interrupt like a button) by connecting reset to gnd. Even a timed sleep can be managed however it will require some precise soldering work. www.instructables.com/id/Enable-DeepSleep-on-an-ESP8266-01/

    • @frightrisk7407
      @frightrisk7407 6 років тому

      Thanks. I'll have to think it through. I am making a mouse trap that notifies me when it trips. So I did want timed sleep, but perhaps I could wire something that closes a switch when the trap closes. But that happens fast if I want a momentary close and not sure how to do that, or I could have a full close just by having 2 contacts on the jaws of the trap. But that means the switch is closed until the trap is open.

    • @frightrisk7407
      @frightrisk7407 6 років тому

      And there is this. www.instructables.com/id/ESP8266-01-Building-Blocks-Unleash-2-Bonus-GPIO-Pi/ This will give me 2 more I/O pins, but I assume one of them is not 16. Is there a way to map pin 16 to TX or RX?

  • @motiondetection4597
    @motiondetection4597 6 років тому

    thanks this is great work. how do you add in an mqtt username and password?

    • @ItKindaWorks
      @ItKindaWorks  6 років тому

      Thanks! This video should help you out with mqtt usernames/passwords ua-cam.com/video/0wnnMWkn5Hs/v-deo.html

  • @aakash512
    @aakash512 5 років тому

    Hey, which editor are you using?

    • @ItKindaWorks
      @ItKindaWorks  5 років тому

      Sublime Text - it's my go-to editor

  • @kevinchen4375
    @kevinchen4375 7 років тому

    esp-07 or esp-12 is much better for deep-sleep application.

    • @ItKindaWorks
      @ItKindaWorks  7 років тому +1

      oops misread that as a question. Eh theres really no difference between an 01 and 7/12 other than the exposed pin 16 for timed deep sleep. Other than that there isnt any power draw different that I've measured.

    • @kevinchen4375
      @kevinchen4375 7 років тому

      pin16 is one reason, and by using esp-07 or esp-12 there is no need to remove the led manually when you use esp-01.

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      I guess thats true but I like the power LED personally. Others here may differ in opinion I suppose. Also at least my 07 models still have the power LED. The 12s dont.

  • @respaceits2283
    @respaceits2283 6 років тому

    Great video. I have a question on when the mailbox closes in your example. I can successfully get the mqtt message to show when it opened and the time however it doesn’t show me when a device closes. Ie I changed the messaging to tell me when a door opens but it doesn’t tell me the door is now closed. Is there a way to address this?

    • @ItKindaWorks
      @ItKindaWorks  6 років тому

      The reason that this is happening is because the ESP is just being "woken up" by the switch (or more to the point because it is waiting for the reset pin to be pulled low). Because it is only looking for the pin going low, it doesn't care when the pin goes high and therefore will only tell you whether it is opened but not closed.

    • @respaceits2283
      @respaceits2283 6 років тому

      ItKindaWorks I see. Is there a way to modify the code to show when it closes? (I’m not a serious programmer by any means)

    • @ItKindaWorks
      @ItKindaWorks  6 років тому

      I suppose one way would be to hook a switch up to a digital input and while the ESP is running, read that switch and wait for the close state before shutting back down.

    • @respaceits2283
      @respaceits2283 6 років тому

      ItKindaWorks yeah what I was thinking of doing was hooking it upto a magnetic read switch. Just not sure how or where to edit the code.

    • @ItKindaWorks
      @ItKindaWorks  6 років тому +1

      A reed switch is just like any other. I would add in a condition to the sleep if statement that the reed switch should be in the closed state before allowing it to sleep. Something like
      if((minRunTimer.check() && digitalRead(doorSwitch) == LOW && done) || maxRunTimer.check())

  • @Dialbist
    @Dialbist 7 років тому +1

    Can it be triger the PIR sensor?

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      Sure! Just keep in mind the power requirements of the PIR sensor since that would affect battery life if you're running it off of battery.

    • @Dialbist
      @Dialbist 7 років тому

      You mean that the PIR sensor consumes a lot? or that he needs another voltage?

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      It might not consume a *lot* but relative to the ESP it might be a lot. So here is the datasheet for a fairly common PIR sensor: www.mpja.com/download/31227sc.pdf It says that it consumes ~65mA which is almost the same as the ESP here so now you have ~1.4mA consumption which will give you roughly half the battery life that you had without the PIR sensor. Still thats multiple months of battery (roughly put at 3 months rather than 6-7) so it totally depends on the application. You can of course always use more than one battery (or a larger battery) to get that time back but it's just something to keep in mind that as you add more electronics that need to run even when the ESP is in deep sleep, there will be an effect on battery life.

    • @Dialbist
      @Dialbist 7 років тому

      Thanks, I understand! Here for example such ru.aliexpress.com/item/DFRobot-PIR-Human-pyroelectric-infrared-motion-sensor-3-3-5V-15uA-7m-with-Digital-cable-for/32792234109.html seems to have very little consumes, but not cheap

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      Given the power consumption thats not the worst price I've ever seen. But yeah its not the cheapest

  • @simonem8899
    @simonem8899 7 років тому

    Are you running the ESP directly from an LI-ION 18650?

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      I am! But don't worry, it's a high quality lipo that has built in over/under voltage and thermal protection! AFAIK that should be safe enough. And the ESP seems ok with the slight over voltage although it's not ideal at full charge.

    • @simonem8899
      @simonem8899 7 років тому

      at full charge it's 4.2Volt, I recommend using an LDO, there are some with a really low quiescent current which certainly would not cost much battery life,
      and would make the power more stable and secure.

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      I looked for quite a while for a LDO that would drop only .3-4 volts for when it's at nominal charge around 3.7 volts and never found anything that would have that low of a drop. It doesn't take long to drop down from 4.2V. And in my testing it seems to work fine so i say whatever, this is IKW after all ;)

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      I should say I never found a *decently priced* LDO that didn't require an order of 1k+ units to be cost effective.

    • @simonem8899
      @simonem8899 7 років тому +1

      take a look at ht7333, i suggest to put a 1000uF caps across the power pin to smoothen out the big current spike of the esp at reset, and if you desolder the red led you'll get much more life out of the battery

  • @Pacemaker476
    @Pacemaker476 7 років тому

    Please help me get this code working. Anyone? This is my error..
    'netInfo' has no non-static data member named 'name'

    • @ItKindaWorks
      @ItKindaWorks  7 років тому

      The name field in netinfo has recently been removed since it never really served any useful purpose. All you need to do is remove the entry for 'name' that you have in your instances of netinfo.