You really do take this to the next level, great video.
@RalphBacon6 жыл бұрын
Nice of you to say, ifell3, glad you liked it, thanks for posting.
@aryeguetta85926 жыл бұрын
I Like the videos - the length is OK by me :) Keep them coming great work!
@RalphBacon6 жыл бұрын
Thanks for your post, Arye Guetta, good to hear from you.
@programmingtips4043 жыл бұрын
Thank you for the details!
@RalphBacon3 жыл бұрын
No problem!
@BGLENN-dp4tx5 жыл бұрын
Great video. Thank you.
@RalphBacon5 жыл бұрын
Thanks for your post, B. GLENN, good to hear from you.
@springwoodcottage42486 жыл бұрын
Helpful, informative & useful. Thanks for sharing!
@RalphBacon6 жыл бұрын
You are most welcome Springwood Cottage, I'm glad you like the video. Nice to hear from you.
@martin090919894 жыл бұрын
Thx for shareing this information with the world! That helped me to bring down the power consumtion for a central locking control unit replacement, for my old BMW to 3,5mA using an Arduino Nano. If i have enough time i try to convert this replacement project to a attiny and see how low this thing can go! 😏
@RalphBacon4 жыл бұрын
Experimentation is sometimes the only way to see if it's going to work!
@summerWTFE4 жыл бұрын
Did you have to flash a new boot loader? My nano went into an infinite boot loop and I read that you have to use another boot loader forum.arduino.cc/index.php?topic=513120.0
@lindsaydempsey56834 жыл бұрын
Great content and these two were just the right length IMO, any shorter and important details would have been skipped I think. Keep up the great work.
@RalphBacon4 жыл бұрын
Glad you enjoyed it!
@reelrebellion74866 жыл бұрын
I enjoy that you do thorough videos, and I think the current balance is pretty close to ideal. If I am following along at home I dont have to search for missing details, or otherwise "faff about" as you might say. If you feel the pressure to cut too keenly, I might recommend creating a "Ralph Bacon Shorts" series (notice how free I am with your time), where you trim the same video down to the barest of essentials.
@RalphBacon6 жыл бұрын
So you want me to edit my video raw material _twice_ , Kent, is that right? Actually, I like the idea of constructing a 5-minute (yes, 5-minute) look-at-what-you-could-have-watched style teaser. I'm wondering how much work that would actually be. Hmm, I shall consider... and maybe experiment with video #118 (as video #117 is already queued up ready for release, too late for that one). Thanks for the idea and being so free with my time!
@reelrebellion74866 жыл бұрын
I'm glad to receive what ever you offer, I prefer the videos as you do them now vs. a less thorough shorter format. I'll keep watching either way. I think you summed up what I was trying to say better than I did.
@gandsnut6 жыл бұрын
For what it's worth, the ICM7555 (CMOS timer chip) uses 60uA and claims to provide timing periods into hours... One wonders if it could trigger the microcontroller to wake-up, say, once every 30min. There may be other long-period timers that can do better. And, certainly, other microcontroller programming methods to maximize power savings must exist.
@RalphBacon6 жыл бұрын
Wait until I cover the braindead ESP8266/ESP32 and you will see how your idea has more merit than you might imagine! Shhh, Are, no more spoilers!
@BGLENN-dp4tx5 жыл бұрын
Great insight and to answer you directly, YES you can trigger wakeup with the CMOS and other versions of the 555 timer. It's very simple and there is much information on the topic already available.
@andymouse6 жыл бұрын
seriously, love the vid and as for "naked Arduino" Julian got it down to chip and LED only !...…...he broke all the rules !
@RalphBacon6 жыл бұрын
Yes, Andy, he did break the rules as the timers (millis, delay) no longer work the way you expect! But I guess there are tradeoffs to running at a lower frequency.
@viniciusnoyoutube6 жыл бұрын
Very good video! :)
@RalphBacon6 жыл бұрын
You are most welcome Vinicius, I'm glad you like the video. Nice to hear from you.
@OsoPolarClone6 жыл бұрын
Thanks. Very interesting video.
@RalphBacon6 жыл бұрын
Thanks for your post, Bruce Peterson, good to hear from you.
@abdellahsendjasni8 ай бұрын
thanks, i hope this one works for my project
@RalphBacon8 ай бұрын
I hope so too!
@thorbjrnhellehaven57662 жыл бұрын
I find a combination of both videos to be very useful!! My application: mailbox delivery notification: input switch -> wake up interrupt -> sendWirelessMessage("Mailbox alert!") max timer -> count X hours -> sendWirelessMessage("mailbox guard alive") master unit -> replyWirelessMessage( CONFIRMED ; request_X(number) )
@RalphBacon2 жыл бұрын
Sounds very do-able Thorbjorn. What processor would you use to send the message? An ESPXXX? Or use a network card with an Arduino?
@thorbjrnhellehaven57662 жыл бұрын
@@RalphBacon the project is still in the early phase, just collecting ideas. I want long life on battery. It seems like the ESP8266 has potential for low deep sleep power. I am a bit confused about how to wire a switch and the internal WAKE signal to RST, then know if it was switch or timer. I am open to to any suggestions on other purpose fit controllers. I also thought about possibly a controller to handle the main tasks with switch and timer interrupt in deep sleep, then power on the wireless controller on demand, but it seems like the ESP8266 has potential for pretty low deep sleep power by itself. The other significant decision is for lid switch detection. Shoul be weather proof all year: sunny, rainy, snowy, icy, or windy.
@4funrc116 жыл бұрын
Hey! This is really good. Thx.
@RalphBacon6 жыл бұрын
Thanks for your post, 4FunRC, good to hear from you.
@istvanzilizi61946 жыл бұрын
Nice video, please try the 8Mhz setup @3V. What is the difference about the power consumption?
@RalphBacon6 жыл бұрын
I'll have a go, Istvan, and report back in a future video. Without a doubt, it should reduce consumption again. Thanks for the nudge.
@slm60uk6 жыл бұрын
If I've got my maths right then assuming an average 25uA drain, then that 2200mAH battery should last almost exactly 10 years (if it were perfect!). I recently watched a video of someone (can't remember who) who ran a similar circuit off a 3V coin cell, and that ran for well over a year, which makes sense as a CR3032 has a capacity of 220maH.
@RalphBacon6 жыл бұрын
You're doubtless correct, slm60uk, as I too have come to the conclusion that the flashing LED circuit I now have sitting in the corner of my workshop is never going to stop before the universe itself ends, so I am going to wire up a tiny 100mAH battery and see how long that lasts! Hopefully not so long before the next update...
@Joe_Galaska6 жыл бұрын
Nice video. I was going to ask what the capacitor values were on the "naked" bread board but then you mentioned a future video will cover. Hard for me to duplicate and experiment with if I don't know what those values are. I am new enough to the details to just get me into trouble. More often than not I release the magic smoke. Keep up the great work!
@RalphBacon6 жыл бұрын
A video is queued up and ready to go, but I don't think I'm giving anything away by telling you, Joe, the small caps next to the 16Mhz crystal are 22pf and the one by pin 1 (used to reset the device) is 0.01µF. But I explain this in more detail in forthcoming video #117, so you may want to watch that first. Since that video, I've experimented with the ATmega328P's on-board 8Mhz oscillator as well as the ESP8266 --- but that _is_ giving too much away!
@interestingspagetti6 жыл бұрын
Nice vid. I saw the use of a watchdog timer on a channel called SuperHouseTV (hope ok to reference). He basically automated his whole house using arduino's. But he used it in case of a power cut. To give everything time to wake up. But yeah, love your channel.
@RalphBacon6 жыл бұрын
I saw a video of him (of SuperHouseTV) going to the Sonoff factory in China, Dave, that was a looong video too but very watchable. Using this project to protect against power cuts is something I either have already mentioned or will do so in video #117, it's an easy thing to do, depending on the criticality of the system being protected, of course. Thanks for posting.
@interestingspagetti6 жыл бұрын
Sorry if you did mention past hence. I'm fairly new to your channel. Only just getting into arduino's. Some of it is beyond me. But learning so much and getting more understandable. Best of all i'm learning to code a little. I've found the hobby i'm looking for. Once again many thx.
@RalphBacon6 жыл бұрын
You're most welcome, Dave, and I hope you enjoy the Arduinite ride. It can be frustrating at times, but it's all a learning experience and success tastes all the sweeter because of the hurdles we must sometimes overcome. If you haven't already subscribed you might consider doing so, if only to be advised on new videos (sort of weekly). Thanks for posting.
@davidmarks50911 ай бұрын
Love the videos. I saw one of your videos where you use a Lipo with the brand ultrafire which is what happened a few houses away where a lipo battery caused a house to burn to the ground. I am using NiMa batteries they are easier for me
@RalphBacon11 ай бұрын
Oh wow! Yes, some LiPo batteries from dubious sources have to be treated with respect/suspicion, or do you what you have done!
@davidmarks50911 ай бұрын
Yes they do but what a good name for them ultrafire which happened to some persons house a street away from me. They said it was a lipo fire could of been from a laptop or some RC thing. NI MA for me no house burning involved. :)
@Ed196016 жыл бұрын
Very good
@RalphBacon6 жыл бұрын
Thanks for that, Ed19601, nice to hear from you.
@stepanberan46414 жыл бұрын
Very cool video!! Would love to have an IoT teacher at my school that is at least half as good as you at explaining things.
@RalphBacon4 жыл бұрын
Wow, thanks! Perhaps I should have been a teacher (nearly was, actually). Thanks for posting!
@JonnyBergdahl6 жыл бұрын
I'm kinda surprised by your results. A bare ATmega328P shouldn't draw more than only 4 uA in deep sleep. I do see that you have a pullup on the reset line that might explain the extra power draw? It has an internal (weak) pullup internally so it's not really needed. Also, you could go further into other power saving techniques such as lowering the frequency and the voltage. The ATmega328P draws significantly more power on 5 V compared to 3 V, in the order of 3-4 times. Lowering the frequency also have an impact, in the order of half the current. Just note that there is a maximum frequency the ATmega328P can run off a certain voltage, 16 MHz on 3V don't work so well. I have a board sitting beside me that I run off two AA batteries. It is a modified 8 Mhz Arduino Pro Mini, where I have removed the power regulator and the power LED. It has run for 2.5 years already, and the voltage level on the batteries is only marginally lower. I initially calculated a life time of +5 years, but it looks to be even better than that.
@RalphBacon6 жыл бұрын
And I'm impressed with your Arduino board running for 2.5 years on a couple of AA batteries. Running at a lower frequency is fine if you're then prepared for the millis() and delay() to take twice as long or are prepared to edit a file (eg boards.txt) or two to get it all back in line. I just took the easy path on this one! I'm shutting down that breadboard of mine and connecting a small 100mAH battery as the one I have will last forever. I'll also take out the pull-up resistor and see what difference that makes. Great information, Jonny, thanks for posting.
@JonnyBergdahl6 жыл бұрын
Actually, if you select Arduino Pro Mini in the Arduino IDE, it adds a new sub menu where you can select between 3.3V, 8MHz and 5V, 16MHz (I did create my own board definition for a 12 MHz board I designed though). Note that you need to burn the bootloader that is made for the frequency as well, otherwise the serial speed is wrong and you can't upload sketches.
@RalphBacon6 жыл бұрын
I've got a board definition for an 8Mhz breadboard Arduino (from Arduino.cc themselves would you believe) so I'm playing about, er, doing in-depth analysis and research with that one. Perhaps a future video update?
@JonnyBergdahl6 жыл бұрын
Just note that you can't use 115200 on Serial when running at 8MHz. I found that out the hard way, thus my need for a 12 MHz version. :-)
@RalphBacon6 жыл бұрын
Good to know, thanks for the heads up.
@tsarath4 жыл бұрын
As an added reference, there is a LowPower library available to make this easier, so you can do "LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);" to sleep for 8s which is the max and then wake it back up, library is here github.com/rocketscream/Low-Power
@RalphBacon4 жыл бұрын
Very useful link, thanks for that. That said, It is always good to know _why_ and _what_ you are invoking the "long way" before using libraries (which is why I often do it the long way first, just to show my viewers what they are trying to achieve, before letting us all off the hook by using a library!)
@tsarath4 жыл бұрын
@@RalphBacon Agreed! thanks btw for a great video, got my "bare naked 328" going to sleep every 8s and checking millis() before doing some work. What is the meter you used to measure current btw? I need something similar as when I connect my generic multimeter (switched to mA) in series, the 328 doesn't come on for some reason even though it registers power being drawn...
@RalphBacon4 жыл бұрын
My current meter dongle came from Banggood but I've just ordered a different model (spooky coincidence!) because I wanted both voltage and current to be displayed simultaneously. It's this one: bit.ly/USB_Current_Monitor_Dual A bit more expensive (a couple of $) compared to my original one: www.banggood.com/KW-202-Digital-Display-USB-Portable-Tension-Tester-Voltmeter-Battery-Tester-Blue-p-1153997.html?p=FQ040729393382015118& but this one alternates between voltage and current which gets a bit irksome if you're just after current.
@TYGAMatt3 жыл бұрын
Hi Ralph. Long time ago I know, but why use a volatile char for the sleepcnt variable? I'm just going to use your sleep code for a project and a bit confused by this. Cheers. Matt.
@RalphBacon3 жыл бұрын
Good question! All the "volatile" bit does is to ensure that the variable value is retrieved from its memory location rather than relying on a register value that previously held that value. No harm done (other than a few microseconds of time to retrieve the value). However, as the Arduino retains its memory across Deep Sleeps you are safe to remove that attribute. Note that on _an ESP32_ a variable _must_ be decorated with the RTC_DATA_ATTR attribute as we store any variables we want to retain across Deep Sleep in the RTC memory. Then no special precautions are required when updating it.
@TYGAMatt3 жыл бұрын
Thanks Ralph. Sorry, I wasn't specific. Why a char variable? I understand the volatile bit and also the requirements for an ESP32. I've had this sleep code (with my oen function) running flawlessly for two days now, but just didn't really grasp why you used a char and not a byte for example. I haven't changed the variable type but maybe I will just to see what happens! Cheers as always. Matt
@RalphBacon3 жыл бұрын
A "byte" is a made-up variable type not commonly used elsewhere; it is the exact equivalent to a uint8_t (single byte unsigned integer) in C++. I personally would not use this data type as it does not describe the data in any way at all. A "char" is the equivalent of an int8_t (single byte signed integer), usually. Which one you use shows your intent; did you expect a small integer returned or an actual character such as 'b'? Any single byte type can hold up to 255 in value, but that may be interpreted as a negative number if you use char, so could represent -128 to +127 if the first bit in the byte is set. Confused? You should be!
@pildimir4 жыл бұрын
Why is MCUCR = bit (BODS) | bit (BODSE); MCUCR = bit (BODS); not used in the timer example? Can i use it and where in the code?
@RalphBacon4 жыл бұрын
Because I don't have Brown Out enabled! It's a bit of a nuisance whilst developing so I usually set the fuse to turn it off entirely. If you do have it enabled (and must therefore execute those lines of code) do it immediately before sleep mode is invoked. I believe I have used this in some of my demos. Nick Gammon (no relation) is the guru of stuff like this, have a read of his site on this topic: www.gammon.com.au/forum/index.php?bbtopic_id=123 A beautifully written site, chock full of essential Arduino information.
@pildimir4 жыл бұрын
@@RalphBacon thank you, your site is very interesting.
@ChrisGlasow2 жыл бұрын
Hi Ralph, I noticed you were able to order components from AliExpress, but I get the 'not shipping to your region' dialog. Do you have a way of being able to order stuff from them? Any advice would be greatfully recieved😊
@RalphBacon2 жыл бұрын
Your username includes "Glasgow" so if you have chosen United Kingdom as the destination it will be fine (I've had several dozen parcels from them). Look at the top right of the page where your currency / region are and make the appropriate selections, otherwise it defaults to somewhere like Albania (the first country in the list). 😲
@ChrisGlasow2 жыл бұрын
Hi Ralph, OK, resolved it by creating another account, so something went wrong in my original account setup. All resolved and good to go. Thanks for your help Ralph. Cheers Chris
@willofirony6 жыл бұрын
Naked AVR?? ATMega porn? Brilliant vid, Ralph At risk of pre-empting part 3, further savings (for a micro doing some actual work, when not asleep) can be made by reducing the frequency of operation. This has the added advantage of not needing the crystal and oscillator circuitry and stable operation at lower voltages.
@javierpallalorden6 жыл бұрын
Michael Keegan Yes 8MHz, and you do not need the crystal.
@RalphBacon6 жыл бұрын
Yes, I think I mention in one of the three videos (#117 not yet released) about reducing the clock rate to run on a lower voltage (down to 1.8v) but I think I was at that point thinking I was milking the topic just a tad. I also didn't cover running on the internal clock as that required a (minor) bootload change which, when you see my next video, has been covered enough! Running at anything other than 16Mhz means that all timers run incorrectly so I didn't want to get into that. Who would have thought that there was so much to cover?
@RalphBacon6 жыл бұрын
PS I am not allowed to use the n-word here as KZbin flags it up and blacklists my video! I think even "bare" is pushing it ;-)
@DirtyLemming4 жыл бұрын
What piece of equipment is being used to measure such a low current?
@RalphBacon4 жыл бұрын
I'm using a UT803 multimeter by UNI-T, a well established brand with some high quality equipment.
@andymouse6 жыл бұрын
Hi got a software problem for you and benny to mull over: if (heat > too much & andycantsleep = TRUE){ drink Guinness} else { andy = deepsleepmode } Interrupt = don't ; } } this does not work any thoughts ?...…………..thanks in advance
@RalphBacon6 жыл бұрын
You forgot the double "=" on the first line, == TRUE, no wonder it doesn't work! Also, you misspelled Murphy as Guinness! I asked Benny, and he just looked at me weirdly in a "can't sleep? What on earth does that mean", and he then back to do-not-disturb mode. Hope this helps.
@psykopat81 Жыл бұрын
hi, thank you for your video, it is very helpfull. i have a strange problem, if i set sleepcnt < 115 (approx. 15 minutes) everything works fine, but if i set < 150 or above it doesn't work and i want to set sleep time 35 minutes.. ( i am using aurdino nano btw)
@RalphBacon Жыл бұрын
The maximum Deep Sleep RTC timer for the Arduino UNO and Nano is just 8 seconds so are you waking the Arduino using an external signal interrupt on GPIO pin D2 or D3? When I wanted a long Deep Sleep (power off), I counted how often the Arduino woke up ( in multiples of 8 seconds) and if less than the required time, immediately went back to sleep - it took just a few milliseconds to do all this. I wanted it to wake up after 1 minute so after 8 cycles of sleep/wake (8 secs * 8 wakes = 64 seconds) I continued with the code. Using an ESP32 it's quite different and you can Deep Sleep for up to 5 YEARS! because the RTC timer is a 64-bit counter not the tiny 8-bit counter in the Arduino. I can recommend Nick Gammon's article on all the various sleep states for the Arduino: www.gammon.com.au/forum/?id=11497
@psykopat81 Жыл бұрын
@@RalphBacon i am trying your code (using wdt , thank you for sharing btw). i want it to sleep e.g. 40 minutes, so sleepCnt should be 40 * 60 / 8 = 300, right ? if i set sleepCnt > 120 code doesn't work (for me at least)
@RalphBacon Жыл бұрын
Yes, 40 minutes is 40*60 seconds (2400) so divide by 8 second "chunks" of Deep Sleep should get your the required delay. If it "doesn't work" for you (a bit vague!) put a Serial.println in the code every time it comes out of Deep Sleep so you can find out _when_ it stops working. Make sure too, that you are not using short integers (uint8_t) for your maths as that will introduce truncation (255 max for a uint8_t aka short int).
@psykopat81 Жыл бұрын
@@RalphBacon thank you for your detailed answer. but i didn't understand "Make sure too, that you are not using short integers (uint8_t) for your maths as that will introduce truncation (255 max for a uint8_t aka short int)."
@RalphBacon Жыл бұрын
That means, in your sketch, use the 'int' type for numeric variables not the 'uint8_t' type because an integer can hold up to 32,000+ but a uint8_t only hold up to 255 which is not large enough for the maths you are doing here. Stick to 'int'. Any more news on what you mean by "doesn't work"?
@meJoKeR655 жыл бұрын
Hey Ralph, can you tell me how can I change the time it takes to wake up the arduino? Can I even program it to wake up after an hour?
@RalphBacon5 жыл бұрын
Unfortunately, Stavros, if you are using the Watch Dog Timer (WDT) method then the Arduino will wake up after a *maximum* delay of 8 seconds. That doesn't sound a lot but your code can just increment the number of times it's been woken up and go straight back to sleep again. So for an hour that would be 3600 secs / 8 secs = 450 wake-ups. Alternatively, if you are using the interrupt method of wake up then you need something to provide a LOW pulse on pin 2 or 3 as per my demo. This can be a manual intervention (eg someone pushing a button connected to GND) or a DS3231 Real Time Clock (RTC) that you have previously set an alarm for, to wake up after an hour. At its simplest (and depending on how accurate you need it to be) an NE555 timer could be a solution too. I hope that helps but feel free to ask further questions!
@meJoKeR655 жыл бұрын
@@RalphBacon Thanks for the quick answer! Maybe I will get and RTC but for the time being can you please advise me how to set the alarm to 8 seconds?
@RalphBacon5 жыл бұрын
If you read this article and understand it you will be able to set your WDT to the maximum of 8 seconds. I hope this helps. folk.uio.no/jeanra/Microelectronics/ArduinoWatchdog.html
@meJoKeR655 жыл бұрын
@@RalphBacon Thanks for everything Ralph! You see, me and my brother are working on a project where will will measure the weight and temperature of beehives and we need that extra power. Thanks again, really appreciated.
@RalphBacon5 жыл бұрын
Finally, someone is using an Arduino for beehives and bees! Fantastic!
@rasmushaun17736 жыл бұрын
Thanks (: How do you get it down to 20 mA? My arduino Uno is 3o mA with your code. It is powered by 5V (:
@RalphBacon6 жыл бұрын
I guess not all Arduino-style circuit boards are created equal. The LEDs, for example, on your board could consume much more current. To be honest, trying Deep Sleep on a full UNO board is never going to give you good results. Try following video #117 using a bare Arduino chip - then you'll see it's the same.
@whitefields55956 жыл бұрын
Ralph, Here is a barebones ATmega 328 board that allows for selective inclusion of components www.bitsbox.co.uk/index.php?main_page=product_info&cPath=140_161_164&products_id=3297
@RalphBacon6 жыл бұрын
Looks nice, a bit wider than this other USA one: kevinrye.net/index_files/barebones_arduino.php assuming it's even available. I'm tempted by the bitsbox.co.uk version, perhaps I should negotiate an affiliate deal... Anyway, thanks for the info, interesting.