#118

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ค. 2018
  • We covered the Arduino's Deep Sleep in videos #115 & #116 so now it's the turn of the ESP8266 to have a snooze.
    It works differently to the Arduino ATmega328P so be prepared to implement your solutions differently with an ESP8266. It's not difficult at all but does require some thinking about how to continue where you left off.
    We also explore how much current an ESP8266-12E takes when in Deep Sleep mode (spoiler alert: not much). But remember the ESP8266 is a power-hungry beast at the best of times with all that Wi-Fi connectivity.
    In order to measure the current, we have to build a Bare Bones version of the ESP8266 board using a simple breakout PCB, making it very easy to mount on a breadboard.
    As usual, all links will be found in the GitHub and repeated here too.
    github.com/RalphBacon/ESP8266...
    -----------------------------------------------------------------------------------
    LINKS LINKS LINKS LINKS LINKS LINKS
    -----------------------------------------------------------------------------------
    ESP8266 (supports various modules) Vertical Breakout Board (UK Seller but generally available)
    www.ebay.co.uk/itm/ESP8266-ES...
    Same as above but WITH an ESP8266-12f module to solder onto it (very easy)
    www.ebay.co.uk/itm/ESP8266-ES...
    Behind the scenes ESP library containing (among many other useful things) the function to determine why the module woke up
    Note, these two files are part of a much larger library for the ESP8266, but linked here for reference.
    github.com/esp8266/Arduino/bl...
    github.com/esp8266/Arduino/bl...
    Everything you ever need to know about the ESP8266, published on May 14, 2017 by Ivan Grokhotkov
    media.readthedocs.org/pdf/ard...
    Espressif's own short document on lower power solutions, v1.1, published 2016.
    www.espressif.com/sites/defau...
    Have I missed any links? Let me know in the comments section below the video!
    ---
    If you like this video please give it a thumbs up, share it and if you're not already subscribed please consider doing so :)
    My channel and blog are here:
    ------------------------------------------------------------------
    / ralphbacon
    ralphbacon.blog
    ------------------------------------------------------------------
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 150

  • @jimb032
    @jimb032 5 ปีที่แล้ว +2

    Hi Raph - great job as usual. I don't have problems running ESP from USB barely ever. I did with the little 01 boards and windoze, but not with any others. I think Windoze does so the trickery with the USB port and power, as the same experiment in Linux yielded successful results. Good luck! Now bare ESP32 modules are a different animal all together. Look forward to your videos...hope you never stop!!!

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Wait and see what we have to do, James, to get the USBASP USB-to-serial module working on Windows 10! But that's for a future video, in the meantime let's just bask in the glow of a working ESP-12 module, whilst I ponder what is going on with this power issue... But first I must decorate the front bedroom. Thanks for your kind words, and for posting.

  • @OtusAsio
    @OtusAsio 5 ปีที่แล้ว

    Thanks for this one...very ineresting as always.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thanks for that, Pierre Plante, nice to hear from you.

  • @ricka1939
    @ricka1939 5 ปีที่แล้ว

    Ralph, loved the video! If you get a chance, please follow up using an esp32 board. Regarding the reset button. If you told the user to always press it twice, that should work. If in sleep mode, it wakes up to active mode on the first click, on the second click, it does a "proper" reset. If it is already in active mode, well, it gets reset twice, no harm done. Does that seem right?

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      That's a great way of solving the reset issue, Rick. That way you are guaranteed a reset regardless of the state of the device at the time of pressing RST. Thanks for sharing, I will be using this clever way in future!

  • @englishrupe01
    @englishrupe01 4 ปีที่แล้ว

    Hi Ralph! Always great videos, thanks! Hey, i have only just found out that the ESP8266 can also run at 160Mhz just by a simple instruction.....are you aware of this (I am sure you are and i just missed it)? I just bumbled into this fact and got really excited! I would love to see you do a video on this if possible though i know your time is busy and precious. Many thanks for all you do for us lesser mortals. Cheers!

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      In Arduino IDE 1.8.10 there are many (new) parameters that you can define for ESP8266 projects - including the CPU speed (I think it might have been there before but well hidden). That makes it easier to program. I always thought that it was defaulted to 80MHz but I've just checked in my Eclipse IDE and it is set at 160MHz (by default it seems). Perhaps my HomeAlone project is running at 160 MHz then! Pretty fast. I don't know how to set it dynamically at run time, not that it would be that useful to do that anyway.

    • @englishrupe01
      @englishrupe01 4 ปีที่แล้ว

      @@RalphBacon Thanks for the reply, Ralph. I shall enjoy exploring this. I was just thinking they were fixed at 80mhz and that i might have to shift to the more expensive ESP32's, but this CPU speed change makes me happy that i have several 8266's with variable speeds. I first found out about it from this guy doing benchmark testing (code is attached in the thread and may also be useful to you): forum.arduino.cc/index.php?topic=431169.0 and then this one seems to be how to set the clock speed with one line: bbs.espressif.com/viewtopic.php?t=889 Thanks!

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      Indeed, I've read that website before. I don't think the Arduino IDE supports that function, though, you'd probably have to use their SDK. But as I said, set it on upload and it should run at 160MHz. Simples.

  • @willwho2512
    @willwho2512 5 ปีที่แล้ว

    In my bare bone ESP-12 setup, I always bridge GPIO15 to GND and add a capacitor across VCC and GND. Without connecting GPIO15 to GND, it boots into SD boot mode sometimes. And the capacitor helps dealing with power spike that might cause a reset when running on a tiny battery.

    • @mdijkens
      @mdijkens 5 ปีที่แล้ว

      exactly! 220uF is enough

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      This is interesting, Will. Perhaps that's what mine was doing? Instead of "hanging" it was booting into the wrong mode? I shall check this, Oh, and the capacitor too.

  • @Ed19601
    @Ed19601 5 ปีที่แล้ว +2

    Very clear. Just a remark: with the wemos d1mini also no need to push a button for programming

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      So everyone here is telling me! Perhaps my version of the D1 board is the same, perhaps not, I can't remember! I do have to "faff around" with the two buttons on the other board though, most annoying.

    • @Ed19601
      @Ed19601 5 ปีที่แล้ว

      Ralph S Bacon I was hesitating as you spoke of the "D1". That's why I specifically added "D1 mini". It is very well possible that the now retired D1 didn't do it automatically. But the Wemos D1 mini is together with the NodeMcu board now the board to go to. I think the Wemos D1 mini has a better LDO than the Nodemcu.
      Anyway yr summary of the deep sleep and especially the difference with Arduino is very good

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      You've jogged my memory, Ed. The V1 (retired) did NOT do the required reset without a lot of button faffing (the one I have). The newer V2 version does, I believe, it was one of the improvements. But I am now going to experiment with the newest D1 mini series and will reveal all in a future video. So much to do!

  • @LauwersFreddy
    @LauwersFreddy 5 ปีที่แล้ว

    Interesting video! Have you tried open source software Fritzing for simple breadboard layouts and schematics? A lot of Arduino parts in the library. The hand drawing is also fine, and probably faster ;-). Just wanted to mention a free alternative. Thank you for making these video’s!

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Ah, yes, Fritzing, the much-maligned tool by the forum at Arduino.cc! I don't know why they hate it so much but I've not used it either (partly because of the aforementioned reason). Do you think it would make my wiring diagrams clearer, Freddy?

  • @sausagehider
    @sausagehider 5 ปีที่แล้ว

    Hi Ralph,
    Regarding the ease of program of the ESP8266, I have some Wemos D1 Mini Pro's and you don't need to press reset or anything when programming. They program the same as the NodeMCU LoLin boards (which I also have).
    Regarding the powering of the NodeMCU, I think you may have a faulty one or some other fault most likely a poor-quality power/USB lead. I have 5 of these (purchase before discovering the D1 Mini Pro's) and have used several computers to program them and never had a supply issue. With a 40mA draw out of the 500mA available on most USB ports, there should be plenty of power.
    On the Wemos D1 Mini Pro, you get the voltage regulator and USB-serial converter onboard as with the NodeMCU but in deep-sleep mode the current consumption is around 25uA to 50uA which is similar to the 'bare' ESP12-E. Using this you get the low deep-sleep current consumption yet easy plug and play USB connection for programming.
    I have several used for remote sensing. One of those being an Oil Tank Level Meter. This uses the D1 Mini Pro with a laser range finder and temperature sensor which sits at the top of my heating oil tank and takes a reading every 15 minutes, uploads to Thinkspeak (via WiFi) and then goes back to deep sleep. It takes approximately 10 seconds to wake up, gather the data, connect via Wifi and upload the data. It also uses the analogue input to measure the battery voltage. One thing to note with this, is that the board has a built-in voltage divider on the analogue input which accepts 3.3v max, so when calculating a new voltage divider for 5v input, this existing divider needs to be taken into account.
    Great videos, I have learnt loads from you.
    Thanks
    Martin

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Good feedback and suggestions, Martin, thanks.
      I've tried different USB cables and even a powered hub. I, too, would have expected it to work. But even if it did boot up OK as soon as it came out of Deep Sleep it hung. Perhaps I have a dodgy board? I might get a Wemod Di Mini Pro because the way you describe it makes it perfect for actual project implementation.
      Thanks for posting, nice to hear from you.

  • @khetimachineryindia
    @khetimachineryindia 3 ปีที่แล้ว

    Thanks for posting this video. I am using ESP8266 and reading analog voltage over time using deep sleep feature. wake up time is 5 mins after every hour. The voltage values start increasing than the actual signal if the module is used for continuously 24 hours. when i reset the esp8266 by pressing external button then the voltage value is lesser. have your observed this? means hard restart is different from deepsleep restart??

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว +1

      I haven't noticed this but are you taking into account temperature stabilisation, discarding the first analog read (1st reading not reliable) and as you are using Deep Sleep you must be powering by battery, right? So the analog value will be dependent on the battery voltage (always referenced to VCC) - perhaps the battery voltage drops over 24 hours?

    • @khetimachineryindia
      @khetimachineryindia 2 ปีที่แล้ว

      @@RalphBacon Thanks for your reply.. All I want to know that is soft reset and hard reset in esp8266 is same....It seems it is not...can we make esp8266 hard reset through program??

  • @sanjaybhatikar
    @sanjaybhatikar ปีที่แล้ว

    Nice video! So it is memoryless/stateless between wake cycles? The only way to persist information seems to be a file system. Thank you.

    • @RalphBacon
      @RalphBacon  ปีที่แล้ว +1

      Yes, exactly, although the RTC has some memory that you can access after a Deep Sleep. That memory is fairly limited but still useful. If you were to Hibernate (not just Deep Sleep) then that RTC memory is also wiped.

  • @Dhamian
    @Dhamian 5 ปีที่แล้ว

    The new D1 minis have auto reset circuit similar to the Node MCU, I dont need to press any button in order to program mine. Also the mini has an LDO voltage regulator much more suitable for battery operation.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      So I now understand, Caio, I must retest my D1 full sized board to see if I still have to press both buttons in that weird way. Thanks for posting.

  • @reelrebellion7486
    @reelrebellion7486 5 ปีที่แล้ว

    I built a weather station using an esp01, should be about like your naked board, and my recollection was the whole thing ran fine from a generic ftdi module. Plugged directly to a usb port on my pc, no extra hub, but that shouldn't matter. I even had the wifi active. Maybe the esp01 is a different version of the chip. It doesnt have the metal cover, looks like a regular chip.
    Side note: when you pulled off that green wire a question popped in my head. Do Ralph's dupont cables devolve into a mass of single strands like mine do? If not how does he manage that? Ok. Two questions.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      The chip is the same, Kent, an ESP8266, some have that shiny gold cover on them, not sure it's for anything other than cosmetic purposes. As far as I know, anyway.
      My connected Dupont cables invariably become separated as they reach adulthood. Sometimes, two might stick together for a long time (red/brown = power) or even yellow/green (= data) but mostly they become individuals in their own right. I think this is the natural order of things. At which point I order another 120 cables for next to nothing from the Far East and the whole saga repeats. So yours behave like mine. It's only natural, Kent, don't fight it.

  • @simonwhite3137
    @simonwhite3137 3 ปีที่แล้ว

    Thanks for this one Ralph! I'm just getting into battery-powered ESP8266 and sending the kit to sleep is a vital part of the process. My first is an e-ink weather forecast display that updates itself at 05:45 each morning regardless of when it was last put to sleep.
    Let me share my schoolboy error for all those who might want a laugh. In trying to check whether the data had saved properly, I would print the contents of each saved rtcUserMemory, but they all seemed to contain the value 1 rather than the saved value.
    I was using the shortcut expression...
    Serial.print(ESP.rtcUserMemoryRead(0, &loopCount, sizeof(loopCount)));
    ...which of course returns and prints a true/false result, NOT the value of the variable.
    Only took me two days of going round in circles before the penny dropped.
    Keep up the good work Sir!

    • @RalphBacon
      @RalphBacon  3 ปีที่แล้ว

      Only by making mistakes do we gain what's called "experience", Simon. Frankly, I'm impressed that you shared it here, kudos to you indeed, and it will hopefully make others think about their code! Don't forget that, depending on the memory of your ESP8266, you can also use SPIFFS or LITTLEFS that survives even a power down.

    • @simonwhite3137
      @simonwhite3137 3 ปีที่แล้ว +1

      @@RalphBacon if only it didn't have to be so frustrating 😂😂😂 but yes, that's now something I'll never ever get wrong again and it's all part of the fun of learning.
      No need for surviving a power down in this case, but thanks for the steer. One step at a time!

    • @simonwhite3137
      @simonwhite3137 3 ปีที่แล้ว

      Hmmm...
      When all's said and done, it's not a good timekeeper over 24 hours!

    • @RalphBacon
      @RalphBacon  3 ปีที่แล้ว +1

      Agreed. That's why (in my Home Alone project) I connect to an NTP (Time Server) every few hours or so. The time on an ESP8266 can only be as good as the clock frequency and it will never be _that_ precise!

    • @simonwhite3137
      @simonwhite3137 3 ปีที่แล้ว

      @@RalphBacon Yep. Mine displays the time from NTP when it goes and gets the weather forecast each morning. But I really don't like that it's up to eleven [EDIT: TWENTY SEVEN] minutes out(!) in waking up over 24 hours. That just feels wrong. I might give in and add a DS3231 as a wakeup alarm clock.

  • @aryeguetta8592
    @aryeguetta8592 5 ปีที่แล้ว

    Is this the one you use?
    Expansion Board V3 Lua Breakout Development Boards for ESP8266 CH340G NodeMcu EM88
    Thanks

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      That certainly looks like it, Arye, and can be found on eBay, AliExpress, Amazon and most other suppliers! It's very cheap too because it doesn't contain any real components other than a voltage regulator (it might be a buck converter) but it certainly makes it easier to connect up the pins.

  • @BrazzaB1
    @BrazzaB1 5 ปีที่แล้ว +1

    Hi Ralph. You can power the Lowlin boards from USB - You are probably using a thin cable and poor power supply. Thick cabled USB and good 5v supply is needed

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Yup, I've sort of got the message now, Brian. It's me! But I have a course of enquiry to follow and I'll see if it is that. Thanks for confirming this.

    • @zebratangozebra
      @zebratangozebra 5 ปีที่แล้ว

      Andreas Spiess has a good video on USB cables. Junk USB cables have had me perplexed for days on why something wouldn't work. I'm running the same ESP8266 board here on a 10 foot USB cable with another foot of connector cable and it works fine.

  • @mdijkens
    @mdijkens 5 ปีที่แล้ว +5

    I wonder if you were only measuring the uA of the bare ESP? No voltage regulator in between?
    I have bare ESP12E's running on a single 2.5Ah 18650 with a HT7333 LDO for over a year (10 sec on, 71min (max) off)
    The HT7333 consumes around 5uA, the ESP12E around 15uA

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      I was measuring the bare ESP8266-12E module with nothing else running, Maurits, (well, you saw the setup on my board). I couldn't get the current any lower. Maybe those 10K pull-up resistors on the breakout board are consuming some current (I'm not even sure if they are absolutely required). I need to find out where they are actually connected. Your current consumption is super low indeed, just what is required. Thanks for those details, maybe I will try an LDO voltage regulator too.

    • @Ed19601
      @Ed19601 5 ปีที่แล้ว

      Maurits Dijkens interesting. I have a bare esp12F running on 2 *1.5 alkaline, waking up every 71 Min, only making WiFi contact if 4x71 Min have passed. If so it takes a bme280 reading and several ds18b20 readings and mqtt's those. Has been working (well mostly sleeping) for several months already without me noticing any voltage drop. Your results make me think I shld be good for years as well..... If my alkalines survive the winter

    • @mdijkens
      @mdijkens 5 ปีที่แล้ว

      I have used almost 20 ESP12E's. All consistent results.
      This is the schema I created: easyeda.com/maurits.dijkens/mdesp12e-adapter
      After lots of testing & measuring this was lowest powerconsumption and best reliability
      20uA in deepsleep (5uA from HT7333)
      If you want to use the gerbers then best use 4.0 or 4.1

    • @mdijkens
      @mdijkens 5 ปีที่แล้ว

      @Ralph: Just watched that part again and I think you are measuring about 50uA extra by keeping the FTDI connected to RX & TX. Just power it from stable 3.3V with 220uF, use 12k instead of 10k resistors and measure again

    • @billwaldrum5571
      @billwaldrum5571 5 ปีที่แล้ว

      @Maurits: What sort of power/radio management do you use in your sketch? There is so much conflicting and out of date information out there that I would love to see something that really works.

  • @robertpoynton9923
    @robertpoynton9923 4 ปีที่แล้ว

    What is the longest time it can sleep for? I'm wanting to get a mqtt message of the soil moisture in the front yard so I would only need a few readings per day, or is there a maximum sleep time?

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      The ESP8266 can sleep for a maximum of just over 1 hour (71 minutes). But that shouldn't be a problem at all. If you only want to "do stuff" every 4 hours for instance, set the wake-up to 60 minutes, count 3 wake-ups and go straight back to sleep and on the fourth wake-up do stuff, reset the wake-up counter and go back to sleep. Just think that on the Arduino UNO we can only sleep for 8 seconds maximum!

  • @eriklaken1025
    @eriklaken1025 5 ปีที่แล้ว +1

    I have them and the work on one microusb no problem at all.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Yes, Erik, you and everyone else. Except me! When I get to the bottom of this I will announce it in a future video or my blog. Thanks for confirming this.

  • @TheRainHarvester
    @TheRainHarvester 4 ปีที่แล้ว

    I read "persistent" mode can wear out the flash, if you sleep / wake too much. I'm just getting started with ESP, so not too sure why you'd need persistent mode or if it is the default.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      You don't need persistent mode if you are supplying the SSID and password, just execute?:
      WiFi.persistent(false);

    • @TheRainHarvester
      @TheRainHarvester 4 ปีที่แล้ว

      @@RalphBacon I'm using an AP , so the user types the pw into the phone to connect. Is persistence a problem?

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Espressif admit there _was_ an issue with premature flash failure but their newest code doesn't write anything to flash unless something (SSID, password) has changed. Why they are storing it there at all beats me.

    • @TheRainHarvester
      @TheRainHarvester 4 ปีที่แล้ว

      @@RalphBacon , oh, I bought mine years ago. What term would I search to update it's firmware? I want an open source firmware so no one is spying my wifi traffic.

  • @gavinsmalley1513
    @gavinsmalley1513 5 ปีที่แล้ว

    Ralph you must have better eyes than me! I'd never recommend using an ESP01 for anything that requires deep sleep if it can be avoided as deep sleep wakeup requires access to GPIO16 to trigger the reset and that isn't exposed on the ESP01 - you need to solder directly to the pin on the chip and that (for my eyes at least) requires much magnification and a very steady hand.
    Not sure what to suggest is going wrong with powering your ESPs but I have run ESP-12Es (in the shape of a Wemos D1 mini with built in USB-Serial) from my laptop's USB port with no problem at all. They take no more than 300mA even with everything fully loaded and the USB-Serial running. Any USB port should be able to supply a minimum of 500mA. Even the one you have on the development board should run from the USB port if you remove the dev board. There's definitely an issue in your setup somewhere. Do you have a long/poor USB cable somewhere?
    Maybe something for a follow-up video: There are many different sleep modes available on the ESP (including the ability to sleep, or not, the radio). Maybe going through these would be of interest?

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Yes, I shall have to investigate what is going on. One suggestion is that my device was *not* hanging but going into the wrong startup mode (waiting for a sketch, basically) on return from sleep. See the comment from Will Who in the comments. Thanks for posting Gavin, always nice to hear from you.

  • @PaulCavanagh69
    @PaulCavanagh69 5 ปีที่แล้ว

    you should also look at esp32 as it improves on the deep sleep mode and has a ULP coprocessor

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Does the ESP32 not do the same thing, Paul? I haven't really investigated but something tells me it's similar, except we no longer need to connect GPIO16 to RST, it's all done internally. Maybe!

    • @mdijkens
      @mdijkens 5 ปีที่แล้ว

      I could not get the same powerconsumption with the ESP32 yet, but Imust admit I have not spend as much time in it as the ESP8266

  • @crayzeape2230
    @crayzeape2230 5 ปีที่แล้ว

    In the case of the ESP8266, the Arduino code is running as a thread on the underlying RTOS, this likely accounts for the difference in sleep operation.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Are you sure about this? My understanding was that uploaded code runs on the "bare metal" unless you have specifically uploaded an RTOS of some sort. Even the NodeMCU is an eLua based firmware, which itself runs without an operating system. But I'm not even using that in this demo, just some basic Arduino-compatible code. Perhaps other will comment here?

    • @crayzeape2230
      @crayzeape2230 5 ปีที่แล้ว

      Not sure at all, though I shouldn't have used the RTOS/thread term. The NonOS SDK uses a callback based system rather than an OS. There are still a lot of background processes going on that have to run interleaved with the Arduino code though. It's been too long since I last looked at the ESP8266 scene and my logic appears to be a little flawed :(

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      No problem, I'll read up more about this when my work/home decorating time allows!

  • @matthewframe3340
    @matthewframe3340 4 ปีที่แล้ว

    I tried this setup however without the source code and information on the drawing with the push-button I was unable reproduce satisfactory results. Do you have updated details by chance?

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      When you say "satisfactory results", what results did you get? Basically, remember that the ESP8266 just shuts down in Deep Sleep and when woken (ie rebooted) it knows that it was previously in Deep Sleep and can grab variables from the RTC SRAM.

  • @jamest.5001
    @jamest.5001 5 ปีที่แล้ว

    I hope I'm not making myself look too dumb. However I'm curious to if deep sleeping. Does it take extra time to wake-up and "do its thing" and does it slow the execution of commands. Like does it take time to go to sleep and wake up? Even a fraction of a second? Or some of the code will have to account for? I hope I made since!

    • @IanSlothieRolfe
      @IanSlothieRolfe 5 ปีที่แล้ว

      It depends of how much of the chip is switched off (i.e. what sleep mode your in). If clocjk sources are switched off then there will be a delay while the oscillator starts and stabilises. However, its usually only a matter of microseconds, so unless your doing something very time critical on wakeup its not normally significant.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      The biggest delay in waking up from Deep Sleep (which takes almost no time at all) is that it must connect again to the wi-fi which is why I suggested using a fixed IP address as that takes about 30mS as opposed to about 300mS (or thereabouts).
      So, if you woke up every 1 second and blinked an LED you would see that it would get far behind the second hand of a clock as it did all that setup stuff over the course of an hour. Nothing happens instantaneously, that's for sure!

  • @TheRainHarvester
    @TheRainHarvester 4 ปีที่แล้ว

    I thought the deep sleep would use lower uA. Did you find out why? No LDO is being used - right?

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      I power the chip directly, as even the best LDO will consume some power.

  • @tablatronix
    @tablatronix 5 ปีที่แล้ว +4

    I never use an auxiliary power supply for esp8266 development, straight USB, If i had to guess that crappy lolin boards ( I do not use them ) has a non LDO regulator. I would suggest using official amica nodemcu v2 or doit nodemcu v2 boards, they also fit on breadboards properly. Or even a d1 mini is better

    • @mdijkens
      @mdijkens 5 ปีที่แล้ว +2

      Only USB is enough for my Lolin NodeMCU's. I use them a lot for development/test. For deepsleep you have to use a bare ESP8266. The dev-boards don't make sense for deepsleep considering the usb/ftdi and regulator consume way more

    • @tablatronix
      @tablatronix 5 ปีที่แล้ว

      Maurits Dijkens yeah for non dev , deep sleep you would rarely use a dev board, esp8266 is really not suited for battery projects.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +2

      I'm going down the D1 mini route, tablatronix! They seem to really hit the sweet spot in terms of functionality, size and price. And the number of shields you can get is huge, so something for everybody. Something I'm (hopefully) lining up with a supplier for a future video. Great suggestion, keep watching (and commenting)!

    • @tablatronix
      @tablatronix 5 ปีที่แล้ว

      Yeah I was resistant to the d1 mini for a bit, it seemed cheap to be good, but it seems to have proven itself and it sure it small. However there are chinese versions that are called wemos but not always up to the quality.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      We shall find out in a future video. Keep tuned!

  • @fassesweden
    @fassesweden 5 ปีที่แล้ว

    What about the maximum write cycles in both RTC and flash memory. If I’m not mistaken it’s not recomended to write to the same memory byte more than about 10000-100000 times.

    • @mdijkens
      @mdijkens 5 ปีที่แล้ว

      According to spec you are right. I do however have multiple ESP12E's running several years and some have been written to the same memory location over 20,000 times. No issues yet. And if it finally fails, no problem to replace after several years :-)

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Yes, Fredrik, flash memory does have a limit, but I've always taken 100,000 writes as being the max you should really use a single cell for. That could be a long time before you use a cell that many times. Regarding the RTC memory, that's not flash, I don't believe, as you lose the information after power is cut. Probably volatile RAM, which doesn't have a limit as far as I know. Good question!

    • @mdijkens
      @mdijkens 5 ปีที่แล้ว

      Ah yes, you are right; RTC mem is not flash, so no problem even in 20 years :-)

    • @3dprograminsrl27
      @3dprograminsrl27 4 ปีที่แล้ว

      another way of keeping track of variables would be to use an external webserver. Having access to a server (VPS) and bits of JavaScript knowledge, you could easily setup an API in NodeJS (ExpressJS)

  • @SThomas1972
    @SThomas1972 5 ปีที่แล้ว

    The Adafruit feather esp8266 runs of usb power quiet happily and it will charge a battery aswell.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Yes, I'm looking into whether my board is fine but boots to the wrong mode (after sleep), I'll let everyone know my findings. Thanks for posting Simon.

  • @browaruspierogus2182
    @browaruspierogus2182 5 ปีที่แล้ว

    ESP has deep sleep modes if you didn't read their documentation. There is Light Sleep and Deep Sleep - true deep sleep.
    In true deep sleep not all of peripherals can be preserved because all power is off however there is ULP onboard ESP allowing that at even lower level
    docs.espressif.com/projects/esp-idf/en/feature-cmake/api-reference/system/sleep_modes.html?#overviewall
    You can still override the wakeup behavior in the code

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Oh yes, Browarus, I read all the documentation but decided that if running off a battery were ever to be successful then Deep Sleep was the only viable way of preserving that battery life. I, therefore, did not experiment with the other modes as they would not have achieved my goal in this video. Thanks for the link, can't remember if I included it in my GitHub but it's good to be listed here too! Nice to hear from you.

  • @RaadYacu
    @RaadYacu 5 ปีที่แล้ว

    one issue i've found with barebone ESP3266 is that 70 uAmps deep sleep is only for blinky sketches. Once RF power is turned on, it shoots up to 200-300 uAmps ( I forget exact nbr) and seems there is no way to shut the thing off with any of the ESP. commands they have . As you said, its a joke how Espressif used the sleep mode with this chip vs Atmega's WDT.
    It sure would be nice to have a Wifi chip that uses low power or just shuts off when told to . Basically the only way I've found to turn make ESP8266 low power is just turn off the whole thing use chip enable as my control pin from outside.

    • @kissingfrogs
      @kissingfrogs 5 ปีที่แล้ว +1

      The wemos seems to run at about 70mA with 200mA spikes only when there is wifi activity which differs from your experience.

    • @RaadYacu
      @RaadYacu 5 ปีที่แล้ว

      Are you referring to the Wemos Lolin D32?

    • @kissingfrogs
      @kissingfrogs 5 ปีที่แล้ว +1

      It looks like I have my wires crossed somewhere. I thought 70uAmps was a typo and you actually meant 70mA. But it now looks like you did in fact mean 70uAmps. I thought any ESP8266 regardless of board consumed about 70mA with 200mA peaks when wifi-ing. I am beginning to think that is not the case. I need to do more research.

    • @RaadYacu
      @RaadYacu 5 ปีที่แล้ว

      My numbers were gathered for Deep Sleep only. This number and wakeup frequency matters most for low power use cases ( to me at least )

    • @gavinsmalley1513
      @gavinsmalley1513 5 ปีที่แล้ว

      When deep sleeping in a sketch that uses WiFi you have to disconnect WiFi and turn off the radio before deep sleeping otherwise the radio remains running increasing the current draw. There are many levels of deep sleep available on the ESP8266 and you have to specify the correct sleep for what you require. Adreas Speiss has some good tutorials on these along with current measurements on his You Tube channel.

  • @TheRainHarvester
    @TheRainHarvester 4 ปีที่แล้ว

    would a capacitor (instead of a separate power supply) work? (I want to use batteries.)

    • @TheRainHarvester
      @TheRainHarvester 4 ปีที่แล้ว

      I'm powering my ESP01 from the 5V (going to a 3.3v LDO) of my Arduino nano which is plugged into my USB. No power problems. I use a 470uF capacitor on the 5V rails, but it still works without it. Maybe my pc has a great USB port?

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      That size capacitor is quite large; what is it you are hoping it will do? Additionally, on switch on it could pull so much power that it could stop the Arduino booting up.

    • @TheRainHarvester
      @TheRainHarvester 4 ปีที่แล้ว

      @@RalphBacon I was having wifi disconnect every few hours so I wanted to eliminate power supply issues. I do stuff like this when I develop and eventually remove them one-at-a-time to see if they help/hinder.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      The wifi disconnected, perhaps, because you have not specified "no sleep" to keep it going, forever?

    • @TheRainHarvester
      @TheRainHarvester 4 ปีที่แล้ว

      @@RalphBacon interesting. I just read about that. Thanks!
      Eventually I'll sleep this esp between updates. So I'll eventually have the problem again. I think our router may be to blame. It's ten years old and we frequently need to reboot it. Although the esp hangs, waiting to receive, even when the router doesn't need rebooting.
      I think the router waits a while to connect when lots of devices are connected to it, or someone is playing TH-cam.
      I added a count to detect when the esp loses the client.readStringUntil() ...it just receives nothing so the Arduino code just waits. If the counter is 20, I just return so a new SendData can call client.connect() again.
      But at least it will work with everyone's router (even old ones).
      At least I think that is the culprit.

  • @anythingunderthesun9930
    @anythingunderthesun9930 4 ปีที่แล้ว +1

    I never had a problem with the power on my NodeMCU ESP-12E, I always directly connect the microUSB in my desktop. Clearly there is a problem with your USB or your pc is not supplying enough 5 volts, or you have a slight-defective nodemcu.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      I think it was the hub I was using - not powered so very limited in current (technically 500mA but it doesn't actually deliver that much).

  • @calvin-7540
    @calvin-7540 4 ปีที่แล้ว

    I tried to follow your way of counting the number of time of looping, at the beginning everything was fine. However, after I powered down it and power up again, the counting value immediately went to a gigantic number like 4 million something, do you have any idea why it has happened?

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      When you say "powered down... and up again" I'm assuming you mean from Deep Sleep? In which case you must retrieve the variable values (that you previously stored) from the EEPROM of the RTC - no values are retained at Deep Sleep, unlike the Arduino. Is this what you meant?

    • @calvin-7540
      @calvin-7540 4 ปีที่แล้ว

      @@RalphBacon Well, my "power down and up" means unplug from the power supply

    • @calvin-7540
      @calvin-7540 4 ปีที่แล้ว

      @@RalphBacon after powering up again, the value changes to a very big number which seems a lot of digits with a starting number of 4. it's like 4 million something, very strange....

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Variable values are not retained over a power break. You must either initialise them in the setup to zero, or read the previously stored value from the RTC EEPROM area. In fact, I'm not sure that survives a total unplug either, just when the ESP8266 goes to sleep. You will have to read up on what is support, I'm afraid.

    • @calvin-7540
      @calvin-7540 4 ปีที่แล้ว

      @@RalphBacon Thanks for your reply, the first suggestion is the very easy one I came up with and I did try, it works fine. Everytime I cut off the power and power it up again, it starts count from 0.

  • @baz813
    @baz813 3 ปีที่แล้ว

    @UC8Ob-HnnmhlgSv5Vs_i32TQ I presume the difference in the sleep methods would be that the arduino method, requires maintenance of the state of non volatile ram, which would therefore require energy. I guess the ESP method, is more of a cold boot, and so requires less energy not requiring to keep the non volatile ram energised.

    • @RalphBacon
      @RalphBacon  3 ปีที่แล้ว +1

      Well, in deep sleep the ATMEga328P only requires 0.2µA which is lower than the leakage current of your battery so I'm not sure it really matters too much! And it's so much easier to wake the Arduino up! The ESP8266 is effectively switched off but the RAM of the RTC still has to be kept alive with the values you've put there. Swings and roundabouts, really.

    • @baz813
      @baz813 3 ปีที่แล้ว

      @@RalphBacon wow that's such a tiny sip! would definitely seem to invalidate my theory :-)

  • @andymouse
    @andymouse 5 ปีที่แล้ว

    interesting how the chip manufactures go about different tasks but the 328p is in my book far more elegant and logical ! (in this example)...…..and what about this "low = on " business (witchcraft?)...………….I think it would be best for me to give the ESP8266 a miss as I'm beginning to grow in confidence with the 328p...……..It seems I only work on an internal oscillator (sob!)

    • @Ed19601
      @Ed19601 5 ปีที่แล้ว +1

      The 328 is indeed magnificent, but don't discard the ESP8266 just yet. It is very capable

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +2

      Indeed, the ESP8266 is a much more powerful, faster chip and, of course, has wi-fi built in so you can connect to your phone (well, the other way round, usually) to monitor stuff, such as the beehive temperature. Or whatever. But get to grips with the ATmega328P and then move onto the ESP range.

    • @sausagehider
      @sausagehider 5 ปีที่แล้ว +1

      What I don't understand is why people use the Atmega328P and then use an ESP8266 to add Wifi when they can just program the ESP8266 directly without using the Atmega328P at all. Of course there will be some exceptions with specific functions of the Atmega328P, but I think the majority would not require the Atmega328P at all if you need Wifi!

    • @Ed19601
      @Ed19601 5 ปีที่แล้ว

      Martin Ellis very very true. If you want more Io pins add an i2c extender

    • @sausagehider
      @sausagehider 5 ปีที่แล้ว +1

      Oh, and of course a Wemos D1 Mini Pro is about 1/2 the cost of the Arduino Uno clone!

  • @EL90291
    @EL90291 5 ปีที่แล้ว

    Check your USB cable.....I use same LoLin board and only use the micro usb cable for power .

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +2

      I tried many cables, EL EL, but it seemed to make no difference. I will have to revisit this and check that my hub was actually providing the power. Thanks for the suggestion.

    • @Gijz74
      @Gijz74 4 ปีที่แล้ว

      Yep. Some cables seem to be able to power the board without a problem but most don't. I thought missing drivers where the issue but cable number 6 or 7 worked straight away. It can be done but requires "angel woven hi-fidelity" USB cable ;-) And once you found such a cable mark it with electrical tape or some other label.

  • @marcoscuriel7741
    @marcoscuriel7741 4 ปีที่แล้ว

    esp8266 01 has about 50mA (yes, mA) on deep sleep... do you know why?

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Well, if it's the ESP8266 taking that much current then it is most certainly _not_ in deep sleep. But what about peripherals? Are they still consuming power? Disconnect all of them and measure again. Are there any LEDs on the ESP8266 module? Whilst a single LED will only consume about 5-10mA perhaps you have more LEDs? Remember that when the ESP8266 is in Deep Sleep is it effectively switched off with just the timer running to bring it out of Deep Sleep - you know this happened because on start up the reboot reason changes (see the demo). Good luck, tell me what you find!

    • @marcoscuriel7741
      @marcoscuriel7741 4 ปีที่แล้ว

      @@RalphBacon i have only esp8266 01. Maybe is like burn because it takes like 120mA in normal mode, 45/50mA more from the video info. Did you test it with 01 board?

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      No, I used a standard board but it should make no difference - the central chip is the same, it's only the peripherals that can consume more power. Are you _sure_ you are making the ESP8266 sleep?

    • @TheRainHarvester
      @TheRainHarvester 4 ปีที่แล้ว

      @@marcoscuriel7741 It might be the LDO. I had to replace my Arduino LDOs with low quiesent power LDOs.

  • @JeanDAVID
    @JeanDAVID 3 ปีที่แล้ว

    where is the sketch ino file please ?

    • @RalphBacon
      @RalphBacon  3 ปีที่แล้ว

      Good question, Jean. I can't find it and I can see from the name in the video that it would have been renamed to have a "ESP8266"-type name. My NAS backups are now all packed up pending the house move. The only hope is to be able to get all the lines from the video, so sorry.

  • @tablatronix
    @tablatronix 5 ปีที่แล้ว +3

    esp8266 wake is essentially reset

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +4

      Absolutely it is. The only difference is that the ESP8266 reads one of the RTC memory cells to determine what caused the reset. And that's it. Done and dusted. A bit clunky, don't you think?

  • @i3130002
    @i3130002 4 ปีที่แล้ว

    You could do nothing else, as of needing to connect to WiFi after sleep

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      I didn't quite understand this, can you rephrase please?

    • @i3130002
      @i3130002 4 ปีที่แล้ว

      @@RalphBacon Sorry I forgot mentioning the sleep method they used in nodemcu.
      There is no other way to implement sleep method as of having to reconnect to Wi-Fi and DHCP stuff after wake up.

  • @amrmagdy_smarthome
    @amrmagdy_smarthome 5 ปีที่แล้ว

    Link + code = LIKE ... haha

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Thanks for your post, Amr Magdy, good to hear from you.

  • @jeffhousen8968
    @jeffhousen8968 5 ปีที่แล้ว

    put all your code into setup? whoever thought this was a good idea....

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      It's just a naming convention, Jeff. In the usual (Arduino) way, we have the setup and the loop. In this mode (sleep, resume) those nomenclatures do not have their original meaning so everything can go into the startup - or, if you prefer, the startup could call either another function (doStuff) or let the loop do its stuff - except we don't actually loop (usually) when Deep Sleeping. It's a weird one, that' for sure. Thanks for posting, great to hear from you.