Low Power Arduino - Sleeping at 0.3mA perfect for batteries (Arduino Nano deep sleep)

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 พ.ค. 2024
  • How to make your Arduino Nano run on 3mA and sleep on only 0.3mA. In deep sleep mode you can make your arduino nano run on batteries for a long time.
    We are going to test:
    - which PIN is best for powering the Arduino
    - remove the LED to save energy
    - slow down the Arduino (clock prescaler)
    - lower the voltage
    AND
    - Remove the voltage regulator and put the Arduino in sleep mode.
    Note that the VIN pin do not work when the regulator is removed.
    The same results can be expected from the Arduino Pro Mini as well.
    Perfect when you want to run your low power arduino on a battery.
    Code for sleep
    ***********************
    Code for sleep
    ***********************
    #include (insert Angled brackets)avr/sleep.h(insert Angled brackets)
    void setup() {
    CLKPR = 0x80;
    CLKPR = 0x01;
    }
    void loop() {
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);
    sleep_enable();
    sleep_cpu();
    }
  • วิทยาศาสตร์และเทคโนโลยี

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

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

    Want to support us? Buy us a coffee ☕️ ​buymeacoffee.com/DIYTechBros​​

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

    Late to the game but just what I needed for an ongoing project. Thanks for sharing 👍🏼

  • @zaferaltun
    @zaferaltun 8 หลายเดือนก่อน

    Amazing man!

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

    Wow! great technique , never thought of it like that

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

    i SEE A GREAT SKILL OF UNDERSTANDING THE ARDUINO CONCEPT. lOOKING FOR MORE INSTRUCTIVE VIDEOS. THANK YOU FOR SHARING AND MAKING US BETTER

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

    Good work bruh , wondering why this video is not getting more views👏👍

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

      Thanks! This is a video for experts - so kind of small niche ;-)

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

      @@DIYTECHBROS I wish this video get more view as much , so that it can encourage you to do more videos . Never stop this kind of work . We need your guidance.

  • @dontmindme402
    @dontmindme402 7 หลายเดือนก่อน

    Thank you for the vid, but i do wanna ask if i want to time it for it to wake up in 4 mins and half, how do i add the millisecond

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

    Thanks for this great video. I do have a question though. Can this process be done on any Arduino Nano of just for this model? Thanks.

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

    this is helpful if you already have the nano on hand and don't plan to do other projects. however, if you want to run on battery power, getting the atmega chip itself seems like a better idea since that one can go into super deep sleep.

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

      True!
      But, instead of getting the atmega328 from the Nano it would be easier using the attiny85 (or a newer like the attiny1604). Less components and same ultra low power consumption in sleep.

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

    great video. quick question how would i wake it up using a touch sensor

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

    Nice detail.

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

    if I put arduino uno into sleep mode does it keep variables values and continue the code instructions using interrupt ?

  • @michaelweatherby8648
    @michaelweatherby8648 4 ปีที่แล้ว +2

    Great video, found a discussion on Arduino forum from 2016, this really fills in the gaps. Investigating idea of battery operated lock for hidden wall safe, want to see if I can do 2 factor, biometric lock and maybe some kind of hidden magnetic switch for power activation. Just started concept today and found all the pieces in the Arduino library. What a great ecosystem of stuff....! will check out reduced boot time video

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

      ohh... that sounds really exciting :-)

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

    Perfect

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

    This is exactly what I am looking for!!!

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

      Great :-)

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

      dear sir, i did exactly as you did on the video. but how i will wake up the arduino nano? im using a pir sensor for interrupt, but nothing happens! it doesnt wake up. any solution sir? thank you

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

      Hi!
      Two questions that will allow us to help.
      1. How does the wiring look?
      2. What does your code look like?

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

    Very useful video. Thanks

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

    thanks, how to wake up again if sleep mode is enabled? I'm using the RTC module and if I reverse the code can the arduino wake up at the time interval I want?

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

    This is great!!!

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

    @DIY TECH BROS, why you use RST pin? You don't use VIN pin.

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

    Hi. Thanks for the video! As a beginer, I would like to ask you some questions:
    1 - It is possible to create an instruction that according to the inputs received, the clock of the processor changes up or down, without the necessity to reset it?
    2 - What about the consumption of Nano + NRF2401 + Analog Joystick?
    3 - Do you think that its possible to connect the configuration above in 2x 1/2AA lithium batteries?
    Thanks in advanced!

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

      Hi Cristiam! Seems like you main question is about power consumption? IF you want to go beyond whats in this video, I would recommend having a look at the ATTINY85 (we have a video on how to program it). It will run on low voltage and lower the power consumtion!

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

      DIY TECH BROS Thanks for your answer. My project consists in one base connected directly on the power supply and a remote station supplied by batteries that needs to wake up when the base send an “activate” signal to it, otherwise it must sleep for less power consumption. I checked about ATTNY85 as you suggested and I think that the Nano can be replaced by this. Thanks! But I read that the RF24 module itself consumes 12mA, so I’m afraid about my batteries... Other question, do you know some small module that has the processor and the radio communication integrated in one circuit?

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

      ​ @Cristiam Kechinski Did you find any solution to your problem? I am trying to make a "lock opener" which is contacted to a NFC / RFID scanner on the front of the door. The actual unlocking mechanism is handled by a stepper motor, which should be connected to smth like an Arduino. The issue now is that I also need to power a NRF2401 module and the Arduino itself by using batteries. The whole thing should last at least a couple of months, otherwise it would make no sense at all. I would really appreciate your help.

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

    Great! Thank you!!! But if you lower the clock settings, how do you restore them on wake up so that you don't mess up Serial comms?

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

      Hi, did you learn this topic?

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

      @@oguzhanergin224 No. Not yet. (i.e the effect of lower cock speed upon Serial comms)

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

      @@kychemclass5850 Thanks

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

    If in sleep mode can it wake up with an external button press.

  • @ArcanePath360
    @ArcanePath360 3 ปีที่แล้ว +2

    Nice!

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

    Hi! Thanks for your interesting videos!
    Can i ask you, how we can use Li-Po or Li-Ion battery to supplying an Arduino Nano?
    I can't find good information, about the best way to use 3.7V battery.

    • @DIYTECHBROS
      @DIYTECHBROS  3 ปีที่แล้ว +2

      Sure, there are two options.
      Power it on the 5V pin with the battery. As it drops too low you might run into issues, but over all it is usually quiet reliable on lower voltages (until you reach a certain level).
      Alternatively, use a step up converter!

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

      @@DIYTECHBROS Thank you very much! Really great channel! :)

  • @sameerk12982
    @sameerk12982 4 ปีที่แล้ว +2

    Thank you very much Tech Bros for such an informative tutorial........learned a lot.

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

    Can you help me understand what you mean by destroy led than resistor? are you suggesting to either remove resistor or led? What battery you are suggesting to use? 3.7v ? if yes, then it doesnt work with VIN right?

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

      On the "easier to destroy the LED than the resistor" question, he means, using a heat gun or soldering iron to remove the component is more likely to destroy the LED than the resistor due to the high heat. It's safer to remove the resistor if you ever decide to repurpose the board and reinstall the resistor.

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

    Muito bom, parabéns.

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

    Great video! It really helped me. I have a question, if you remove the voltage regulator, can you power the arduino the Arduino with two Li-Po batteries of 3,7V (getting 7,4V) by the VIN pin? Or it may burn?

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

      use a voltage regulator

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

      Remove the regulator and your Vin is not connected to anything anymore.
      Should you put 7.4 volt (in worst case even 8.4 volt) directly on your chip it will go up in smoke

  • @H2ON_MEA
    @H2ON_MEA 4 หลายเดือนก่อน +1

    CLKPR = 0x80; CLKPR = 0x00; // Normal speed for 16 Mhz

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

    What temperature for the heat gun is "safe" for removing the resistor? I'm concerned about breaking nearby components.

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

      just don´t touch them while removing the voltage regulator

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

    Vin is NOT 5V, it's 7V+ up to 12V.
    You use Vin and have lower mA because you DOWNCLOCK it with a low voltage.

    • @DIYTECHBROS
      @DIYTECHBROS  3 ปีที่แล้ว +2

      Hi Sezer!
      The AMS1117 (5V) is, as you are saying, ment to convert down to 5V. But here we are manipulating the voltage to get a lower power consumption on the microcontroller (and a bit lower on the board as well). While we do value all comments, it is also important for our viewers that they are not just based on assumptions but on actual testing.
      Did you test this?
      I have no problems getting the needed power (amps) out of the 1117. And further more, as seen in the video, the Arduino also runs as expected.

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

      @@DIYTECHBROS Ok I understand, it makes sense to lower power consumption but I just wanted to note that Vin= 5V won't work work at same clock as VCC=5V

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

      ​@@DIYTECHBROS It makes no sense that involving MORE components (the AMS1117) make the arduino consume LESS power/current. And on your comment above you say that you manipulation the voltage but on the video (0:30) you are clearly stating that you are using 5 volt on the VIN pin (using the AMS1117).

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

      You are correct, although they are not downclocking it -- they are just running at a lower voltage. When they power through the Vin pin, the actual voltage going to the uC is less than 5V. This is because the linear regulator requires a headroom between the input voltage and output voltage. Even LDO's (Low Drop Out regualators) have some headroom. Lower voltage naturally reduces power consumption in the uC, however, running the uC at 16MHz really needs 5V to have guaranteed reliability. If you reduce the clock speed, then this method is fine.

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

      @@DIYTECHBROS sorry but thats bogus. If you want to have the atmega run on a lower voltage, say 3.3 volt then apply that directly to the chip and bypass/remove the voltage regulator on the board. A comparison between 5 volt on Vin and 5Volt on the 5 volt pin is just odd

  • @roboticsguyy
    @roboticsguyy 4 ปีที่แล้ว +2

    This video made me smile! I'm trying to build a 4-button RF remote control with Atmega 32p-pu (Arduino uno) and I need it to last 6 months off of two 3V coin cells. This video MAKES THAT POSSIBLE! THAANK YOU!!!
    Ps: I have 1 million questions to ask you on that very project, I don't want to be a bother...But Can I email them to you?

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

      Perfekt :-)

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

      One tip that can be an option for your project is the HT12D and HT12E RF modules!

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

      @@DIYTECHBROS Woah. I just googled it... Can it replace atmega itself?

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

      On the sender, yes :-) There are 4 inputs that can be transmitted to the receiver (decoder) that in turn can be read by an Arduino. That way you can skip the Arduino on the sender (encoder). If you can skip the Arduino the on the receiving end is depending on what you are doing with the data. Best of luck, and just ask any questions if there are any problems!

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

      @@DIYTECHBROS Basically in my project, I want to transmit the state of 4 separate buttons over a short distance (300cm tops). It will be a controller for a simple emergency vehicle siren system. At the receiver I will control the lights and sirens using relays depending if the button on the controller is on or off.
      I see simple RF remotes last 1 year +...I need mine to last that long. Can a HT12D and HT12E serve as transmitter and receiver in this project?
      Can I interface the HT12D with an nRF240L?
      Lol I just gave you a ton of work

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

    Are you serious saying that if you feed it on Vin (what voltage?) It consumes 12mA and on the 5 volt it consumes 18mA? Eventhough the x volt on the Vin has to go through a lineair regulator to get to 5 volts?? That seems very illogical unless you voltage you put on the Vin is too low

    • @jrstf
      @jrstf 5 หลายเดือนก่อน +1

      He probably fed 5V into Vin (instead of the required 7-12V), this sent about 4V to the processor which is why current consumption went down. As you point out, it'd be better to feed 4V into the 5V pin so you don't lose 20% of your power in the regulator, which is what he did.

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

    how can i wake it up, when the arduino is in deep sleep mode?

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

    You can also save power by reducing the time your Arduino spend restarting. Have a look at our other video: th-cam.com/video/lsa5h2tVM9w/w-d-xo.html

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

      On a side note: using higher value resistors and using active low instead of high will also increase battery life.

  • @user-ur9qq8us4y
    @user-ur9qq8us4y 4 ปีที่แล้ว +1

    If I want to connect sensors to my Arduino and also want them to be low power, what would be the best way? Would it make sense to switch their power in off with a Mosfet or Transistor while the Arduino is in sleep Mode?

    • @DIYTECHBROS
      @DIYTECHBROS  4 ปีที่แล้ว +2

      Hi Tim! Many sensors have a power down mode or a sleep mode. So if possible, that is often a good option. Otherwise a transistor is a good option, or MOSFET is the power consumption requires it!

    • @user-ur9qq8us4y
      @user-ur9qq8us4y 4 ปีที่แล้ว

      @@DIYTECHBROS thank you very much 👍

  • @Antz_411
    @Antz_411 หลายเดือนก่อน

    This works great if you never want the Nano to wake up again...

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

    Too low power 0.3mA but no show led on for 1sec, and led off for 10sec?

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

      Hi Andy! Not sure I fully understand your question? :-)

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

      I think he would like to say "put the Arduino into sleep mode in 10 seconds and then wake it up and turn on the LED in 1 second, in each loop". 😁

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

      Thanks Vu Anh Minh Le!